Page 1 of 1 1
Topic Options
#120733 - 2004-06-07 04:17 PM script exits unexpectedly
Udaloy Offline
Fresh Scripter

Registered: 2003-09-08
Posts: 31
Loc: Ohio
I was redirected to this forum, so here goes.
Quote:

Hello all,

Last Thursday or Friday, I started getting calls about some people's network drives not getting mapped. I ran the script in debug mode, and I found that the script is exiting before it's completed. Right in the middle of the script, for no good reason. The whole script is to map an S: drive depending on which department you are in. This script has worked for about a year or so without a hitch, and now it's exiting at this code:

Code:
  


$X = "\\kdata02\"
$name = @USERID
Use s: /Del /persistent


:PROGRAMMERS

If InGroup("Programmers")
Use q: /Del
Use q: $X+"development"
?"Q: drive mapped to Development share"
EndIf


:YEARENDTAX

If InGroup("YearEndTax")
Use y: /Del
Use y: $X+"yearendtax"
?'Y: drive mapped to YearEndTax share'
EndIf



:ACCOUNTING

If InGroup("accounting") OR InGroup("Finan Actg Intern") OR InGroup("Accounts Receivable")


If $name = "skutlen"
GoTo BILLING
EndIf
Use s: $x+"accounting"
?'S: drive mapped to accounting share'
EndIf


:BILLING

If InGroup("billing") OR InGroup("commercial billing") OR InGroup("utility billing") OR InGroup("residential billing")
If $name = "claassek"
GoTo Surgery Payroll
EndIf
Use s: $x+"billing"
?'S: drive mapped to Billing share'
EndIf


:SURGERYPAYROLL

If InGroup("SurgeryPayroll")
If $name = "mazurd"
GoTo INFOSPAN
Else If $name = "nealv"
Use q: $x+"Surgery Payr"
GoTo INFOSPAN
EndIf
Use s: /Del
Use s: $x+"Surgery Payr"
?'S: drive mapped to Surgery Payroll share'
EndIf



:INFOSPAN
;This drive letter has to be x in order for infospan to run properly
If InGroup("infospan users")
Use x: "\\Infospan\Shared"
?'X: drive mapped to Infospan share'
EndIf


:PERSONNEL

If InGroup("personnel") OR InGroup("employee records") OR InGroup("office services")
Use s: $x+"personnel"
?'S: drive mapped to Personnel share'
EndIf


:MARKETING

If InGroup("MARKETING")
Use s: $x+"marketing"
?'S: drive mapped to Marketing share'
If InGroup("Residential Services")
Use r: /Del
Use r: $x+"Residential"
?'R: drive mapped to Residential share'
GoTo TREASURY
EndIf
EndIf


:RESIDENTIAL

If InGroup("residential services")
Use s: $x+"Residential"
?'S: drive mapped to Residential share'
EndIf


:UTILITY

If InGroup("utility") OR InGroup("utility services")
Use s: $x+"utility"
?'S: drive mapped to Utility share'
EndIf


:SAFETY

If InGroup("safety")
Use s: $x+"safety"
?'S: drive mapped to Safety share'
EndIf


:PURCHASING

If InGroup("purchasing")
Use s: $x+"purchasing"
?'S: drive mapped to Purchasing share'
EndIf


:EQUIPMENT

If InGroup("equipment")
Use s: $x+"equipment"
?'S: drive mapped to Equipment share'
EndIf


:ACQUISITION

If InGroup("acquistion integrat")
Use L: /Del
Use L: $x+"Acquisition"
?'L: drive mapped to Acquisition share'
EndIf


:NEWVENTURES

If InGroup("New Ventures")
Use h: /Del
Use h: "\\kdata02\new ventures"
?"H: drive mapped to New Ventures share"
EndIf





:END

Exit





The script exits just after the Marketing section. The reason for the goto is to skip the very next If InGroup line, as there is a person in Marketing that is also in Residential Services, and mapping two S: drives isn't productive.

This particular code happens to be on line 125, not the problem in my opinion. Any ideas?




$X is pointing to the correct server.

Top
#120734 - 2004-06-07 04:50 PM Re: script exits unexpectedly
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
was just browsing the code.
got to this:
Code:

