Page 1 of 2 12>
Topic Options
#166889 - 2006-09-05 10:30 PM KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I would think if MessageBox was used correct, it would give error 0
Code:
If NOT @LOGONMODE
Break ON
EndIf
Dim $SO
$SO = SetOption("Explicit","On")
$SO = SetOption("NoMacrosInStrings","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("WrapAtEOL","On")

$SO = MessageBox("Hello World","My First KiX Script")
? "Return Value: " + $SO
? "Error " + @ERROR + ": " + @SERROR
? "Kix Version: " + @KIX

Shows on screen:
Code:
Return Value: 1
Error 1: Onjuiste functie.
Kix Version: 4.53 Release Candidate 1


Top
#166890 - 2006-09-05 11:05 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Value
Meaning

-1
User did not respond to the dialog box within the specified time-out period.

1
OK button selected.

2
Cancel button selected.

3
Abort button selected.

4
Retry button selected.

5
Ignore button selected.

6
Yes button selected.

7
No button selected

Top
#166891 - 2006-09-05 11:12 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
witto, you are correct.
it's an oddity and should be fixed.

Top
#166892 - 2006-09-05 11:13 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I know, but I clicked OK. I would expect error value = 0
Top
#166893 - 2006-09-05 11:14 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Thanks
Top
#166894 - 2006-09-05 11:22 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Jooel,
I did not know if this was "works as designed" or really an issue. Should I repost this in the Beta forum?

Top
#166895 - 2006-09-05 11:30 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
this was discusses some years back, iirc.
could have been some other function too, though.
but honestly, I think it's a bug, even if it works as designed as it doesn't work as expected.

be my guest and copy your original post to beta.

Top
#166896 - 2006-09-06 02:32 AM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Post to suggestions, not beta.
Top
#166897 - 2006-09-06 09:09 AM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good point les.
to avoid any flames...

Top
#166898 - 2006-09-06 09:20 AM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Interesting one.

The manual doesn't state what @ERROR will be, but I agree that it might be more sensible for it to be used to indicate that KiXtart couldn't raise the window because (say) the PC is out of memory.

Top
#166899 - 2006-09-06 09:58 AM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
IMHO, the @Error does not have to be documented for MessageBox seperately. It is all in Appendix B. @Error must just follow the Error codes as listed on the Microsoft Developer Network: System Error Codes .
Top
#166900 - 2006-09-06 10:29 AM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I agree with that.
Top
#166901 - 2006-09-06 01:00 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Indeed. In that case you will want to be doing something about Get as well
Top
#166902 - 2006-09-06 01:58 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Good point. I read it. But this is IMHO a good workaround to catch special keys.

About Get: I think it could be stored in the Return Value, but it should be recognisable. p.e. change the type that is outputted to an Array.
Store in place 0 the Value
Store in place 1 the KeyCode
Code:

Get $SO /A
? "Key: " + $SO[0]
? "KeyCode: " + $SO[1]


If $SO[0] = "" then you know a special key was pressed

$SO[1] p.e. an "A" on a French, Belgian(, Canadian?) keyboard will return the same KeyCode as a "Q" on almost any other keyboard in the world.

/A could be a switch to make Get work in Advanced mode, for downward compatibility

I do not know if that makes sense...

About MessageBox
The Error Code for MessageBox does not give me any added value.
Error Code = Return Value
Return Value = Error Code
It only gave me surprising error values at places in scripts where I did not expect to catch one.


Edited by Witto (2006-09-06 02:12 PM)

Top
#166903 - 2006-09-06 02:53 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'm just pulling your leg.

As I said I agree that it would make more sense if @ERROR was actually returning an error rather than the result value.

The problem is that because it has never worked this way changing the @ERROR value will break existing scripts.

Although it has caught you out AFAIK you are the first person, so it is a very rare event. In fact you might be the first person to have ever checked for a (real) error condition following a MessageBox()!

I guess the question becomes "Is it better to change the action to something more compliant and break backwards compatibility, or is it better to leave it as-is and accept that you cannot check for an error"

I'm fairly neutral on this one, though I'd normally advise against introducing unnecessary compatibility issues.

Top
#166904 - 2006-09-06 03:14 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
About MessageBox:
  • I think checking @ERROR or checking the Return Value for totally the same *value* does not require big recoding.
  • I would also think that most coders would use the return value to check what key is pressed in MessageBox. Just as it is documented.

Or wait, maybe this:
MESSAGEBOX ("message", "title", style, time-out, 1)
A fifth optional parameter to indicate you want real Error Codes? Default = 0?

About Get:
It is just because you came up with it that I just started thinking about a suggestion with downwards compatibility.

Top
#166905 - 2006-09-06 03:16 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
BTW, Thanks for pulling my leg, I liked it.
Top
#166906 - 2006-09-06 03:47 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

The problem is that because it has never worked this way changing the @ERROR value will break existing scripts.

Although it has caught you out AFAIK you are the first person, so it is a very rare event. In fact you might be the first person to have ever checked for a (real) error condition following a MessageBox()!




"Will" sounds so certain. I would prefer to say "might" since I doubt may people actually work with the @Error returned by MessageBox().

THis is not the first known case of being caught off guard by the @Error returned by MessageBox(). It has been discussed several times and I often use it in examples of overly optimistic coding where @Error is assumed. In fact, my examples include a short UDF that uses EXIT to clear @Error.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#166907 - 2006-09-06 04:04 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
what is wrong with get?
and isn't there a @result macro?

Top
#166908 - 2006-09-06 04:35 PM Re: KiX 4.53 RC1, MessageBox: Error Code = Return Value
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

"Will" sounds so certain. I would prefer to say "might" since I doubt may people actually work with the @Error returned by MessageBox()




I actually had "could" at first but "could" or "might" implies a very small chance that any script will break. However given the amount of scripts that are out there it is actually very likely that a change is going to break a number. It's also very likely that it will be a very small number.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 208 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.047 seconds in which 0.016 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