[fpc-pascal] specify variable name with string variable

James Richters james at productionautomation.net
Mon Jul 8 01:25:19 CEST 2019


Is there an example of how declare them this way?  I only have about 50 variables I wish to do this with.

-----Original Message-----
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Michael Van Canneyt
Sent: Sunday, July 7, 2019 6:20 PM
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] specify variable name with string variable



On Sun, 7 Jul 2019, James Richters wrote:

> This might sound silly,  but is it possible to somehow specify a variable with a string containing the name of the variable?
>
> For example:
>
> Var
>   MyVariable1 : Word;
>   MyVariableName : String;
>
> Procedure ShowVariable(Variablename);
> Begin
> Writeln(Variablename,' = $', inttohex(    (Somehow get the value of the variable specified by the name here ) ,4));
> End;
>
> Begin
> MyVariableName:= 'MyVariable1';
> ShowVariable(MyVariableName);
> End.
>
> Is such a thing possible?

No. 
If you want that you need to declare them as published properties of a class.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


More information about the fpc-pascal mailing list