Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Bo Berglund via fpc-pascal
On Wed, 05 Apr 2023 00:33:50 +0200, Bo Berglund via fpc-pascal wrote: >On Tue, 4 Apr 2023 23:43:21 +0200, Christo Crause via fpc-pascal > wrote: > > >>Is your startaddress variable an unsigned 16 bit integer >>(word/uint16)? If not, type cast this to a uint16 to ensure the compiler >>calls the

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Bo Berglund via fpc-pascal
On Tue, 4 Apr 2023 23:43:21 +0200, Christo Crause via fpc-pascal wrote: >> if not i2cMaster.WriteBytesToReg(FEEPROMAddr, startaddress, @source[0], >> NumBytes) then >> >> Here the source argument is a TBytes array of bytes so I supply the >> address of >> element 0 as the data argument

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Sven Barth via fpc-pascal
Travis Siegel via fpc-pascal schrieb am Di., 4. Apr. 2023, 20:34: > I'm not positive, because I've never used them, but I'm pretty sure > variables configured as const, can't be changed once they're defined. For typed constants that depends on the $WritableConsts directive. Regards, Sven

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Christo Crause via fpc-pascal
See comments below. On Tue, Apr 4, 2023 at 6:52 PM Bo Berglund via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > I use the method: > > i2cMaster.WriteBytesToReg(i2caddress: byte; regAddress: uint16; data: > PByte; > size: byte): boolean;) > > With data specified as follows in the call:

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Jonas Maebe via fpc-pascal
On 04/04/2023 16:14, Bart via fpc-pascal wrote: If your local "writeable constant" is of type string, and strings are longstrings, and the writeable const is assigned a value that is the result of a string concatenation, then you'll have a memory leak. That does not matter in practice (*),

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Thomas Kurz via fpc-pascal
Didn't know that either: "It should be stressed that typed constants are automatically initialized at program start. This is also true for local typed constants and initialized variables. Local typed constants are also initialized at program start. If their value was changed during previous

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Jeffrey A. Wormsley via fpc-pascal
> > Page Write ... > What this means is that if you start in the middle of a 64 byte block, let's say at byte 60 (0 based) which is on page 0, and you write 4 bytes, then you will write into 60, 61, 62 and 63 as expected. But if you write 6 bytes, you will write into bytes 60, 61, 62, 63 and

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Travis Siegel via fpc-pascal
I'm not positive, because I've never used them, but I'm pretty sure variables configured as const, can't be changed once they're defined.  If that's your intent, then feel free to use them, but it sounds like you're trying to make variables (not constant values) last for the whole program,

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Bo Berglund via fpc-pascal
On Sun, 02 Apr 2023 23:21:38 +0200, Bo Berglund via fpc-pascal wrote: >On Sun, 2 Apr 2023 23:14:25 +0200, Christo Crause via fpc-pascal > wrote: > >>On Sun, Apr 2, 2023 at 9:30?PM Bo Berglund via fpc-pascal < >>fpc-pascal@lists.freepascal.org> wrote: >> >>> Is there a reason that there is no

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Bart via fpc-pascal
On Tue, Apr 4, 2023 at 6:00 PM Tomas Hajny via fpc-pascal wrote: > Well, managed types are not very likely in code imported from a Pascal > compiler not knowing units... Well, his fpc.cfg might define string to be ansistring... -- Bart ___

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Tomas Hajny via fpc-pascal
On 2023-04-04 16:14, Bart via fpc-pascal wrote: On Tue, Apr 4, 2023 at 9:43 AM Jacob Kroon via fpc-pascal wrote: What is the technical downside to using "const", or is it just cosmetic ? If your local "writeable constant" is of type string, and strings are longstrings, and the writeable

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Bart via fpc-pascal
On Tue, Apr 4, 2023 at 9:43 AM Jacob Kroon via fpc-pascal wrote: > What is the technical downside to using "const", or is it just cosmetic ? If your local "writeable constant" is of type string, and strings are longstrings, and the writeable const is assigned a value that is the result of a

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Tomas Hajny via fpc-pascal
On 2023-04-04 11:14, Sven Barth wrote: Tomas Hajny via fpc-pascal schrieb am Di., 4. Apr. 2023, 09:51: . . If you read the documentation (wiki or the real documentation in PDF/HTML etc.) properly, you don't find there anything saying that constants declared locally within functions or

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Sven Barth via fpc-pascal
Tomas Hajny via fpc-pascal schrieb am Di., 4. Apr. 2023, 09:51: > On 2023-04-04 09:43, Jacob Kroon wrote: > > > Hi Jacob, > > >> You don't need to change "var" to "const" - if you want to ensure the > >> variables to persist in between the function/procedure runs, you need > >> to move them to

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Jacob Kroon via fpc-pascal
Hi Tomas, On 4/4/23 09:51, Tomas Hajny wrote: On 2023-04-04 09:43, Jacob Kroon wrote: Hi Jacob, You don't need to change "var" to "const" - if you want to ensure the variables to persist in between the function/procedure runs, you need to move them to the global level, i.e. outside of the

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Tomas Hajny via fpc-pascal
On 2023-04-04 09:43, Jacob Kroon wrote: Hi Jacob, You don't need to change "var" to "const" - if you want to ensure the variables to persist in between the function/procedure runs, you need to move them to the global level, i.e. outside of the functions/procedures. It is not advisable as a

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Jacob Kroon via fpc-pascal
Hi Michael, On 4/4/23 09:05, Michael Van Canneyt wrote: [cut] Do I have any other option besides changing from "var" to "const" everywhere, and provide initial values in all declarations ? Make them actually global variables. procedure X; Var  y : integer; begin // Use y end; becomes

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Jacob Kroon via fpc-pascal
Hi Tomas, On 4/4/23 09:01, Tomas Hajny via fpc-pascal wrote: [cut] You don't need to change "var" to "const" - if you want to ensure the variables to persist in between the function/procedure runs, you need to move them to the global level, i.e. outside of the functions/procedures. It is

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Jacob Kroon via fpc-pascal
Hi Bernd, On 4/4/23 08:54, Bernd Oppolzer via fpc-pascal wrote: Am 04.04.2023 um 08:16 schrieb Jacob Kroon via fpc-pascal: Thanks for the tip above. I was able to write a couple of perl-scripts that are able to convert my old Pascal sources to something that fpc can parse. Amongst other

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Michael Van Canneyt via fpc-pascal
On Tue, 4 Apr 2023, Jacob Kroon via fpc-pascal wrote: Hi Charlie, everyone, On 3/28/23 11:33, Karoly Balogh wrote: [cut] If you want to export a variable without name mangling, you must declare a public name for it, something like: var foobar: integer; public name '_myfoobar'; Then

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Bernd Oppolzer via fpc-pascal
Am 04.04.2023 um 08:16 schrieb Jacob Kroon via fpc-pascal: Thanks for the tip above. I was able to write a couple of perl-scripts that are able to convert my old Pascal sources to something that fpc can parse. Amongst other things, the scripts inject the "public name"/"external name"

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Tomas Hajny via fpc-pascal
On 2023-04-04 08:16, Jacob Kroon via fpc-pascal wrote: Hi Jacob, . . But I suspect I have a new problem: With the old Pascal/MT+ compiler it would appear that local variables declared in functions/procedures have a life-time that spans the whole program, like a "static" declared variable in

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Jacob Kroon via fpc-pascal
Hi Charlie, everyone, On 3/28/23 11:33, Karoly Balogh wrote: [cut] If you want to export a variable without name mangling, you must declare a public name for it, something like: var foobar: integer; public name '_myfoobar'; Then reference it as: var foobar: integer; external name