Page 1 of 1 1
Topic Options
#76095 - 2003-07-28 01:39 PM Strange GOTO Error
nboothe Offline
Lurker

Registered: 2001-11-07
Posts: 4
I'm getting an unknow command [BEGIN] error in my script and I can't figure out why. I've used this same command in the script numerous time and it has never given an error before. Here is an excerpt from the script.

code:
  

; UPDATES THE CLIENT REGISTRY BASED ON THE VALUE OF $OS

SELECT
CASE ($OS = "Windows XP")
GOTO "winxp"
CASE ($OS = "Windows 98")
GOTO "win9x"
CASE ($OS = "Windows 95")
GOTO "win9x"
CASE ($OS = "Windows 2000")
GOTO "begin"
CASE ($OS = "Windows NT")
GOTO "begin"
CASE ($OS = "Windows ME")
GOTO "begin"
CASE ($OS = "Unknown OS")
GOTO "begin"
ENDSELECT

:winxp

SHELL "regedit -s w:\regfiles\proxywxp.reg

IF EXIST(c:\windows\system32\dsfolder.dll)
GOTO "BEGIN"
ELSE
ENDIF

COPY "w:\scriptfiles\dsfolder.dll" "c:\windows\system32"
SHELL "regsvr32 dsfolder.dll /s"
GOTO "BEGIN"
END

:win9x

SHELL "regedit -s w:\regfiles\proxyw9x.reg"
GOTO "BEGIN"
END

;-----------------------------------------------------------------------------

:BEGIN

; DECLARES THE VARIABLE $CL AS THE NAME OF THE CLIENTS WORKSTATION. LOOKS AT
; THE FIRST THREE CHARACTERS OF THE WORKSTATION NAME AND JUMPS TO SECTION OF THE
; SCRIPT ASSOCIATED WITH THE SPECIFIC SITE. IF NO MATCH IS FOUND IT JUMPS TO :W9X

$cl = "@wksta"

The exact section that gives me the problem is:

code:
  

IF EXIST(c:\windows\system32\dsfolder.dll)
GOTO "BEGIN"
ELSE
ENDIF

Any help would be appreciated!

Thanks.

Top
#76096 - 2003-07-28 01:40 PM Re: Strange GOTO Error
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Easy one:

You miss the quotes in here :

quote:
IF EXIST(c:\windows\system32\dsfolder.dll)
should be:

code:
 IF EXIST('c:\windows\system32\dsfolder.dll') 



[ 28. July 2003, 13:41: Message edited by: Jochen ]
_________________________



Top
#76097 - 2003-07-28 01:42 PM Re: Strange GOTO Error
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
By the way,

you can dismiss the 'else' in that case
_________________________



Top
#76098 - 2003-07-28 01:52 PM Re: Strange GOTO Error
nboothe Offline
Lurker

Registered: 2001-11-07
Posts: 4
Thanks for reply. I added the single quotes but still get the same error. Any other ideas?

Thanks.

Top
#76099 - 2003-07-28 02:07 PM Re: Strange GOTO Error
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yep,

you also missed the trailing quotation here :

quote:
SHELL "regedit -s w:\regfiles\proxywxp.reg
[Roll Eyes]
_________________________



Top
#76100 - 2003-07-28 02:11 PM Re: Strange GOTO Error
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I wasn't aware that END was a command in the KiXtart manual. [Wink]
Top
#76101 - 2003-07-28 02:15 PM Re: Strange GOTO Error
nboothe Offline
Lurker

Registered: 2001-11-07
Posts: 4
Jochen, you are the man! I looked a that stupid script over and over again. I knew it was something simple.
Top
#76102 - 2003-07-28 02:17 PM Re: Strange GOTO Error
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You could also do away with the GOTO statements by changing the logic around a little...



; UPDATES THE CLIENT REGISTRY BASED ON THE VALUE OF $OS

SELECT
    CASE ($OS = "Windows XP")
        SHELL "regedit -s w:\regfiles\proxywxp.reg"
        IF NOT EXIST('%WINDIR%\system32\dsfolder.dll')
            COPY "w:\scriptfiles\dsfolder.dll" "c:\windows\system32"
            SHELL "regsvr32 dsfolder.dll /s"
        EndIf
       
    CASE InStr($OS,"Windows 9")
        SHELL "regedit -s w:\regfiles\proxyw9x.reg"
       
    CASE 1
ENDSELECT

