Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 08/23/21 in all areas

  1. A.M. Hoornweg

    How to use unit BufferedFileStream & FastCopy?

    David asked "What's wrong with". So I pointed out some. OP may have other reasons, admittedly. 🙂
  2. I agree to that. Maybe the best way, to catch any of the remaining formats is, to seek the string reversely, from end to start. 1. Then take the last separator (first found when searching reversely) in the string, as preliminary decimal separator. 2. If there are more separators in the string, they could be safely ignored, they can only be thousands separators. 3. If separator 1.) is the only separator in the string, only then you might run into an unclear situation, as you explained above. 4. But you still could try to count the number of decimals after the last separator if there are <> 3, then you still could be very sure that it's NOT a thousands separator, but a decimal separator. 5. Even if you have >= 6 decimals, it should be a decimal separator, as I rarely expect having a million separator without a thousands separator. ( Still somebody could do nasty things like that ) 6. Only if there are exactly 3 decimals, then you better know your format source.
  3. A.M. Hoornweg

    How to use unit BufferedFileStream & FastCopy?

    I avoid it for the following reasons. First of all, the CopyFileEx API documentation does not specify if the source file is opened for shared access or not. So I don't know how it behaves when multiple users are accessing the file and if that behavior may change in future. Secondly, when I copy a file somewhere, I emphatically want it to inherit the access properties of the target directory. Otherwise the access rights become unpredictable. Unfortunately, the CopyFileEx API documentation says "The security resource properties (ATTRIBUTE_SECURITY_INFORMATION) for the existing file are copied to the new file". I really don't want that to happen.
  4. TFunc is anonymous method, which are backed by interface. So GUID you get from field type is not for ITestA,, but for TFunc<ITestA>. I don't think you can get generic part out from parameterized type. In theory TFunc has Invoke method, so if you could get information on its result type, you would have ITestA. But I couldn't get Invoke information out of RTTI. The real question here is what you are actually trying to do. Your test code is obviously just a test - you already know that TForm1 MyField works with ITestA, so if you can make small test case for your actual use case, maybe there is a way to get information you need. For instance if your form would be generic, you would more easily get what you need because you would have T to work with TForm1<T> = class(TForm) private MyField:TFunc<T>; end;
  5. Bob Baudewyns

    How to design QR Scan focus screen with FMX

    Thank you again Rollo62, In the meantime, I did something very close in the IDE with: - 1 TGridPanelLayout - 4 Outer Black TRectangle with opacity 0.5 - 8 Inner Yellow TRectangle with appropriate rounded corners With a TImage as background for rendering the camera, it looks Ok to me
  6. Dalija Prasnikar

    thread-safe ways to call REST APIs in parallel

    None of those components are not thread-safe. They can be used in background threads, but each thread needs to have their own instances. Yes, you need separate client objects for each thread, too. If the StringList is not shared and you generating unique file name is coordinated between threads, so there cannot be any overlap, then it is safe to save inside thread.
  7. I was working with various kinds of financial data, weather data and power data (prices, volumes, etc), and thousand separators usage was variable. Spaces, commas, dots, the lot. It was a hodge-podge of formats since very few standard exchange formats existed at the time. Even vendors that you had contractual agreements with, would change the format on the fly, without notice. "Yeah, we changed the format. Nobody told you?"
  8. The common trait is that both floats and dates have separator character challenges. For floats, the only reliable solution is to KNOW the input format and do the necessary stripping/replacement before passing the string to the converter. In some of my older input parsers, I stripped spaces, then checked for the presence of , and . and did the following processing - if only one exists, don't touch it - if more than one of a kind exists, remove them all - if both exists - remove all but the last one Which still is hopeless if the 1,000 is 1000 and not 1 with three decimals.
  9. That seems to be correct, thousands separators are not accepted, so have to first handle them self.
  10. When Thousand separators come into play, it starts to get almost impossible, (At least in here). 1,006.66 or 1 006,66 or 1 006.66 etc... And if sometimes there are no decimals. How to fix US version without decimals 1,006 and Finnish ones with them 6,66. As far as I know there can't be universal routine to rule them all. US I think thousand separator is Comma, here it is decimal separator. THis is one of the places there would have been nice to have global standard, and only one 🙂 -Tee-
  11. Unless you do that in place with PChar pointer magic that's a heap allocation! 😉
  12. I prefer to replace dot or comma with the locale's decimal sep and then use StrToFloat. Although in reality I don't use the Emba conversion functions because they are defective, i.e. not accurate.
  13. function MyStrToFloat(const S: string): Extended; const Komma: TFormatSettings = (DecimalSeparator: ','); Dot: TFormatSettings = (DecimalSeparator: '.'); begin if not TryStrToFloat(S, Result, Komma) then Result := StrToFloat(S, Dot); end;
  14. Remy Lebeau

    Bug with formatfloat in crossplatform ?

    That is wrong. Don't assign the new TFormatSettings instance to the global FormatSettings variable at all (in fact, pretend that global variable doesn't even exist). Pass the new TFormatSettings instance directly to FormatFloat() instead, eg: fs := TFormatSettings.Create(SysLocale.DefaultLCID); // customize fs as needed... ShowMessage(FormatFloat('###,###.00', 1234.25, fs));
  15. Remy Lebeau

    Correctly displaying a Message Dialog in FireMonkey

    TDialogService.MessageDialog() is asynchronous on Android, per the documentation, so the dialog won't appear until after SpeedButton5Click() has exited. As such, your code is trying to use the Reply variable before it has actually been assigned a value, which is why StartLogin10() is not being called. Android simply does not support modal dialogs, and so the RTL does not implement any synchronous dialogs on Android. See Using FireMonkey Modal Dialog Boxes, TCommonCustomForm.ShowModal(), and IFMXWindowService.CanShowModal() for more details. You need to move the call to StartLogin10() inside the MessageDialog() callback, eg: procedure TFrmLogin.SpeedButton5Click(Sender: TObject); begin if (lst2.Items.Count <> 0) and (lst2.ItemIndex <> -1) then begin TDialogService.MessageDialog('you are gonna edit something ', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes], TMsgDlgBtn.mbYes,0, procedure(const AResult: TModalResult) begin if AResult = mrYes then StartLogin10 else ShowMessage('you have cancel the operation'); end ); end else ShowMessage('chose something from the list'); end;
  16. function StrToInt00(sString:String; out f : Float32):Boolean; var fs:TFormatSettings; begin try try GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, fs); // remove space if ContainsText(sString, ' ') then sString := StringReplace(sString,' ','',[rfReplaceAll, rfIgnoreCase]); if ContainsText(sString, ',') then begin if fs.DecimalSeparator='.' then sString := StringReplace(sString,',','.',[rfReplaceAll, rfIgnoreCase]); end else if ContainsText(sString, '.') then begin if fs.DecimalSeparator=',' then sString := StringReplace(sString,'.',',',[rfReplaceAll, rfIgnoreCase]); end; finally f := StrToFloat(sString); Result := True; end; except Result := False; end; end;
×