:SURGERYPAYROLL
If InGroup("SurgeryPayroll")
If $name = "mazurd"
GoTo INFOSPAN
Else If $name = "nealv"
Use q: $x+"Surgery Payr"
GoTo INFOSPAN
EndIf
Use s: /Del
Use s: $x+"Surgery Payr"
?'S: drive mapped to Surgery Payroll share'
EndIf


if you look at the line:
Else If $name = "nealv"

you see there is extra if.
syntaxtically, that's ok, but as you never ever close that if, your rest of code is only executed only for ppl from "SurgeryPayroll" group.

so, to fix that, do something like:
Code:

If InGroup("SurgeryPayroll")
If $name = "mazurd"
GoTo INFOSPAN
Else
If $name = "nealv"
Use q: $x+"Surgery Payr"
GoTo INFOSPAN
EndIf
EndIf
Use s: /Del
Use s: $x+"Surgery Payr"
?'S: drive mapped to Surgery Payroll share'
EndIf



Edited by Lonkero (2004-06-07 04:52 PM)
_________________________
!

download KiXnet

Top
#120735 - 2004-06-07 04:55 PM Re: script exits unexpectedly
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Well, this is wrong for a start:
Code:
	  If $name = "mazurd"
GoTo INFOSPAN
Else If $name = "nealv"
Use q: $x+"Surgery Payr"
GoTo INFOSPAN
EndIf



Every "IF" must have a corresponding "ENDIF".

Top
#120736 - 2004-06-07 04:56 PM Re: script exits unexpectedly
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
or yet:
Code:

If InGroup("SurgeryPayroll")
If $name = "mazurd"
GoTo INFOSPAN
Endif
If $name = "nealv"
Use q: $x+"Surgery Payr"
GoTo INFOSPAN
EndIf
Use s: /Del
Use s: $x+"Surgery Payr"
?'S: drive mapped to Surgery Payroll share'
EndIf



to make it little cleaner.
_________________________
!

download KiXnet

Top
#120737 - 2004-06-07 05:06 PM Re: script exits unexpectedly
Udaloy Offline
Fresh Scripter

Registered: 2003-09-08
Posts: 31
Loc: Ohio
My inital results show that you are correct. I'm having the users log off and back on now. Isn't there a statement that forces the code syntax to be correct before it will save? I thought I saw that in someone's script before. Sort of like the implicit statement in VB.

Lonkero, thank you! I owe you one.

Udaloy

Top
#120738 - 2004-06-07 05:15 PM Re: script exits unexpectedly
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the problem is that your code syntax is correct.
there is nothing wrong in the syntax there.
the problem is that the logic you intended (which kixtart can't quess) is not correct.

anyway, good if that was all that was wrong.

for code checking, you could use some coloring editor...
hmm, old postprep had a "block" checker inbuild that would have "reported" the error here.

anyways, once your code grows you will see how important it's to write clean easy to follow code.
that way you yourself can see any problems yourself.

some logging would have helped here too as you would have seen that it never exits this part.
_________________________
!

download KiXnet

Top
#120739 - 2004-06-07 05:53 PM Re: script exits unexpectedly
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You can use MCA's "kixstrip" checking tool available from his site http://home.wanadoo.nl/scripting/

It can be a bit wordy and daunting though.

Top
#120740 - 2004-06-07 07:24 PM Re: script exits unexpectedly
Udaloy Offline
Fresh Scripter

Registered: 2003-09-08
Posts: 31
Loc: Ohio
Richard,

I'll check out that link, thanks. I found what I was thinking about though, it was
Code:
 ;Dim $SO
;$SO=SetOption('Explicit','On')



Does anyone know what the Explicit option does for Kix? Thanx.

Top
#120741 - 2004-06-07 07:40 PM Re: script exits unexpectedly
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
In your case nothing, since you remmed it out.

It forces you to properly dim vars. See the manual in and around page 23 for "Implicit declaration" and page 97.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120742 - 2004-06-08 04:40 AM Re: script exits unexpectedly
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And you should also get rid of the GOTOs in your code as well and instead use properly constructed code flow.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

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

Generated in 0.245 seconds in which 0.166 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