

FredS
Members-
Content Count
429 -
Joined
-
Last visited
-
Days Won
4
Everything posted by FredS
-
How to operate a private field in other unit?
FredS replied to pcplayer99's topic in RTL and Delphi Object Pascal
Yes, and ignore all those other flaws never fixed in the compiler to fixate on WITH which at times is the ONLY way to bypass EMBT bugs without updating to an arguably less stable version of Delphi. -
How to operate a private field in other unit?
FredS replied to pcplayer99's topic in RTL and Delphi Object Pascal
You have to use the Helper, only it and the use of WITH get you access, see my test code above. Plus that's not enough code for anyone to help you.. // Your helper should have a method like SetPrivateVar which uses 'With Self do' SomeClass.SetPrivateVar(TMyClassA2.Create()); -
How to operate a private field in other unit?
FredS replied to pcplayer99's topic in RTL and Delphi Object Pascal
Works here, must be Magic 🙂 -
How to operate a private field in other unit?
FredS replied to pcplayer99's topic in RTL and Delphi Object Pascal
I have this test setup to let me know if this is ever changed in a new version of Delphi. Should be simple enough to replace TCustomTextFile with whatnot and run the test which I just ran in 10.4.1 and it passed: //MMWIN:CLASSCOPY unit _MM_Copy_Buffer_; interface implementation type TTestAccessToPrivateFieldHelper = class helper for TCustomTextFile function SetPrivateOwnsStream(AValue: boolean): boolean; end; { TTestAccessToPrivateFieldHelper } function TTestAccessToPrivateFieldHelper.SetPrivateOwnsStream(AValue: boolean): boolean; begin with Self do begin FOwnsStream := AValue; Result := FOwnsStream; end; end; end. //MMWIN:MEMBERSCOPY unit _MM_Copy_Buffer_; interface type THelperTests = class(TObject) public [Test(True)] procedure TestAccessToPrivateField; end; implementation procedure THelperTests.TestAccessToPrivateField; var F : TTextFile; begin F := TTextFile.Create('testing.txt', TEncoding.UTF8); try Assert.IsFalse(F.SetPrivateOwnsStream(False)); Assert.IsTrue(F.SetPrivateOwnsStream(True)); finally F.Free; end; end; end. -
How to operate a private field in other unit?
FredS replied to pcplayer99's topic in RTL and Delphi Object Pascal
How to call a private method of a class inside a Berlin+ class via Helper procedure TSomeClassHelper.CheckAccessToPrivate; begin With Self do begin // access via with works FInt :=1; SomeMethod; end; end; // Declared in another unit as: type TSomeClass = class private FInt : integer; procedure SomeMethod; end; -
See if this fits: Attribute-based Command Line Parsing
-
Never worked for me. A Reg backup and Beyond Compare work with a little effort..
-
Anyone able to switch 'Configuration' and have that update in the 'Project Manager' , without using the 'Config Manager'? My 10.4.1 is still Sandboxed on Win7.. Also 'Build Groups' are using the wrong config, strangely changing that (Options) doesn't update the 'Project Manager' display but Barbie band-aids that issue..
-
- Quick installed Ubuntu 20.04 - ran: `sudo apt-get install openssh-server` - connected via WSL from Host: fred@PUTER:~$ sudo ssh fred@172.17.134.53 fred@172.17.134.53's password: Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-26-generic x86_64)
-
To be clear, I use 'Bash on Ubuntu for Windows' and can access from the Host machine to my Hyper-Vm using that IP.
-
If your Host machine has a single NIC then you may need to get the IP from the Hyper-V virtual Ethernet adapter to reach your machine. If that is the case the bottom panel has three tabs, the networking tab will have the VMs IP after it has been started.
-
Generic circular buffer library released
FredS replied to TurboMagic's topic in Algorithms, Data Structures and Class Design
Believe I did that years ago.. not sure if via email or Google.. -
Generic circular buffer library released
FredS replied to TurboMagic's topic in Algorithms, Data Structures and Class Design
Think I tried that before and moving existing documentation failed. Just tried again and same.. It does appear to work when I add new documentation, however there are these caveats: -
See contents of variables at a breakpoint in 10.4
FredS replied to Jud's topic in Delphi IDE and APIs
This breaks at times, has for different releases depending on code and debugging for a long time. -
Boolean short-circuit with function calls
FredS replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Priceless 🙂 -
Boolean short-circuit with function calls
FredS replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Nothing, but in the past too many directives where bad for the health of Error/Code insight.. sure that's much improved now 🙂 -
Boolean short-circuit with function calls
FredS replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
function CompleteEval(const Values: array of Boolean): Boolean; -
What's the shortcut for 'double click to maximize the editor area'
FredS replied to Edwin Yip's topic in Delphi IDE and APIs
It won't work without DDevExtensions in a plain IDE, new feature I guess 🙂 -
What's the shortcut for 'double click to maximize the editor area'
FredS replied to Edwin Yip's topic in Delphi IDE and APIs
I know DDevExtensions has it with a double-click by adding a hidden registry key.. -
While Not _thread.Finished Do Application.ProcessMessages;
FredS replied to aehimself's topic in VCL
Start with this, I pulled that out of more complex code but haven't tested it: //MMWIN:MEMBERSCOPY unit _MM_Copy_Buffer_; interface type TThreadHelper = class helper for TThread public /// <summary> /// Will handle all Wait Key, Mouse and Message Inputs, also calls Synchronize as needed. /// </summary> function StartAsync: TWaitResult; end; implementation function TThreadHelper.StartAsync: TWaitResult; var LHandles: TArray<THandle>; Rsl : Cardinal; const cObjects = 2; begin Assert(TThread.CurrentThread.ThreadID = MainThreadID, 'Must be called from Main Thread'); Self.FreeOnTerminate := False; SetLength(LHandles, cObjects); LHandles[0] := Self.Handle; LHandles[1] := SyncEvent; self.Start(); try repeat Rsl := MsgWaitForMultipleObjects(cObjects, LHandles[0], False, INFINITE, QS_ALLINPUT); case Rsl of WAIT_FAILED: Exit(TWaitResult.wrError); WAIT_TIMEOUT: Exit(TWaitResult.wrTimeOut); WAIT_ABANDONED_0 .. WAIT_ABANDONED_0 + cObjects: Exit(TWaitResult.wrAbandoned); WAIT_OBJECT_0 : Result := TWaitResult.wrSignaled; WAIT_OBJECT_0 + 1: CheckSynchronize(0); WAIT_OBJECT_0 + cObjects: Application.ProcessMessages; end; until (Rsl = 0); finally self.Free; end; end; end. -
While Not _thread.Finished Do Application.ProcessMessages;
FredS replied to aehimself's topic in VCL
Either write a method which uses MsgWaitForMultipleObjects and also calls synchronize `WaitAsync` or something like that, or just use a short timeout for `TTask.Wait` and call `Application.ProcessMessages` while not terminated.. -
@Mahdi Safsafi Might be simpler to just redirect System.GetMemory instead of the memory manager's GetMem which is called by other methods doing a reOutOfMemory check themselves.
-
Unfortunately this means that in the next delivery no one will tell me if my shirt, a critical part of the outfit, has changed functionality 🙂
-
That should be doable by August 1st.. /s
-
I believe that falls under the 'new feature' category 🙂 Can connect, but have a valid cookie. I've had issues before with the login server they use/share..