[fpc-pascal] specify variable name with string variable

James Richters james at productionautomation.net
Sun Jul 7 21:58:18 CEST 2019


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?

James


More information about the fpc-pascal mailing list