[... snip ...]
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. ;)
No it´s not it´s just faulty code, this can happen to any programmer.
Code like this would do behave just like that in java.
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.
The assumptions about java programming shown here are just plain wrong.
In fact I pretty much doubt that there is any programming language out
there where setting a variable means to exit the function.
Have fun,
Marc
Have fun too,
Bernd Eilers
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]