Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.


1066 - How can I embed a variable in a string?

by - Joseph Ganci

I am creating a subroutine that will come back with the answer having the contents of the variable within the braces substituted. So that instead of seeing C) {alc1}, you would see C) .01 (the contents of alc1 is .01)

I tried:

--StartVar= the position of the first brace,
--LocVar = The variable containing "C){alc1}".

StartVar := Find("{",LocVar)
EndVar := Find ("}",LocVar)
TVariable := SubStr(LocVar, StartVar, EndVar)
Variable := SubStr(LocVar, StartVar + 1, EndVar - 1)
LocVar := ReplaceWord(TVariable, Variable, LocVar)

The last line should be replaced to the following:

LocVar := ReplaceWord(TVariable, Eval(Variable), LocVar)

Variable is the result of SubStr, which returns a STRING, not the contents of the variable represented by the string. The Eval function will evaluate the contents of the string if it is a real variable.

There are 0 reviews
Add your review