Page 1 of 1 1
Topic Options
#202480 - 2011-06-21 12:01 PM Am I going crazy or is it a bug?
Jeroen Offline
Starting to like KiXtart

Registered: 2001-08-16
Posts: 180
Loc: Netherlands

Hi Guys,

Tell me - am I going crazy?

 Code:
Cls
Break on
At (3,3)"Test1"
Get $
Exit
$null = MessageBox("TEST","TEST",4160)


I would expect this code to generate "Test1" as output to the screen, and then to exit the script after I press a button. Instead, it also shows the messagebox... ??

If I change the code to:

 Code:
Cls
Break on
At (3,3)"Test1"
Get $
Exit
At (4,3)"Test2"
Get $
$null = MessageBox("TEST","TEST",4160)


Then it does exactly what I would expect: output only "Test1" to the screen and exit.
_________________________
Regards, Jeroen. There are two ways to write error-free programs. Only the third one works.

Top
#202481 - 2011-06-21 12:07 PM Re: Am I going crazy or is it a bug? [Re: Jeroen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
no, you're not going crazy you simply miss the exit code, whih causes the next statement to be executed:

 Code:
Cls
Break on
At (3,3)"Test1"
Get $
Exit 1
$null = MessageBox("TEST","TEST",4160)
_________________________



Top
#202482 - 2011-06-21 12:11 PM Re: Am I going crazy or is it a bug? [Re: Jochen]
Jeroen Offline
Starting to like KiXtart

Registered: 2001-08-16
Posts: 180
Loc: Netherlands
But the exit code is optional isn't it ?
_________________________
Regards, Jeroen. There are two ways to write error-free programs. Only the third one works.

Top
#202483 - 2011-06-21 12:14 PM Re: Am I going crazy or is it a bug? [Re: Jeroen]
Jeroen Offline
Starting to like KiXtart

Registered: 2001-08-16
Posts: 180
Loc: Netherlands
Or at least, that is what I understood from:

"If EXIT is followed by a numeric expression, then @ERROR is set to the value of that expression and you can check it in the calling script or batchfile."
_________________________
Regards, Jeroen. There are two ways to write error-free programs. Only the third one works.

Top
#202484 - 2011-06-21 03:32 PM Re: Am I going crazy or is it a bug? [Re: Jeroen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
might be mistaken but I would go with the golden rule that commands don't have optional arguments.
_________________________
!

download KiXnet

Top
#202486 - 2011-06-21 05:08 PM Re: Am I going crazy or is it a bug? [Re: Jeroen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Short answer - no, it's not optional. Also applies to QUIT. Don't believe the manual, it tells half-truths.

Long answer - yes it is optional BUT in some cases the code following the Exit will be interpreted as the optional parameter. This is because KiXtart is a free format language and newlines don't have any special meaning so the first bit of code on the next line becomes the parameter. When this happens the code "disappears".

I think we may have a FAQ for this, it used to come up a lot usually with misbehaving conditional constructs.

Exiting without setting a status is a really bad habit anyway, so consider it mandatory.

[edit]Found the FAQ, getting a bit long in the tooth but here it is: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=5&Number=130059 [/edit]

Top
#202499 - 2011-06-24 07:02 AM Re: Am I going crazy or is it a bug? [Re: Richard H.]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Ja, I wrote that FAQ on this a long time ago. I guess all of my FAQs are long in the tooth now.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#202504 - 2011-06-24 02:03 PM Re: Am I going crazy or is it a bug? [Re: Les]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Any example that contains GOSUB is going to have the kids asking "what era are you, like, from daddy-o" \:\)

Maybe venerable would have been better. No?

Top
#202505 - 2011-06-24 04:11 PM Re: Am I going crazy or is it a bug? [Re: Richard H.]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If you remember the 60's, you weren't there.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#202506 - 2011-06-24 05:06 PM Re: Am I going crazy or is it a bug? [Re: Les]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
They kept talking about the "free love," but I never even got "free like." \:\)
Top
#202508 - 2011-06-24 09:15 PM Re: Am I going crazy or is it a bug? [Re: BradV]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol
_________________________
!

download KiXnet

Top
#202509 - 2011-06-26 07:02 PM Re: Am I going crazy or is it a bug? [Re: Lonkero]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
Surely, unless you want to exit a program with an error code, then the RETURN command is the best to use.
(I also remember the 60s, and I know I was there).
_________________________
Bill

Top
#202513 - 2011-06-27 06:59 PM Re: Am I going crazy or is it a bug? [Re: BillBarnard]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: BillBarnard
Surely, unless you want to exit a program with an error code, then the RETURN command is the best to use.
(I also remember the 60s, and I know I was there).


Yes, you could use RETURN to avoid setting the exit state but generally in coding circles it's considered a bit gauche, some compilers will even take you to task for such a willful breach of etiquette.

It's good manners to explicitly set your exit state, and it takes as much typing to "EXIT 0" as it does to "RETURN" so there is really no excuse \:\)

Joking aside there are sound reasons for getting into the habit explicitly stating your error state when leaving a section of code, even if you don't think that it's important at the time.

Top
#202515 - 2011-06-27 07:10 PM Re: Am I going crazy or is it a bug? [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Just a small technical clarification, Richard... It actually takes one LESS keystroke to type "Exit 0" than it does to type "RETURN" (5 vs 6). \:\)

I'm not sure if Return would work (properly) from a function, as it is used to exit from a subroutine.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#202525 - 2011-06-28 03:58 AM Re: Am I going crazy or is it a bug? [Re: BillBarnard]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: BillBarnard
I also remember the 60s, and I know I was there.
I think when Robin Williams coined the phrase, the connotation was that if you were "there", you were smoking pot and everyone knows pot destroys your memory.

I remember the 60's so I wasn't really "there".

Back on topic, I agree with Richard that the Exit code should be set.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#202526 - 2011-06-28 09:24 AM Re: Am I going crazy or is it a bug? [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Glenn Barnas
Just a small technical clarification, Richard... It actually takes one LESS keystroke to type "Exit 0" than it does to type "RETURN" (5 vs 6). \:\)


Ahh, so you must have one of those fancy-pants syntax checking editors that automatically types the space character for you then \:\/

Top
#202532 - 2011-06-28 09:53 PM Re: Am I going crazy or is it a bug? [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol
_________________________
!

download KiXnet

Top
#202534 - 2011-06-29 01:07 AM Re: Am I going crazy or is it a bug? [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
WTF?? Spaces never count in KixGolf! \:D
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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.074 seconds in which 0.027 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