Neat Trick!
Dave
dave at looktowindward.com
Wed Nov 7 18:44:49 EST 2007
Hi All,
Thought I'd share this one! If you have a number of function calls
that can fail by returning a value and you need to check but also
save the result, here's a neat trick:
repeat forever
put empty into myErrorMessage
if somefunction(Inputparam1, Inputparam2,myResult1,myErrorMessage) =
false then exit repeat
if somefunction(Inputparam3, Inputparam4,myResult2,myErrorMessage) =
false then exit repeat
if somefunction(Inputparam5, Inputparam6,myResult3,myErrorMessage) =
false then exit repeat
if somefunction(Inputparam7, Inputparam8,myResult4,myErrorMessage) =
false then exit repeat
if somefunction(Inputparam9, Inputparam10,myResult5,myErrorMessage) =
false then exit repeat
exit repeat
end repeat
if myErrorMessage = empty then
-- Do Success code and work on the results obtained
else
-- Do Failure Code
end if
In this case the "end repeat" acts as a "label" and we simulate a
goto with "exit repeat"
Cool, Huh?
All the Best
Dave
More information about the use-livecode
mailing list