Jump to content

FredS

Members
  • Content Count

    418
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by FredS

  1. FredS

    IDE Fix pack for Rio

    From: https://andy.jgknet.de/blog/ide-tools/ide-fix-pack/ fastdcc There are 2 ways to use fastdcc. 1. Using fastdcc directly Extract the 7z file into your $(BDS)\bin directory. Start fastdcc32.exe as if it was dcc32.exe Start fastdcc64.exe as if it was dcc64.exe Start fastdccaarm.exe as if it was dccaarm.exe 1. Replacing dcc32.exe by fastdcc32.exe (don’t do this if you want to be able to install future RAD Studio/Delphi/C++Builder updates) Extract the 7z file into your $(BDS)\bin directory. Rename dcc32.exe, dcc32.jdbg and dcc32.de/fr/jp to dcc32compiler.exe/jdbg/de/fr/jp. Rename dcc64.exe, dcc64.jdbg and dcc64.de/fr/jp to dcc64compiler.exe/jdbg/de/fr/jp. Rename fastdcc32.exe to dcc32.exe Rename fastdcc64.exe to dcc64.exe Rename fastdcc32Hook.dll to dcc32Hook.dll For XE3 or newer: Rename fastdcc32Hook.dllx to dcc32Hook.dllx (“x” is necessary for Delphi’s copy protection) Rename fastdcc64Hook.dll to dcc64Hook.dll For XE3 or newer: Rename fastdcc64Hook.dllx to dcc64Hook.dllx Start dcc32.exe/dcc64.exe or msbuild.
  2. FredS

    (Mis-)Behaviour of TStringHelper

    LastIndex and DownRange would help but honestly, this is like having to flip your steering wheel when you shift the car into reverse. 🙂
  3. FredS

    (Mis-)Behaviour of TStringHelper

    Yeah, certainly made clear in the documentation </sarcasm> One would hope that when they copied a DotNet function they could at least copy the DotNet explanation: The search starts at a specified character position and proceeds backward toward the beginning of the string for the specified number of character positions. At this point the claim that it works as expected needs to come with new documentation.
  4. FredS

    (Mis-)Behaviour of TStringHelper

    True but it is the same as IndexOf, should I now file a bug report for IndexOf? StartIndex specifies the initial offset in this 0-based string where the search starts Because this does not compute: Assert(s.IndexOf('Hello', 38) = s.LastIndexOf('Hello', 38)); I originally looked at the source and also took " startIndex - (Length(searchText) - 1)" into account but here is that math: // 0 19 38 0-based s := 'Hello how are you, Hello how are you, Hello how are you'; // ^ 32 Startindex - (Length('Hello')- 1), searched forward or backward? IMO at this point the claim that it works as expected needs to come with new documentation or a bug fix.
  5. FredS

    How to fix missing packages

    From: stackoverflow Close the IDE, then delete the <whatnot> folder from $(BDSCatalogRepository) After that, you have to edit the registry and delete also the <whatnot> folder from: HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\<ProductVersion>.0\CatalogRepository\Elements
  6. FredS

    (Mis-)Behaviour of TStringHelper

    I moved on in 2016, so what happens with this method is no longer for me only for those who spend hours searching for bugs they can't figure out. And I'm not looking for the 'First occurrence', that would be 'IndexOf', so either way the function fails. Returns the last index of the Value string in the current 0-based string. StartIndex specifies the offset in this 0-based string where the LastIndexOf method begins the search, and Count specifies the end offset where the search ends. There are six LastIndexOf overloaded methods, each one allowing you to specify various options in order to obtain the last index of the given string in this 0-based string. When the Value argument (Char or String), passed to LastIndexOf, is not found in the 0-based string, LastIndexOf function returns -1.
  7. FredS

    (Mis-)Behaviour of TStringHelper

    I didn't want to hijack this thread for something I moved on from years ago, so really quickly: Berlin Help: Returns the last index of the Value string in the current 0-based string. { TStringHelper.LastIndexOf returns wrong values } // 0 19 38 0-based s := 'Hello how are you, Hello how are you, Hello how are you'; Assert(s.IndexOf('Hello', 38) = s.LastIndexOf('Hello', 38)); As for the "Huh?" next to LastDelimiter, that was me not understanding how that worked.
  8. Essentially all system wide methods are run through DUnitX now. This is how I know that RSP-15040 is still in Rio 10.3.1, I use that when anyone asks why I built my own string helper. Depending on complexity I use TestInsight while coding.
  9. FredS

    Error insight in Rio

    You can answer your own question by looking at the age of some of those reports in QP..
  10. FredS

    How to replace whole words in a string

    Then you need to figure out what that logic is, it's not word boundaries: https://regex101.com/r/bnXElq/1
  11. FredS

    How to replace whole words in a string

    The code below will return: 'yes, yes.def' v := TRegEx.Replace('abc, abc.def', '\babc\b', 'yes', [TRegExOption.roIgnoreCase]); \babc\b Options: Case insensitive; Exact spacing; Dot doesn’t match line breaks; ^$ match at line breaks; Numbered capture; Skip zero-length matches Assert position at a word boundary (position preceded or followed—but not both—by an ASCII letter, digit, or underscore) «\b» Match the character string “abc” literally (case insensitive) «abc» Assert position at a word boundary (position preceded or followed—but not both—by an ASCII letter, digit, or underscore) «\b» Created with RegexBuddy
  12. FredS

    10.3.1 has been released

    Wasn't there in 10.3, so new to me with 10.3.1.
  13. FredS

    10.3.1 has been released

    Yup.
  14. FredS

    10.3.1 has been released

    First impressions count.
  15. This was about Record class destructors.
  16. Oh boy.. It can't in MMX up to14.0.5 🙂
  17. Why?  To use the Class Destructor for cleanup.
  18. For this I would simply use a Class Helper to separate the UI logic.
  19. Fine for Global vars as long as you don't need to finalize. At that point just change to a class. Pretty sure you don't actually want Global Instance data.. more like a snack without the preparation and cleanup 🙂 //MMWIN:CLASSCOPY unit _MM_Copy_Buffer_; interface type TGlobal = record class var Id : Integer; RecName : string; Values : TArray<TValue>; class constructor Create; private class function GetNewProperty: Integer; static; class procedure SetNewProperty(const Value: Integer); static; public class property NewProperty: Integer read GetNewProperty write SetNewProperty; end; implementation class constructor TGlobal.Create; begin inherited; // TODO -cMM: TGlobal.Create default body inserted end; class function TGlobal.GetNewProperty: Integer; begin // TODO -cMM: TGlobal.GetNewProperty default body inserted Result := ; end; class procedure TGlobal.SetNewProperty(const Value: Integer); begin // TODO -cMM: TGlobal.SetNewProperty default body inserted end; end.
  20. FredS

    Delphi Rio and tRegEx.Replace Problem

    Certainly not executable code, you're using that function as input but never supply a TMatch parameter..
  21. FredS

    FileExists(xxxxx) in a network?

    Try: LTips := ChangeFileExt(Application.ExeName, '.Tips');
  22. FredS

    FileExists(xxxxx) in a network?

    The format is \\<server>\<share>\<path> Admin shares can be accessed with <drive letter>$. After taking a closer look at what you are doing, why would 'c:' be a valid path inside a share?
  23. FredS

    FileExists(xxxxx) in a network?

    OK, sAppName := '\\192.168.1.35\F-TestServer\C:\TestArea\Testfile.Tips'; should be sAppName := '\\192.168.1.35\F-TestServer\C$\TestArea\Testfile.Tips';
  24. FredS

    FileExists(xxxxx) in a network?

    Some very old versions of Delphi had this issue, simple fix was to use: function MyFileExits(FileName: string): boolean; var SearchRec: TSearchRec; begin if (FindFirst(FileName, faAnyFile, SearchRec) = 0) then begin SysUtils.FindClose(SearchRec); Result := True; end else Result := False; end;
  25. FredS

    Changes in Parallel Library

    Modified your code to get a better look at the difference. Both Executed in Berlin 10.1.2 Ideally #1 should reach a higher WorkerThreadCount during its two minutes of execution but still the same with Rio. #3 may be an issue (also in Rio), imagine running a pile of low intensity tasks first then executing something that loads Data Modules, Databases and whatnot.. starting at the same count you left off could cause out of memory issues unless dealt with (not tested). #4 IMO is handled better in Berlin, the AverageCPUUsage delegates the Pool to drop below MinLimitWorkerThreadCount. ** RIO System.Threading unit, modified to compile in Berlin #1 Slow increase, never reached full ActiveTask Count 00:02:13.8790372 AverageCPUUsage: 35 WorkerThreadCount: 34 MinLimitWorkerThreadCount: 4 #2 Increased to 58 immediately, holds appropriate AverageCPUUsage 00:01:11.9777749 AverageCPUUsage: 90 WorkerThreadCount: 58 MinLimitWorkerThreadCount: 50 #3 Starts off with #2 WorkerThreadCount and holds appropriate AverageCPUUsage 00:01:11.8997475 AverageCPUUsage: 89 WorkerThreadCount: 58 MinLimitWorkerThreadCount: 4 #4 Does NOT hold appropriate AverageCPUUsage 00:01:35.0015869 AverageCPUUsage: 100 WorkerThreadCount: 99 MinLimitWorkerThreadCount: 99 ** Berlin System.Threading unit, modified with RSP fixes only #1 Slow increase, never reached full ActiveTask Count 00:02:13.9110588 AverageCPUUsage: 34 WorkerThreadCount: 34 MinLimitWorkerThreadCount: 4 #2 Increased to 58 immediately, holds appropriate AverageCPUUsage 00:01:11.4247095 AverageCPUUsage: 89 WorkerThreadCount: 59 MinLimitWorkerThreadCount: 50 #3 Starts off with #2 WorkerThreadCount and holds appropriate AverageCPUUsage 00:01:11.6894449 AverageCPUUsage: 88 WorkerThreadCount: 59 MinLimitWorkerThreadCount: 4 #4 Drops appropriately below MinLimitWorkerThreadCount to keep AverageCPUUsage 00:01:21.0234632 AverageCPUUsage: 88 WorkerThreadCount: 78 MinLimitWorkerThreadCount: 99 program Project2; {$APPTYPE CONSOLE} uses WinApi.Windows, System.SysUtils, System.Diagnostics, System.Threading, System.Classes, System.TimeSpan; var SW : TStopWatch; ActiveTasksTicks : Int64; const SleepMs = 100; SleepCycles = 333; HighPrime = 100 * 1000; function IsPrime(const Value: Integer): Boolean; {$REGION 'History'} // 18-Jul-2018 - From a Parallel Task example {$ENDREGION} var Test, k: Integer; begin if Value <= 3 then IsPrime := Value > 1 else if ((Value mod 2) = 0) or ((Value mod 3) = 0) then IsPrime := False else begin IsPrime := True; k := Trunc(Sqrt(Value)); Test := 5; while Test <= k do begin if ((Value mod Test) = 0) or ((Value mod (Test + 2)) = 0) then begin IsPrime := False; break; { jump out of the for loop } end; Test := Test + 6; end; end; end; procedure TestParallel; var TaskArray: array [1..100] of ITask; Ticks : Int64; i : integer; begin for I := Low(TaskArray) to High(TaskArray) do TaskArray[I] := TTask.Create(procedure var s, p: integer; Succeeded : Boolean; {* GetActiveTasks *} function GetActiveTasks: integer; var i : integer; begin Result := 0; for i := Low(TaskArray) to High(TaskArray) do if (TaskArray[i].Status = System.Threading.TTaskStatus.Running) then begin Inc(Result); end; end; begin for s := 1 to SleepCycles do begin Ticks := ActiveTasksTicks; if (Ticks + TTimeSpan.TicksPerSecond) < SW.ElapsedTicks then begin System.AtomicCmpExchange(ActiveTasksTicks, SW.ElapsedTicks, Ticks, Succeeded); if Succeeded then begin Write(#13 + Format('ActiveTasks: %3.d, CPU: %3.d%%', [GetActiveTasks, TThreadPoolStats.Current.CurrentCPUUsage])); end; end; Sleep(SleepMs); for p := 1 to HighPrime do isPrime(p); end end).Start; TTask.WaitForAll(TaskArray); end; procedure TestTasks(AMinWorkerThreads : integer); var TPS : TThreadPoolStats; begin ActiveTasksTicks := 0; SW := TStopWatch.StartNew; TThreadPool.Default.SetMinWorkerThreads(AMinWorkerThreads); TestParallel; Write(#13 + StringOfChar(' ', 72)); WriteLn(#13 + SW.Elapsed.ToString); TPS := TThreadPoolStats.Default; WriteLn('AverageCPUUsage: ', TPS.AverageCPUUsage); WriteLn('WorkerThreadCount: ', TPS.WorkerThreadCount); WriteLn('MinLimitWorkerThreadCount: ', TPS.MinLimitWorkerThreadCount); WriteLn; end; begin TestTasks(TThread.ProcessorCount); TestTasks(50); TestTasks(TThread.ProcessorCount); TestTasks(99); ReadLn; end.
×