[fpc-pascal] How to contribute a Unit

2024-02-03 Thread Amir--- via fpc-pascal
Hi,   In www.freepascal.org, I see there is a "Contributed Units" tab. What are the criteria for a unit to be qualified to be placed there. How can one build a community account? Best, Amir P.S. Here is the unit I want to

Re: [fpc-pascal] Read Field names from VMT

2024-02-01 Thread Amir--- via fpc-pascal
I see... The trick was to define TMyClass! Thanks! On 2/1/24 02:19, Michael Van Canneyt via fpc-pascal wrote: On Wed, 31 Jan 2024, Amir--- via fpc-pascal wrote: Without more info (declaration of ChildTClass, declaration of the constructor of that class etc), it is not possible

Re: [fpc-pascal] Read Field names from VMT

2024-01-31 Thread Amir--- via fpc-pascal
Without more info (declaration of ChildTClass, declaration of the constructor of that class etc), it is not possible to comment. We need a complete compilable code sample to provide you with more insight. Please have a look at the attachment. Best, Amir FieldAddress.lpr.gz Description:

Re: [fpc-pascal] Read Field names from VMT

2024-01-29 Thread Amir--- via fpc-pascal
; Looks like "ChildTClass.ClassName" is correct but the constructor of the appropriate class is not being called. On 1/22/24 23:05, Michael Van Canneyt via fpc-pascal wrote: On Mon, 22 Jan 2024, Amir--- via fpc-pascal wrote:   Params := TParams.Create;   WriteLn(Params.Int2.IntVal);

Re: [fpc-pascal] Read Field names from VMT

2024-01-22 Thread Amir--- via fpc-pascal
On 1/22/24 23:05, Michael Van Canneyt via fpc-pascal wrote: On Mon, 22 Jan 2024, Amir--- via fpc-pascal wrote:   Params := TParams.Create;   WriteLn(Params.Int2.IntVal);   WriteLn(TInteger(Params.FieldAddress('Int2')).IntVal); The third line does not work (the zipped code is attached

Re: [fpc-pascal] Read Field names from VMT

2024-01-22 Thread Amir--- via fpc-pascal
  Params := TParams.Create;   WriteLn(Params.Int2.IntVal);   WriteLn(TInteger(Params.FieldAddress('Int2')).IntVal); The third line does not work (the zipped code is attached). On 1/21/24 23:43, Michael Van Canneyt via fpc-pascal wrote: On Sun, 21 Jan 2024, Amir--- via fpc-pascal wrote: How

Re: [fpc-pascal] Read Field names from VMT

2024-01-21 Thread Amir--- via fpc-pascal
How can I set the value? I tried something like Test := TTest.Create Ptr := Pointer(Test); TSub(Ptr+8) := TSub.Create; But it is not working? You can use the PVmtFieldTable and PVmtFieldEntry types from the TypInfo unit: === code begin === program tfield; {$mode objfpc}{$H+} uses  

Re: [fpc-pascal] How to avoid Copy

2024-01-02 Thread Amir--- via fpc-pascal
Thanks! On 1/2/24 22:59, Sven Barth via fpc-pascal wrote: Amir--- via fpc-pascal schrieb am Mi., 3. Jan. 2024, 07:53: Yeap! That is actually what I posted here (Feature Request) <https://gitlab.com/freepascal.org/fpc/source/-/issues/40578>. My example allows you to access it

Re: [fpc-pascal] How to avoid Copy

2024-01-02 Thread Amir--- via fpc-pascal
Yeap! That is actually what I posted here (Feature Request) .  You simply need to inherit from the list class so that you can make the function public. And with a little trick you can also use it inside a for-in-loop: === code

Re: [fpc-pascal] How to avoid Copy

2023-12-31 Thread Amir--- via fpc-pascal
On 12/31/23 02:46, Marco van de Voort via fpc-pascal wrote: Op 31/12/2023 om 04:11 schreef Amir--- via fpc-pascal: I compiled the code with `fpc -O3 -Sd -gv -g -gl ` and ran `valgrind` on it (the output is attached). It does not look like there is a big difference between the Check1

Re: [fpc-pascal] How to avoid Copy

2023-12-29 Thread Amir via fpc-pascal
On Dec 29, 2023 9:50 PM, Adriaan van Os wrote:Amir--- via fpc-pascal wrote: > Hi all, > >  I have a List of record, where the record has a WideString field. >   I have some code like the following: > > function check(constref v: TMyRecord; data: TListOfMyRecord): Boolean; > var >   r:

[fpc-pascal] How to avoid Copy

2023-12-29 Thread Amir--- via fpc-pascal
Hi all,  I have a List of record, where the record has a WideString field.   I have some code like the following: function check(constref v: TMyRecord; data: TListOfMyRecord): Boolean; var   r: TMyRecord; begin   Result := False;   for r in data do     if r.State = v.State then  

Re: [fpc-pascal] Read Field names from VMT

2023-12-27 Thread Amir via fpc-pascal
Thank you!On Dec 27, 2023 7:46 AM, Sven Barth via fpc-pascal wrote: Am 26.12.2023 um 21:29 schrieb Amir--- via fpc-pascal: On 12/26/23 01:14, Sven Barth via fpc-pascal wrote

Re: [fpc-pascal] Read Field names from VMT

2023-12-26 Thread Amir--- via fpc-pascal
On 12/26/23 01:14, Sven Barth via fpc-pascal wrote: Amir--- via fpc-pascal schrieb am Di., 26. Dez. 2023, 07:03: Hi,    I want to retrieve the name of the fields in a record/class, at run time. It looks like "TVmt.vFieldTable" is what I need. But I cannot fi

[fpc-pascal] Read Field names from VMT

2023-12-25 Thread Amir--- via fpc-pascal
Hi,   I want to retrieve the name of the fields in a record/class, at run time. It looks like "TVmt.vFieldTable" is what I need. But I cannot find any documentation about how to explore the content of this table. I appreciate any pointer. Thank you, Amir

Re: [fpc-pascal] I'm working on automated Help Output for console apps

2020-11-20 Thread Amir via fpc-pascal
Hi,  I also have a similar library for that purpose: https://github.com/AmirAavani/my-units/blob/master/General-Purpose-Units/ParameterManagerUnit.pp This library expects "ValidArguments.inc" file whose content is like the following: ValidArgumentsInfo : array of AnsiString =