Hi. Is there the possibility to create indirect karel Variables? A simple example :
param,param_1,param_2,i: Integer
GET_REG(1,real_flag,int_value,real_value,STATUS)
i=int_value
param=param_i
Can i do something like this? How?
Thanks in advance
Hi. Is there the possibility to create indirect karel Variables? A simple example :
param,param_1,param_2,i: Integer
GET_REG(1,real_flag,int_value,real_value,STATUS)
i=int_value
param=param_i
Can i do something like this? How?
Thanks in advance
Hi
If you mean like as in C++ :
bla-bla-bla code
int new_val = 0;
bla-bla-bla code
That is not possible in karel right now. Karel language similar Pascal with structure VAR/BEGIN/END. All your variables must were declaring in your module VAR. Or you can write some sub program in your program and compile it. And after I think it is possible to use....but I didn't write this in Karel.
Hi. Is there the possibility to create indirect karel Variables? A simple example :param,param_1,param_2,i: Integer
GET_REG(1,real_flag,int_value,real_value,STATUS)
i=int_value
param=param_i
If I understand you correctly, you want to 'compose' the name of a variable at runtime, right? If so, then that is possible, with some restrictions. See the BYNAME() function.
One of the bigger restrictions is that you cannot actually do param=BYNAME(..), but you can only use it to pass values by reference to routines, so: MY_FUNC(BYNAME('prog_name', 'var_name', ..), other_var). But you can work around that by creating a small routine that just sets your variable to the value it received using BYNAME(..).