List Info

Thread: Veto dataset change




Veto dataset change
user name
2007-05-01 09:30:17
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

You can download the corresponding document here:
http://kraak.info/bibli
o1.sxw

Thank in advance!

Helge

--
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

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Veto dataset change
user name
2007-05-01 11:37:33
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: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Veto dataset change
user name
2007-05-01 20:17:14
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: dev-unsubscribeapi.openoffice.org
> For additional commands, e-mail: dev-helpapi.openoffice.org
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Veto dataset change
user name
2007-05-02 03:32:53
Hi Marc,
>> I found a script from Frank Schönheit  
>> which doesn't work but I don't know what is wrong
with it:
>> ...
> 
> This is a logical error made by Java programmers. ;)

Calling me a Java programmer, who I barely know the basics
of Java ... tsts.

It was of course an error induced by my C++-background 

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer        
frank.schoenheitsun.com -
- Sun Microsystems                      http://www.sun.com/star
office -
- OpenOffice.org Base                       http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Veto dataset change
user name
2007-05-02 10:28:13
>  [... 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: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Veto dataset change
user name
2007-05-02 11:27:31
Am Mittwoch, den 02.05.2007, 10:32 +0200 schrieb Frank
Schönheit - Sun
Microsystems Germany:
> Hi Marc,
> >> I found a script from Frank Schönheit  
> >> which doesn't work but I don't know what is
wrong with it:
> >> ...
> > 
> > This is a logical error made by Java programmers.
;)
> 
> Calling me a Java programmer, who I barely know the
basics of Java ... tsts.

Sorry, didn't know being called a Java programmer would be
interpreted
as insulting you.

> It was of course an error induced by my C++-background


Ah yes, that's better by far. ;)

Marc
-- 
It is practically impossible to teach good programming style
to
students that have had prior exposure to BASIC: as
potential
programmers they are mentally mutilated beyond hope of
regeneration. - Dijkstra

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Veto dataset change
user name
2007-05-02 11:56:29
Am Mittwoch, den 02.05.2007, 17:28 +0200 schrieb Bernd
Eilers:

> Code like this would do behave just like that in java.

Are you really sure? If so, please verify ... see below.

> 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.

If you view it that way, it is.

But in Java the result of a function is set by using return
(assigning a
value to the function name is an error, as long as there is
no variable
with the same name), and "return" has the same
task as a variable named
like the function in BASIC: transporting the result to the
caller.

But in Java - and C++ as I learned now - the return
statement *does*
exit the function.

Marc

class FunctionDemo {

	boolean getBool(int v) {
		if (v == 1) {
			return true;
		}
		return false;
	}

	void run() {
		boolean b = getBool(0);
		System.out.println(b);
		b = getBool(1);
		System.out.println(b);
	}

	public static void main( String[] args ) {
		FunctionDemo me = new FunctionDemo();
		me.run();
	}
}

Gives the following output:

$ javac FunctionDemo.java
$ java FunctionDemo
false
true
$ 

qed


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )