Page 1 of 1 1
Topic Options
#99795 - 2003-03-19 06:37 PM FAQ Disscussion - Error Msg Lookup
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I did a little tweaking of Howard's ConvertCOMError() function. It goes a little like this...

code:
fnConvertCOMErr(-2147352567)
@ERROR " : " @SERROR ?

Function fnConvertCOMErr($sErr)
If $sErr<0 $sErr=VAL("&"+Right(DecToHex($sErr),4)) EndIf
Exit $sErr
Endfunction

The benefit is that the error code is now converted for the @ERROR and @SERROR macro without having to resort to "net helpmsg" which isn't available on all operating systems.

[ 19. March 2003, 18:39: Message edited by: Chris S. ]

Top
#99796 - 2003-03-19 07:16 PM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not bad.
simple when compared to Cerror() - translates com-errors
_________________________
!

download KiXnet

Top
#99797 - 2003-03-19 08:16 PM Re: FAQ Disscussion - Error Msg Lookup
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Great job Chris! That is worthy of a Golf trophy. You have taken code of 121 characters and reduced it to 103 characters while adding more KiXtart functionality.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#99798 - 2003-03-19 09:31 PM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn, if this all about golf:
code:
Function fnConvertCOMErr($sErr)
Exit Iif($sErr<0,VAL("&"+Right(DecToHex($sErr),4)),0)
Endfunction

is 93 and in hungarian notation

proper golf score would be with:
code:
Function fnConvertCOMErr($)
Exit Iif($<0,VAL("&"+Right(DecToHex($),4)),0)
Endfunction

and score 81 [Big Grin]
_________________________
!

download KiXnet

Top
#99799 - 2003-03-19 09:41 PM Re: FAQ Disscussion - Error Msg Lookup
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Lonk, you have too much time on your hands. [Wink]

Chris, could this be made more generic by (using Lonk's IIF code) by returning the input value if it is >= 0? Or do we never see a COM error return anything zero and above?

code:
Function fnConvertCOMErr($sErr)
Exit Iif($sErr<0,VAL("&"+Right(DecToHex($sErr),4)),VAL($sErr))
Endfunction

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#99800 - 2003-03-19 09:44 PM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no, com never returns above zero.
I thought that chris check was only for the users who don't know what com is.

as if we are sure there is only com-errors, the code comes down to:
code:
Function fnConvertCOMErr($)
Exit VAL("&"+Right(DecToHex($),4))
Endfunction

being 70 [Wink]
_________________________
!

download KiXnet

Top
#99801 - 2003-03-19 10:02 PM Re: FAQ Disscussion - Error Msg Lookup
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Lonks last code was my first take at it, but I didn't post that. I added the if $sErr<0 to make it error proof. Adding IIF is less compatable with earlier versions of KiX.
Top
#99802 - 2003-03-19 10:05 PM Re: FAQ Disscussion - Error Msg Lookup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
When discussing a FAQ, I would appreciate if you would provide a link.

http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=10&t=000047#000000

The FAQ is now linked to this thread.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#99803 - 2003-03-19 10:07 PM Re: FAQ Disscussion - Error Msg Lookup
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
BTW, I posted this for two reasons...
  • To update the Error Checking FAQ
  • To start a discussion on adding a new SETOPTION to automatically convert COM errors to "real" error codes.

Top
#99804 - 2003-03-19 10:09 PM Re: FAQ Disscussion - Error Msg Lookup
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Sorry Les, busy today. Sentences using verbs and nouns only. [Wink]
Top
#99805 - 2003-03-19 10:12 PM Re: FAQ Disscussion - Error Msg Lookup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
When the dust settles on this topic, if someone wants to take the best of both threads and make it into one, be my guest.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#99806 - 2003-03-20 09:34 PM Re: FAQ Disscussion - Error Msg Lookup
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Chris,

Could you post code with PostPrep when possible... sooooo much easier to copy and use right away. [Wink]

Top
#99807 - 2003-03-21 12:57 AM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
chris, can you or me post this as udf?

as I see, it comes to simple way of doing things and as such, must be as udf.
what comes to current, this is 34 times simpler and thus better.
_________________________
!

download KiXnet

Top
#99808 - 2003-03-21 01:00 AM Re: FAQ Disscussion - Error Msg Lookup
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Sure, I'll post it.
Top
#99809 - 2003-03-21 01:07 AM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn nice [Wink]

waiting for opportunity to destroy one of my owns [Big Grin]

once again, thanks for sorting this "out"...
meaning, making it simple...

with kix one can do that... but without correctly adjusted brains, no-one can do simple code!
so, thanks again!

[ 21. March 2003, 01:10: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#99810 - 2003-03-21 02:26 AM Re: FAQ Disscussion - Error Msg Lookup
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Published function here: fnCOMErr()
Top
#99811 - 2003-03-22 03:50 AM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
chris, didn't like the iif-way I posted?
_________________________
!

download KiXnet

Top
#99812 - 2003-03-22 03:51 AM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, if you want to keep it backwards compatible (without iif):
code:
Function fnCOMErr($lErr)
If $lErr<0 Exit VAL("&"+Right(DecToHex($lErr),4)) EndIf
Endfunction

_________________________
!

download KiXnet

Top
#99813 - 2003-03-22 03:52 AM Re: FAQ Disscussion - Error Msg Lookup
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I don't think we need to KiXGolf UDFs. They should rather be easy to understand for novices.
_________________________
There are two types of vessels, submarines and targets.

Top
#99814 - 2003-03-22 03:55 AM Re: FAQ Disscussion - Error Msg Lookup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh.
the dependency...

why you say that it's 4.02?
as far as I know, the dep is 4.00 RC-4

thus making it "dependencies: none"
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.073 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

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