<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">El 07/07/2019 a las 21:58, James
      Richters escribió:<br>
    </div>
    <blockquote type="cite"
      cite="mid:52fe01d534fe$52891230$f79b3690$@productionautomation.net">
      <pre class="moz-quote-pre" wrap="">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?</pre>
    </blockquote>
    <br>
    What is it for?<br>
    <br>
    What about:<br>
    <pre>procedure ShowVariable(const Variablename:string; const value:word);
begin
 Writeln(Variablename,' = $'+inttohex(value ,4));
end;

ShowVariable('myVar',myVar);</pre>
    <br>
    And as far as I understand, you want to call
    ShowVariable('myVar',myVar), but not wasting time writing the name
    enclosed in quotes, let the program get the identifier name in
    runtime, or the other way around, let the program get the value from
    a name passed in runtime.<br>
    <br>
    Bad luck, Pascal is not a script language, it is not aware of
    identifier names in runtime there is no "eval". Thanks to that it
    gets rids of all the burden of having to keep in runtime structures
    to know the name, type and value of variable. It generate fast
    native programs.<br>
    <br>
    Nevertheless, there are ways, you can program that in Freepascal 
    using classes, properties, RTII etc. It is more flexible and
    powerful. But obviously it has a price in complexity. Instead or
    using the standard operators and reference a simple variable, you
    must use a more convoluted syntax.<br>
    <br>
    As far as I see, you don't intend to let the program create new vars
    in runtime, you just want to write the identifiers of the vars you
    have hardcoded.  Is it worth? <br>
    <br>
    (I hope it is not just for debugging)<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Saludos

Santiago A.
</pre>
  </body>
</html>