I’ve got a routine that will reverse a string - or in this case correctly print “Hello Word!” forward from it’s reverse, as is my want.
Can I just check a couple of things, Marcus?
In order to return a parameter from a funct… I mean routine, you have to define it first and refer to it in the routine when returning.
Secondly what difference does the # make in loop?
Here’s my code:
// Define variable outside button scope
[VarDef, s, “!dlroW olleH”]
// Define routine here
[RoutineDef, reverse_string,
// Define an empty string
[VarSet, rev, “”]
// reverse the string
[VarSet,i,[StrLength,#s]-1]
[Loop,[StrLength,#s],
[VarSet,rev,[StrMerge,rev,[StrExtract,#s,i,i]]]
[VarDec,i]
]
// Set the routine paramater to the new string
[VarSet, s, rev]
// return parameter here
,s] // End of Routine
[IButton, “Reverse string”, “Reverse that string!”,
[Note, s] // forward
[RoutineCall, reverse_string, s]
[Note, s] // reversed
]
Thanks