Can anyone explain me how to shorten the code I use?
Mark Wieder
mwieder at ahsoftware.net
Wed Mar 15 14:00:17 EST 2006
William-
Here's my take on it:
local tErrMsg, x, tData, tErrs
local tFld, tBtn
put empty into tErrs
repeat with x=1 to 25
put "Niveau van leerling" && x && "mag niet leeg zijn!" into tErrMsg
put "naam" & x into tFld
put "naam" & x & "nivo" into tBtn
put field tFld && the selection of button tBtn into tData
if field tFld is empty then
if the selectedText of button tBtn is "..." then
put empty into tData
else
--answer error tErrMsg
put tErrMsg & cr after tErrs
end if
else -- field x is not empty
if the selectedText of button tBtn = "..." then
--answer error tErrMsg
put tErrMsg & cr after tErrs
end if
end if
end repeat
...but I'm not sure exactly what you want the end result to be. Notice
that what you wrote could result in 25 error dialogs appearing on the
screen, one after another, which could be very annoying. I substituted
the accumulation of errors into a variable which could be checked
after the run:
if tErrs is not empty then
answer error tErrs
end if
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list