I could have recognized this fault by myself, just was too blind to
see it :-). Thanks a lot for assisting me, Marc!
Best regards
Helge
PS: Andrew, maybe this example script might be interesting for your
book? Using the search word "veto" in connection with starbasic I
couldn't find any examples in the net. I think this example could be
really useful for many users.
--
Helge Kraak
Frauenlobstr. 78a
60487 Frankfurt am Main
Germany
Mobil: +49 (0)178 828 80 90
Telefon: +49 (0)69 979 466 23
Fax: +49 (0)69 133 046 094 11
Internet: www.helge.kraak.info
ICQ: 348131950
Am 01.05.2007 um 18:37 schrieb Marc Santhoff:
Am Dienstag, den 01.05.2007, 16:30 +0200 schrieb Helge Kraak:
Hi,
maybe somebody of you can assist me with my attempt to have a working
veto function for dataset changes in a form. In case a certain entry
in a form doesn't match a correct value I want to intercept the user
from switching to next dataset. I found a script from Frank Schönheit
which doesn't work but I don't know what is wrong with it:
Function approve( Source as Object ) as Boolean
If ( val( Source.Source.Text ) > 10 ) Or ( val( Source.Source.Text )
< 1 ) Then
MsgBox "too large!"
approve = FALSE
End If
approve = TRUE
End Function
This is a logical error made by Java programmers. ;)
Setting the value of the function does not cause the program flow to
stop and exit but goes on, running over the second assignment to
approve. This way approve always yields the value TRUE.
Change it this way and it works:
Function approve( Source as Object ) as Boolean
If ( val( Source.Source.Text ) > 10 ) Or ( val
( Source.Source.Text ) <
1 ) Then
MsgBox "too large!"
approve = FALSE
else
approve = TRUE
End If
End Function
Or insert a line saying "exit function" after setting approve to FALSE
to make BASIC behave like Java.
Have fun,
Marc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]