Re: [fpc-pascal] Function to create a record ?

2023-06-05 Thread Steve Litt via fpc-pascal
Jean SUZINEAU via fpc-pascal said on Mon, 5 Jun 2023 11:56:59 +0200 >Hello, I have a hard time trying to understand what you want to test. > >In your functions, you are using a record, not a class or a pointer to >record or an object. > >The personrecord just behave in your parameters and return

Re: [fpc-pascal] Function to create a record ?

2023-06-05 Thread Jean SUZINEAU via fpc-pascal
Oops, I hit "Send message" too quickly. The only difference in the second code is: - personrecord renamed to personclass and declared as "personclass = class" - "newp:= personclass.Create;" added in function newperson Of course for a clean code, you'll need to call something like

Re: [fpc-pascal] Function to create a record ?

2023-06-05 Thread Jean SUZINEAU via fpc-pascal
Hello, I have a hard time trying to understand what you want to test. In your functions, you are using a record, not a class or a pointer to record or an object. The personrecord just behave in your parameters and return value as an Integer or a String, and your fillchar doesn't write

Re: [fpc-pascal] Function to create a record ?

2023-06-04 Thread Steve Litt via fpc-pascal
Travis Siegel via fpc-pascal said on Sun, 4 Jun 2023 19:38:44 + > >On 6/4/2023 1:37 PM, Steve Litt via fpc-pascal wrote: >> Henry Vermaak via fpc-pascal said on Fri, 2 Jun 2023 09:38:17 +0100 >> >>> On Fri, 2 Jun 2023 at 01:36, Steve Litt via fpc-pascal >>> wrote:

Re: [fpc-pascal] Function to create a record ?

2023-06-04 Thread Travis Siegel via fpc-pascal
Depending on the compiler *not* to overwrite local variables is most certainly the wrong way to go with this.  You really should create either a global record/object, or use functions to pass around the information you need.  Expecting the operating system to keep local variables after the

Re: [fpc-pascal] Function to create a record ?

2023-06-04 Thread Steve Litt via fpc-pascal
Ralf Quint via fpc-pascal said on Thu, 1 Jun 2023 17:43:58 -0700 >On 6/1/2023 5:36 PM, Steve Litt via fpc-pascal wrote: >> >> What is the best way for me to construct newperson() so that every >> time called it would return a new variable? >W.T.F.? > >Sorry, but for how long are you

Re: [fpc-pascal] Function to create a record ?

2023-06-04 Thread Steve Litt via fpc-pascal
Henry Vermaak via fpc-pascal said on Fri, 2 Jun 2023 09:38:17 +0100 >On Fri, 2 Jun 2023 at 01:36, Steve Litt via fpc-pascal > wrote: >> fillchar(junkvar, junkvar_size, 'b'); >> person := modperson(person, 'Martin'); >> person := modperson(person2, 'Maria'); > >Maybe a

Re: [fpc-pascal] Function to create a record ?

2023-06-02 Thread Henry Vermaak via fpc-pascal
On Fri, 2 Jun 2023 at 01:36, Steve Litt via fpc-pascal wrote: > fillchar(junkvar, junkvar_size, 'b'); > person := modperson(person, 'Martin'); > person := modperson(person2, 'Maria'); Maybe a typo? (E.g. person2 := modperson(person2, 'Maria')) Henry

Re: [fpc-pascal] Function to create a record ?

2023-06-01 Thread Ralf Quint via fpc-pascal
On 6/1/2023 5:36 PM, Steve Litt via fpc-pascal wrote: Hi all, I'm trying to create a function (called newperson()) that creates a new instance of a record. The following compiles with no errors or warnings in FPC, but multiple calls to newperson() produce exactly the same variable, so in the

[fpc-pascal] Function to create a record ?

2023-06-01 Thread Steve Litt via fpc-pascal
Hi all, I'm trying to create a function (called newperson()) that creates a new instance of a record. The following compiles with no errors or warnings in FPC, but multiple calls to newperson() produce exactly the same variable, so in the preceding changing person changes person2, and vice versa: