Page 1 of 1 1
Topic Options
#81887 - 2003-10-10 10:16 AM On Error Resume Next and SubFunction
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Would like to see the following additions to KiXtarts future.

1. Instead of quitting on an error have ability to resume next line of code after an unexpected error.

2. There are times when you write a UDF that could benefit from the use of another UDF, but I don't like having to call or depend on multiple UDFs to fulfill the main UDF.
I'd like to see something like a SubFunction - sort of like other languages have where is would support a sub-routine that is part of the main UDF.

3. I'd also like to see an addition to the setoptions for case sensitivity support.
Maybe something like this.
setoption('OptionExplicit','ON')
Which would understand difference between
spellings and alert you where they don't match.

Top
#81888 - 2003-10-10 02:51 PM Re: On Error Resume Next and SubFunction
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Subfunction already exist. See Err() - Prints an error message on screen and writes the error into the error log , which uses an embedded "TranslateCOMError()" UDF to translate COM error numbers to Win32 error numbers. The included subfunction is build as a textstring, then EXECUTEd.The relevant code snippet is below:
function err()
$errorcode=@ERROR
$errortext=@SERROR
If $errorcode<0
$errorsub=$errorsub+'Function TranslateCOMError($lErr)'+@CRLF
$errorsub=$errorsub+'If $lErr<0 $lErr=VAL("&"+Right(DecToHex($lErr),4)) EndIf'+@CRLF
$errorsub=$errorsub+'exit $lErr'+@CRLF
$errorsub=$errorsub+'Endfunction'
$errortext=execute($errorsub)
$errorcode=TranslateCOMError($errorcode)
$errorcode=@ERROR
$errortext=@SERROR
EndIf
? ''+$errorcode+' - '+$errortext
endfunction



I don't like #3 as it might result in two different variable swith the same spelling but capitalization differences. This would make code harder to read as one will need to remember the differences between the two or more spellings.

[ 10. October 2003, 14:53: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#81889 - 2003-10-10 05:48 PM Re: On Error Resume Next and SubFunction
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well as I envision it, a function within a function is not the same. Unless you pass the parameter back to the other function both functions would treat data as local scope when using the setoption('Explicit','ON') all script code must now dim vars which also then prevents a UDF from seeing that data, thus you would also have to dim all vars in each Function which would then make each local in scope.

As I view it a SUB-FUNCTION would be able to use and easily use or pass back var/data from the main Function.

As for the OptionExplicit I don't see that it would be harder, I see it as an OPTION if you don't want to use it don't use it.
But it would simply force you to maintain consistency in your typing. Different spellings would be different vars but Different Upper/Lower-case spelling would be weeded out.

Top
#81890 - 2003-10-10 05:55 PM Re: On Error Resume Next and SubFunction
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sub-function.
you mean kinda like private classes?
eh, functions [Wink]
ja, why not, but think this is on the same line with structs-requests.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.091 seconds in which 0.069 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