Page 1 of 1 1
Topic Options
#105069 - 2003-09-24 05:18 PM Kixscript Error with SELECT-CASE-ENDSELECT
Jeff Habrych Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 5
Loc: Groton, CT
This is part of a Command line parsing function that I have put together for a script. But when I compile and run the script I get a Kixtart ERROR

ERROR: Error in Expression: this type of array not supported in expression !
-script name-
Line 4

The line in question is the SELECT command which is confusing since if anything I would expect the error to be in the CASE stmt. And I've tried multiple variations of that line just in case it was that line, but no luck.

I've put in code to check how the SPLIT Command is parsing the commandline and it's output is what I expect

Command
option1
option2
optionN

Has anyone run into anything similar?

CODE ========================================
Function CmdLineParse()
Dim $CmdLine[20]

$CmdLine = Split($EXECmdLine, " ", -1)

For Each $parm In $CmdLine

Select

Case InStr($opt, "/computer=") <> 0
$x = Trim(Right(InStr($parm, "=")))
$_computer = Trim(Right($parm, Len($parm) - $x))

Case InStr($CmdLine, "/repository=") <> 0
$x = Trim(Right(InStr($parm, "=")))
$_repository = Trim(Right($parm, Len($parm) - $x))

Case 1
? "Unknown Parameter" + $parm

EndSelect

Next

EndFunction
_________________________
---------------------------------------------------------------------------------------- NOTE: Regardless of content, this post shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of posts for such purpose. ----------------------------------------------------------------------------------------

Top
#105070 - 2003-09-24 05:21 PM Re: Kixscript Error with SELECT-CASE-ENDSELECT
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Where is $EXECmdLine coming form? It is not being defined.

BTW, there has already been a command-line parsing function/script been posted on this BBS. Use the BBS Search to retrieve it.
_________________________
There are two types of vessels, submarines and targets.

Top
#105071 - 2003-09-30 07:53 PM Re: Kixscript Error with SELECT-CASE-ENDSELECT
Jeff Habrych Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 5
Loc: Groton, CT
The EXECMDLINE comes from when you compile the kixscript it is the complete ARGV from the OS it includes the command name itself.

The Command line parse GetOption(), it's basically the same solution as what I've shown. That function returns the value for the option, without any processing of the value. Which I'd still have to do anyway, with the value after it was returned.

I choose to process the whole command line at once within the same function instead of putting the burden by overusing the program stack.
_________________________
---------------------------------------------------------------------------------------- NOTE: Regardless of content, this post shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of posts for such purpose. ----------------------------------------------------------------------------------------

Top
#105072 - 2003-09-30 07:54 PM Re: Kixscript Error with SELECT-CASE-ENDSELECT
Jeff Habrych Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 5
Loc: Groton, CT
BTW: as a side note I did use all available doucmentation listed, as well as google searches and trying several different approaches in code before posting.

Thanks,
_________________________
---------------------------------------------------------------------------------------- NOTE: Regardless of content, this post shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of posts for such purpose. ----------------------------------------------------------------------------------------

Top
#105073 - 2003-09-30 08:01 PM Re: Kixscript Error with SELECT-CASE-ENDSELECT
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Compile KiXtart? You would be the first who claims to successfully compile KiXtart [Eek!] [Confused]

Are you sure you're not talking about e.g. KiXcrypt or similar?

Also, in your example $EXECmdLine must be defined as a global variable, otherwise it would be empty inside the function.

What does $EXECmdLine and $CmdLine contain? And please post the complete code!

Did you step through the code with DEBUG ON in the first line of the code?
_________________________
There are two types of vessels, submarines and targets.

Top
#105074 - 2003-09-30 08:12 PM Re: Kixscript Error with SELECT-CASE-ENDSELECT
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jeff, think you might want to mention that your probably using the Kixscripts editor exe packager, and that this $parm gets passed to your script, ja ?
Top
#105075 - 2003-09-30 08:23 PM Re: Kixscript Error with SELECT-CASE-ENDSELECT
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I see a few mistakes in your code.

Case InStr($opt, "/computer=") <> 0
should be
Case InStr($parm, "/computer=")

$x = Trim(Right(InStr($parm, "=")))
should be
$x = Trim(Right($parm, InStr($parm, "=")))

Case InStr($CmdLine, "/repository=") <> 0
should be
Case InStr($parm, "/repository=")

code:
Function CmdLineParse()
Dim $CmdLine[20]

? "$$EXECmdLine = '" + $EXECmdLine + "'"

$CmdLine = Split($EXECmdLine, " ",-1)
? "Ubound of $$CmdLine = " + ubound($CmdLine)

For Each $parm In $CmdLine
? "$$parm = " + $parm
Select
Case InStr($parm, "/computer=")
$x = Trim(Right($parm, InStr($parm, "=")))
$_computer = Trim(Right($parm, Len($parm) - $x))

Case InStr($parm, "/repository=") <> 0
$x = Trim(Right($parm, InStr($parm, "=")))
$_repository = Trim(Right($parm, Len($parm) - $x))

Case 1
? "Unknown Parameter" + $parm
EndSelect
Next

EndFunction



[ 30. September 2003, 20:24: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

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
0 registered and 1024 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.046 seconds in which 0.02 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