Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi,
I have several variables in which a user can provide a number from 0 till 50, the variables are: A1, B1, C1 .
In a chart this variable is used to perform a calculation.
In the data i also have a table which has values voor A1, B1, C1, i would like to use those values as the default value for my variables but i don't know how to..
I was thinkin' something like this but it doesn't work...
for
Each record in OPNAME_AFDELINGfor Each record in OPNAME_AFDELING
If(OPNMUTAFDELING='B1', LET B1 = OPNMUTAFDELINGBeddenaantal);
next record
help would be appriated!
thanx
david
Just define another variable and peek the value into it, then use its content to create the variable name:
FOR i = 0 to NoOfRows('resident table')-1
LET vFieldValue = peek ('otherfieldname, i, 'resident table');
LET vVariable$(vFieldValue) = peek('fieldname', i, 'resident table');
NEXT ;
Of course the value in vFieldValue cannot contain a space or other reserved character as this is not allowed in a variable name (you could strip out the spaces using PurgeChar or Replace string functions though)
Regards,
Gordon
Not sure I have understood but does this give you any ideas?
FOR i = 0 to NoOfRows('resident table')-1
LET vVariable$(i) = peek('fieldname', i, 'resident table');
NEXT ;
This will go through each row in a resident table and create a variable identified by the row number with the value of a field within that row.
Regards
Gordon
Hi Gordon,
thanx for your reply, i copied your script in my script:
FOR i = 0 to NoOfRows('OPNAME_AFDELING')-1
LET vVariable$(i) = peek('OPNMUTAFDELINGBeddenaantal)', i, 'OPNAME_AFDELING');
NEXT;
This made about 40 variables with a value from the table, it is allmost what i want, in my case the variables allready excist.
I would like to store the values in variables with names that are the same as another field in the table, is it possible to give the variable a name from another field from the table?
regards,
david
Hi David, hi Gordon,
what do you think about input fields ? You can use wildards for the declaring and load them with the defaults you want:
Inputfield Type;
Tbl:
Load * inline
[Val, Type
10, A
100, A
1000, A
20, B
50, C
500, C
220, D
100, D
];
RR
hi kurokarl,
in fact i have a tab where i have inputfields, the script above is to get the default values for the inputfields from a table..
does this help?
regards,
david
Just define another variable and peek the value into it, then use its content to create the variable name:
FOR i = 0 to NoOfRows('resident table')-1
LET vFieldValue = peek ('otherfieldname, i, 'resident table');
LET vVariable$(vFieldValue) = peek('fieldname', i, 'resident table');
NEXT ;
Of course the value in vFieldValue cannot contain a space or other reserved character as this is not allowed in a variable name (you could strip out the spaces using PurgeChar or Replace string functions though)
Regards,
Gordon
hi Gordon,
this works! thanx.
Is it also possible to exclude some rows/variables?
Something like:
where OPNMUTAFDELINGLocatie = 'S'
regards,
david
sure - you can make any lines of code conditional by wrapping them in IF..THEN..ELSE
IF A=0 THEN
(do something)
END IF
thanx for all help, the result is great..
regards,
david