Page 1 of 2 12>
Topic Options
#130037 - 2004-11-22 07:20 PM three times a messagebox
Anonymous
Unregistered


When I run the next script, I get three!! times a messagebox. First the first, then the second and then THE FIRST AGAIN!!
How come??????

Gosub test
MessageBox ("second","test")
Exit

:test
MessageBox ("first","test")
Return

Top
#130038 - 2004-11-22 07:25 PM Re: three times a messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Because you have fallen victim to the infamous "hanging-out exit" syndrome. You should put some value after your EXIT statement, else the next expression gets evaluated along with the exit (in this case, the MessageBox function), so do this:

Exit 0

-Shawn

Top
#130039 - 2004-11-22 07:36 PM Re: three times a messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If I thought anyone would read it, I would write a FAQ on this issue.

Like I say in my sig...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130040 - 2004-11-22 08:28 PM Re: three times a messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ah go ahead and write one, not much else going on today ;0) ...

Hans, another thing you might do is "silence-up" those MessageBox functions, so that you don't get those odd 1's and 0's printing on your console, like this:

$= MessageBox ("second","test")

There is a FAQ written on that btw.

-Shawn

Top
#130041 - 2004-11-22 09:35 PM Re: three times a messagebox
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think that was ment as: "why the heck I wrote the faq for as nobody seems to read it anyways!"
_________________________
!

download KiXnet

Top
#130042 - 2004-11-22 09:38 PM Re: three times a messagebox
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Hi Hans,

Even though GOTO and GOSUB are supported by KiXtart, in my opinion it would be better to craft your code so as to avoid the usage of those commands.

Something like this would only run when it was called and should end properly.


Code:
Dim $TestMsg

$TestMsg=DisplayMsg('This is a test of the message box from KiXtart')
If $TestMsg=1
? 'User selected OK'
Else
? 'User selected CANCEL'
EndIf

Function DisplayMsg($Message)
Dim $Msg,$MsgErr
$Msg=MessageBox($Message, 'Testing', 65)
$MsgErr=@ERROR
$DisplayMsg=$MsgErr
EndFunction



Edited by NTDOC (2004-11-22 09:51 PM)

Top
#130043 - 2004-11-22 09:48 PM Re: three times a messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
K, well... wrote the damn thing...

EXIT [error level / exit code] optional or not?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130044 - 2004-11-22 09:55 PM Re: three times a messagebox
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Nice little FAQ in such a short time there Les.
Top
#130045 - 2004-11-22 09:57 PM Re: three times a messagebox
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just wonder, should this be updated then too:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB10&Number=81577&Forum=UBB10&Main=81577#Post81577
_________________________
!

download KiXnet

Top
#130046 - 2004-11-22 10:25 PM Re: three times a messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Eh... Shawn made me do it!

Speaking of FAQs... when will we see an update to the FAQ/UDF CHM?

I even found you one of those round tuit thingies.
http://www.myrtlewoodgallery.com/get_a_round_tuit.htm

I know the round ones must be rare but I think this guy has a good supply.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130047 - 2004-11-22 10:38 PM Re: three times a messagebox
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm, nice FAQ there Les ... just one comment though ... you used a simple example through-out your discussion, then at the end of it (your last example), you kinda re-worked the whole thing and threw in a UDF and kinda obscured the whole thing. Just my opinion. two cents ... thought just showing the original sample with EXIT 0 would have been clearer.
Top
#130048 - 2004-11-22 11:15 PM Re: three times a messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Me thinks you either skimmed over it too quickly, or I wrote it too vague.

The third example was a digression... showing the "other" use for EXIT. That's what I get for trying to make the FAQ into a swiss army knife.


BTW, I tried to click on the HansP name but it no worky.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130049 - 2004-11-23 12:58 AM Re: three times a messagebox
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Okay a little tribute to the KF Master... but it's about time to quit hijacking this thread.
Top
#130050 - 2004-11-23 01:09 AM Re: three times a messagebox
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA

Top
#130051 - 2004-11-23 01:10 AM Re: three times a messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
quit hi-jakking this thread you say...

HA!

First off, it is hijaak, not hijakk!

Second, there is no registered owner of this thread so it is fair game.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130052 - 2004-11-23 01:13 AM Re: three times a messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
basta doc... teach me not to msn with him while I reply.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130053 - 2004-11-23 01:15 AM Re: three times a messagebox
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Well, not sure how Canadians spell it, but DICTIONARY says
Hijack and highjack

http://dictionary.reference.com/search?r=2&q=hijack

Top
#130054 - 2004-11-23 01:17 AM Re: three times a messagebox
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Bryce... what's your new MSN account?
Top
#130055 - 2004-11-23 02:11 PM Re: three times a messagebox
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hi Jack, err Ron,

You basta made me rofl'ing with your new avatar collection avatar.
Great! Even the sex boat is included
_________________________



Top
#130056 - 2004-11-23 04:20 PM Re: three times a messagebox
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Quote:

Bryce... what's your new MSN account?




should be bryce at isorg dot net.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1045 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.077 seconds in which 0.032 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org