Page 1 of 1 1
Topic Options
#77659 - 2001-04-25 06:52 PM Execute exit(@@error) in a Function
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Let see if i can explain this right....

first the ini file i am using

test.ini

code:

[test]
Drive = y:
unc = \\server\@userid$$

Running this code, the execute command works just fine.

code:

$Drive = readprofilestring("@curdir"+"test.ini","test","drive")
$unc = readprofilestring("@curdir"+"test.ini","test","UNC")

nul = execute('use $Drive "$UNC" exit(@@error)')

? @serror


Now, i place the same execute command in to a function

code:

Function MapDrive($a,$b)
$MapDrive = ""
use $a /d
$nul = execute('use $a "$b" exit(@@error)') ;this is the error point for Beta 2
if @error = 0
$nul = execute('? "$tab$a mapped to $b"')
$mapdrive=0
exit(0)
ELSE
$nul = execute('? "$tabThere was Error#@error mapping $drive to $b$cr$tab@Serror"')
$mapdrive=@error
exit(@error)
endif
endfunction


$Drive = readprofilestring("@curdir"+"test.ini","test","drive")
$unc = readprofilestring("@curdir"+"test.ini","test","UNC")

$nul = mapdrive($drive, $unc)
? @serror


and i get the following error, and kix exits

quote:

Script error : error in USE statement !
if @error = 0

This is code that works fine under kix4.00 Beta 1, but not Beta 2

Bryce

------------------
kix.isorg.net

[This message has been edited by Bryce (edited 25 April 2001).]

Top
#77660 - 2001-04-25 07:27 PM Re: Execute exit(@@error) in a Function
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
after some more testing, this seems to be related to the USE command and not exit(@@error)....

Bryce

------------------
kix.isorg.net

Top
#77661 - 2001-04-25 07:52 PM Re: Execute exit(@@error) in a Function
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I got it working with this addition: "\"

$Drive = readprofilestring("@curdir\"+"test.ini","test","drive")
$unc = readprofilestring("@curdir\"+"test.ini","test","UNC")

and " " after $tab, otherwise it looks for $tabthere. $b$cr$tab@Serror is OK because $ and @ signify the end of a var by specifying the start of another var or macro.

$nul = execute('? "$tab There was Error#@error mapping $drive to $b$cr$tab@Serror"')

cj

Top
#77662 - 2001-04-25 08:03 PM Re: Execute exit(@@error) in a Function
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
CJ, sorry I should have noted what line was causing the error , kix errors out on this line

$nul = execute('use $a "$b" exit(@@error)')

in the function version of the code. (I edited my post to indicate this)

and $tab is a global var that is being set at the start of the code..

Bryce

------------------
kix.isorg.net

Top
#77663 - 2001-04-25 09:52 PM Re: Execute exit(@@error) in a Function
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
And after even more testing.....

code:

Function MapDrive($a,$b)
$MapDrive = ""
use $a /d ; <---this line is causing the problem some how???
$nul = execute('exit(@@error)')
if @error = 0
$nul = execute('? "$tab$a mapped to $b"')
$mapdrive=0
exit(0)
ELSE
$nul = execute('? "$tabThere was Error#@error mapping $drive to $b$cr$tab@Serror"')
$mapdrive=@error
exit(@error)
endif
endfunction


$Drive = readprofilestring("@curdir"+"test.ini","test","drive")
$unc = readprofilestring("@curdir"+"test.ini","test","UNC")

$nul = mapdrive($drive, $unc)


it is the

use a$ /d

line that is causing kix to bomb on EXECUTE command. Not just using @@error, but i can't EXECUTE() any variable. I tried just a simple

execute('? $$a')

no luck.

If I comment out the "use a$ /d " line, i can "execute('? $$a')" with out any errors.

Bryce

------------------
kix.isorg.net

Top
#77664 - 2001-04-25 09:54 PM Re: Execute exit(@@error) in a Function
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I found the problem:

KiXtart 2001 Beta 2 does not support the USE x: /DELETE function!!

This is weird?!?!?

Ok, let me explain:

Here is the code I used:
BryceNetUse.K2K

code:

break on

$tab=chr(9)
$cr=chr(13)+chr(10)

Function MapDrive($a,$b)
$MapDrive = ""
use $a /d
$nul = execute('use $a "$b" exit(@@error)')
if @error = 0
$nul = execute('? "$tab$a mapped to $b"')
$mapdrive=0
exit(0)
ELSE
$nul = execute('? "$tab There was Error#@error mapping $drive to $b$cr$tab@Serror"')
$mapdrive=@error
exit(@error)
endif
endfunction

$Drive = readprofilestring("@curdir\"+"test.ini","test","drive")
$unc = readprofilestring("@curdir\"+"test.ini","test","UNC")

$drive ?
$unc ?


$nul = mapdrive($drive, $unc)
? @serror


It is essentially the same as yours with a few minor changes.

Now, if you run this with the /DEBUG switch on the command line, it will show these lines in the blue line: (this is KiXtart 2001 Beta 2)

debug:
break on
$tab=chr(9)
$cr=chr(13)+chr(10)
Function MapDrive($a,$b)
$Drive = readprofilestring("@curdir\"+"test.ini","test","drive")
$unc = readprofilestring("@curdir\"+"test.ini","test","UNC")
$drive ?
?
$unc ?
?
$nul = mapdrive($drive, $unc)

Now the function runs:
$MapDrive = ""
use $a /d
use k: "\\server\share" exit(@error)
exit(@error)

Then it quits to DOS with
Script error : error in USE statement !
if @error = 0

This implies that the line before "if @error = 0" is at fault, and this is normally the case, but... If you comment out the USE $a /d line and try again, it works OK (run NET USE k: /d before hand otherwise you'll get an error 85)

This shows two problems:
1. USE x: /DELETE is broken in KiXtart 2001 Beta 2.

2. The global DEBUG mode ignores EXECUTE().

More testing:
Put a DEBUG ON above USE $a /DELETE and a DEBUG OFF after it and you can see that it simply does not work.

Put the DEBUG ON/OFF "around" the EXECUTE('USE $a "$b" EXIT(@@error)') and it works fine.

cj



Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 509 anonymous users online.
Newest Members
min_seow, Audio, Hoschi, Comet, rrosell
17881 Registered Users

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