Calling consecutive variables into Maple from MapleTA
-
I have some variables in MapleTA incrementally named:
----------------The below can be copied into MapleTA---------------
$numOFdefinedANSWERS=3;
$Answer1=4;
$Answer2=7;
$Answer3=15;
#etc.... this list can go on to an undetermined length, dependent on the person building the question (if more answers are added then the user will increment numOFdefinedANSWERS accordinginly)
#From here I am hoping to build a Maple call-out that will build an array of these MapleTA variables. At this point I am simply hoping to attain the last variable in the loop, from there I will build the array.$maplecall=maple("
restart:
for i from 1 to $numOFdefinedANSWERS do
a:=$Answer||i
end do;
");#Presently this call out seems to completely ignore the dollar sign... as "Answer3" is sent back to MapleTA, when I would like "15" sent back to TA.
#I tried to modify using this callout...
$MAPLE_call=maple("
restart;
with(StringTools);
for i from 1 to $numOFdefinedANSWERS do
a:=cat(Char(36),Answer,i)
end do;
");# This Generates a string sent back to MapleTA, that a parse seems to not handle well either?
#Any ideas are appreciated?
-
I'm not sure if this is acceptable in your implementation, but moving the variables inside the Maple call works. The reason is that (unfortunately) the dollar sign has a different meaning in Maple.
$MAPLE_call=maple(" Answer1:=4; Answer2:=7; Answer3:=15; C:=Array([]): for i from 1 to $numOFdefinedANSWERS do a:=parse(cat(Answer,i)): C:=ArrayTools[Append](C,a): end do; C; ");
-
Thank-you for the response. I am not wanting to call the variables into Maple until desired (in other words not all together at the start).
The reasoning is User A might only have 3 defined answers to the particular question while user B might have 7 defined answers. I was hoping the for loop would gradually gather all the answers rather than having them defined at the start of the call to maple.
Mark