The problem:
The main structure of the code the way I want it to be-
Def main()
decl int i
decl char arr[3]
INI
PTP HOME ...
arr[1]='w()'
arr[2]='e()'
arr[3]='l()'
for i=1 to 3
arr[i]
endfor
END
def w()
PTP P1 ...
END
def e()
PTP P2 ...
END
def l()
PTP P3 ...
END
Now, as you can see, what i want to do is, have names of SubPrograms stored in an array, and basically call them one by one in a loop. (I could write the SubPrograms one by one and just remove the loop altogether, but after calling every program i have to give a command, and i'm looking for a way where i don't have to write that command everytime, which can be done by using a loop)
The problem is I can't figure out how to store names of the Subprgrams in an array as the above code gives a syntax error.
If there is a different way altogether of calling functions in a loop, I'd be happy to hear about it. else, I'd appreciate the help here.
Thanks :)
You could implement a switch/case inside your for loop to mimic array indexing.
Def main()
decl int i
decl char arr[3]
INI
PTP HOME ...
for i=1 to 3
switch i
case 1
w()
case 2
e()
default
l()
endswitch
endfor
END
def w()
PTP P1 ...
END
def e()
PTP P2 ...
END
def l()
PTP P3 ...
END