;-----------------------------------------------------------------------------

:BEGIN

; DECLARES THE VARIABLE $CL AS THE NAME OF THE CLIENTS WORKSTATION.  LOOKS AT
; THE FIRST THREE CHARACTERS OF THE WORKSTATION NAME AND JUMPS TO SECTION OF THE
; SCRIPT ASSOCIATED WITH THE SPECIFIC SITE.  IF NO MATCH IS FOUND IT JUMPS TO :W9X

$cl = "@wksta"



[ 28. July 2003, 14:19: Message edited by: Chris S. ]

Top
#76103 - 2003-07-28 03:25 PM Re: Strange GOTO Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, GOTOs are evil [Mad] They should never, ever be used in code unless as a last resort by a desperate coder.
_________________________
There are two types of vessels, submarines and targets.

Top
#76104 - 2003-07-28 10:59 PM Re: Strange GOTO Error
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
quote:
unless as a last resort by a desperate coder
I disagree... There's always a way to avoid using GOTO. If you can't find it, ask it here at the BB!!!
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#76105 - 2003-07-28 11:05 PM Re: Strange GOTO Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
quote:
unless as a last resort by a desperate coder
Quote from "The (Un)Official Survival Handbook of KiXtart Coders" (estimated publishing date 29-FEB-2005 by Microsoft Linux Press), under entry "When to use GOTO":
quote:
GOTO HELL, you damn !@#$ing piece of %^&* that is supposed to be a two-liner no-brainer reg hack
_________________________
There are two types of vessels, submarines and targets.

Top
#76106 - 2003-07-28 11:10 PM Re: Strange GOTO Error
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
LOL,

Can I have copy of that manual (a beta would be nice [Wink] )
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#76107 - 2003-07-28 11:12 PM Re: Strange GOTO Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Sorry, but there will be only "alpha" editions, the printing presses are not able to handle a beta print job [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#76108 - 2003-07-28 11:25 PM Re: Strange GOTO Error
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
OK, will wait untill 2005-02-29...
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#76109 - 2003-07-29 02:05 PM Re: Strange GOTO Error
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Um... before you get really harsh with GOTOs, you might consider that they are useful when debugging code. I often use a GOTO during development to skip blocks of code that would be destructive during the testing process, or a particular block of logic that isn't yet logical.

Of course, the GOTOs are removed when the script is ready for deployment! But - Jens - you might want to update your manual to reference:

GOTO - Useful for debugging, as in the following example, where a non-working block of code must be skipped:
code:
 
Goto The_End_Of_This_!@#$@#ing_Routine!

; this code doesn't work!!!
$X = MyFunc("myArg',6,'23")

:The_End_Of_This_!@#$@#ing_Routine!

Glenn [Wink]
_________________________
Actually I am a Rocket Scientist! \:D

Top
#76110 - 2003-07-29 02:44 PM Re: Strange GOTO Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
My alternative in those cases is
code:
if 0
; this code doesn't work!!!
$X = MyFunc("myArg',6,'23")
endif

or when getting fancier
code:
$debug=1
if not $debug
; this code doesn't work!!!
$X = MyFunc("myArg',6,'23")
endif

conveniently controlled at the beginning of a script. That is actually why I need a @KIXEXE macro. Then I can automatically run a script in debugging mode via KIX32.EXE and in clean console-less mode via WKIX32.EXE
_________________________
There are two types of vessels, submarines and targets.

Top
#76111 - 2003-07-29 03:40 PM Re: Strange GOTO Error
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Yes, that works, but it's hard to tell later which IF statements should be removed unless you use the $DEBUG form.

You KNOW that all the GOTOs have to perform a "GOTO bit-bucket"! [Big Grin]

I actually use a Cmd() UDF to execute external commands in this fashion. If $DEBUG is true (a global var) then the command is displayed instead of executed. The display is via a MSG() UDF, which either writes to the screen, or to a log file if $_LOGFILE (also a global) is defined.

I still use GOTOs for simple and temporary detours.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#76112 - 2003-07-29 03:49 PM Re: Strange GOTO Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'm using something similar where each screen output is done via DisplayText() instead of ? DisplayText() has a couple of bit-wise options enabling verbose/warning/error outputs to both a screen and/or separate log file depending on the amont of logging set up. I can thus display only the most important messages (or none at all) to the screen and generate a complete verbose log into a file at the same time.
_________________________
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
0 registered and 1343 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.092 seconds in which 0.051 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