Is there a function to get the value of a variable by its name ?
for example:
define variable iX as int init 100.
define variable cName as char init "iX".
display varOfName(cName).
I do not think you can do that with a variable but you can with a property.
DYNAMIC-PROPERTY (THIS-OBJECT, cName)
I do not think you can do that with a variable but you can with a property.
DYNAMIC-PROPERTY (THIS-OBJECT, cName)
That is correct.
I think Scott’s EQN were able to do ‘evals’ like that… http://www.oehive.org/node/1006
EQN could do something like this indeed, but you had to 'feed' it with the variables and their values first. It was all processed dynamically and although it has its purposes, I would only recommend this for special scenario's. We have used it to process generic properties that could be defined by the end-users.
What Dominik asks is not possible with normal variables, but you can get close by defining a temp-table. You create one record in this table and use the fields as variables.
DEFINE VARIABLE cVariable AS CHARACTER NO-UNDO. DEFINE TEMP-TABLE tt NO-UNDO RCODE-INFORMATION FIELD iCounter AS INTEGER FIELD cMyString AS CHARACTER. CREATE tt. ASSIGN tt.iCounter = 3 tt.cMyString = 'Hello world'. cVariable = 'iCounter'. MESSAGE BUFFER tt:BUFFER-FIELD(cVariable):BUFFER-VALUE BUFFER tt:BUFFER-FIELD('cMyString'):BUFFER-VALUE VIEW-AS ALERT-BOX INFO BUTTONS OK.
Thx for the answers, i have solved it with switch case,i dont really like it but looks like it's the easiest way.