Jump to content

Mike Torrettinni

Members
  • Content Count

    1509
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Mike Torrettinni

  1. Mike Torrettinni

    Problem with ExitCode

    OK, I got it now! START /WAIT does the trick. Now it makes sense what you @Mahdi Safsafi and @Anders Melander are talking about. To recap: - running GUI application (no matter if it actually shows any GUI) - starting it in batch file, all commands are within same 'virtual' command window, so %ERRORLEVEL% will find correct ExitCode from project - starting it manually in cmd with just project.exe starts new 'virtual' command window and next manual command echo %ERRORLEVEL% will not find correct ExitCode from project, because it is not running in same command window. To fix this, we should use START /WAIT project.exe command. - running console application: - all works OK in all situation (with or wihtout batch file), because console application always runs in same command window as next commands, like echo %ERRORLEVEL% Right?
  2. Mike Torrettinni

    Problem with ExitCode

    Aha, now I understand Mahdi's post, probably not clear enough description. Perhaps I'm mixing terms like: cmd, command line and batch file run in cmd. Lets see if this give better picture: I run same project1.exe (VCL Forms project above, with just ExitCode set) in two different ways, both starting in cmd: This is running run.bat in cmd - works OK: This is running same lines, manually in same cmd - ExitCode is not correct: Is this showing my misunderstanding?
  3. Mike Torrettinni

    Problem with ExitCode

    Thank you, but I'm not seeing the connection to the issue I have... what am I missing here?
  4. Mike Torrettinni

    Problem with ExitCode

    OK. Then why does it work 100% reliable in batch file? Same GUI project.
  5. I'm not sure the verbiage of title is correct, but here is the question: when I have TItem and TItems defined as: type TItem = record ... end; TItems: TArray<TItem>; Is there any obvious disadvantage of using TItems instead of using everywhere TArray<TItem> for variables, function results, parameters... ? I don't know how to phrase the question to ask google about this, in case this is widely discussed topic already.
  6. Mike Torrettinni

    Possible custom Format types?

    Thanks, but I rarely use RegEx and only with very simple expressions.
  7. Mike Torrettinni

    Possible custom Format types?

    OK, makes sense. It looks like very versatile function!
  8. Mike Torrettinni

    Possible custom Format types?

    Thanks! You never had the need to not replace with space, but just delete the %... ? I usually have spaces around the %..., so in this case you end up with triple space, right? 'Customer name %s is wrong' -> 'Customer name is wrong'. No?
  9. Mike Torrettinni

    Possible custom Format types?

    Wow, a lot more options. I see it now. I was reading this page and didn't scroll down: http://www.delphibasics.co.uk/RTL.asp?Name=format
  10. Thanks! Sometimes such clear wording makes all the difference. Yesterday reading in official help and SO answers, I just didn't get it. Now, re-reading the same again, it makes sense.
  11. Great, thank you! Do you have a real case scenario for using the second option, TSessionID = type integer; ?
  12. You are talking about TSessionID = integer; or TSessionID = type integer; ? I understand the use of first one, but not the second one.
  13. OK, I've never seen this, and the more I read about it, the more confused I am what it is used for. I understand it becomes new string type, compatible with just string. But I don't see how it's useful.
  14. Skipping 10.3.x altogether. Will see how 10.4 updates will be successful.
  15. I envy you. I don't have the same experience as you do, renaming across multiple units regularly fails on my Delphi 10.2.3, unfortunately. It's probably my project design contributing to the issue, but still, the IDE should be managing this better or alert on complex unit design if it bothers it.
  16. This happens to me quite often, start with new feature and after a while I see the different naming would be more suitable. So, now changing an alias will be so much easier, because refactoring/rename of type doesn't always work across multiple units.
  17. Isn't TArray<T> only for generic usage? I use it when I define generic method, and is used like TArray,Method<T>... Can it be used for specific usage, like: type TItem = record ID: integer; Text: string; ChildCount: integer; end; fData = TArry<TItem>; function GetText(aIdx: integer): string; begin Result := fData[aIdx].Text; end; Not sure how TArray<T> could be used in this example?
  18. Thanks for simple example, I see the difference. I use TArray<> a lot, will see if I can get used to defining these aliases.
  19. Great, thanks for confirming. I knew such alias can be defined, but never really thought of defining and using it for my own arrays. Now I will! 🙂 Thanks, when I search for alias I get some results.
  20. Mike Torrettinni

    Chatbots on whatsapp. Freeware.

    This link works for me: https://github.com/mikelustosa/Projeto-Tinject Thanks, I found that but couldn't make the connection. Thanks, now the connection is made. 🙂
  21. Mike Torrettinni

    Chatbots on whatsapp. Freeware.

    Google Translate says: "Most RECIFENSE component of the internet!". What does Recifense mean?
  22. Mike Torrettinni

    Typed constants in Delphi.

    Eh, quite disappointing actually. They turned such a good topic into: https://xkcd.com/386/
  23. Mike Torrettinni

    Typed constants in Delphi.

    I always thought that non-typed constants are 'old' type of constants before benefits of typed-constants were obvious and were needed to be implemented. For integers I have no problem with non-type constant, while for colors (hex numbers) I always have to think do I need to specify constant as TColor or not, so I always need to test what works: const cColor1: TColor = $00FAFAFA; cColor2 = $00FAFAFA; Thanks for detailed explanation!
  24. I have often simple cases where I need to process a short list. So, I'm trying to come up with an example method that is simple, new values are easy to add and is just overall clean method. Here I have 3 examples of FixOddIssues: replace OldValue with NewValue in string. Starts with replacing 'FACTORXYZ' with 'REFACTORING XYZ', and I will probably add 3-5 more cases. // USING ARRAY procedure FixOddIssues(var aSQL: string); type TIssue = record OldValue: string; NewValue: string; end; var vIssue: TIssue; vIssues: TArray<TIssue>; begin // change all issues vIssue.OldValue := 'FACTORXYZ'; vIssue.NewValue := 'REFACTORING XYZ'; vIssues := vIssues + [vIssue]; for vIssue in vIssues do aSql := StringReplace(aSQL, vIssue.OldValue, vIssue.NewValue, [rfReplaceAll]); end; // USING 2 CONSTANTS procedure FixOddIssues2(var aSQL: string); const cElements = 1; cOldValues: array [1..cElements] of string = ('FACTORXYZ'); cNewValues: array [1..cElements] of string = ('REFACTORING XYZ'); var i: integer; begin // change all issues for i := Low(cOldValues) to High(cOldValues) do aSql := StringReplace(aSQL, cOldValues[i], cNewValues[i], [rfReplaceAll]); end; //USING CONSTANT ARRAY procedure FixOddIssues3(var aSQL: string); type TIssue = record OldValue: string; NewValue: string; end; const cElements = 1; cValues: array [1..cElements] of TIssue = ((OldValue: 'FACTORXYZ'; NewValue: 'REFACTORING XYZ')); var i: integer; begin // change all issues for i := Low(cValues) to High(cValues) do aSql := StringReplace(aSQL, cValues[i].OldValue, cValues[i].NewValue, [rfReplaceAll]); end; Any better suggestions, easier solutions?
  25. Mike Torrettinni

    Simple list processing example

    Thanks, I think I will do that.
×