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] 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] 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] 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

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

2023-03-28 Thread Ralf Quint via fpc-pascal
On 3/28/2023 3:12 AM, Marco van de Voort via fpc-pascal wrote: On 28-3-2023 11:33, Karoly Balogh via fpc-pascal wrote: Probably yes, but there might be an alternative, see below. But as far as I understand, Unit is a Turbo Pascal concept, so any Pascal programming dialect that predates it,

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

2023-03-28 Thread Ralf Quint via fpc-pascal
On 3/27/2023 2:45 AM, Jacob Kroon via fpc-pascal wrote: Hi, I have some old Pascal code that was compiled in a CPM environment using the Pascal/MT+ compiler from Digital Research. I'm trying to get this project to build in a modern environment, for a start using FreePascal. First, is

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

2023-03-28 Thread Marco van de Voort via fpc-pascal
On 28-3-2023 11:33, Karoly Balogh via fpc-pascal wrote: Probably yes, but there might be an alternative, see below. But as far as I understand, Unit is a Turbo Pascal concept, so any Pascal programming dialect that predates it, probably don't understand it. True, and before units in Turbo

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

2023-03-28 Thread Tomas Hajny via fpc-pascal
On 2023-03-28 11:33, Karoly Balogh via fpc-pascal wrote: Hi, . . You might wanna consider this approach, because if units somehow end up cross-referencing each other, then you might run into difficulties restructuring the code to use Units. Also, it is possible to cross-reference units from

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

2023-03-28 Thread Karoly Balogh via fpc-pascal
Hi, On Mon, 27 Mar 2023, Jacob Kroon via fpc-pascal wrote: > As I understand it, in order to translate this to something that FreePascal > understands, the variable needs to go in a "unit" and be part of its > interface. Then, pascal sources that needs to reference the variable should > use this

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

2023-03-28 Thread Tomas Hajny via fpc-pascal
On 2023-03-27 11:45, Jacob Kroon via fpc-pascal wrote: Hi, I have some old Pascal code that was compiled in a CPM environment using the Pascal/MT+ compiler from Digital Research. I'm trying to get this project to build in a modern environment, for a start using FreePascal. First, is anyone