#105069 - 2003-09-24 05:18 PM
Kixscript Error with SELECT-CASE-ENDSELECT
|
Jeff Habrych
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
|
|
|
|
#105071 - 2003-09-30 07:53 PM
Re: Kixscript Error with SELECT-CASE-ENDSELECT
|
Jeff Habrych
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
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
|
|
|
|
#105075 - 2003-09-30 08:23 PM
Re: Kixscript Error with SELECT-CASE-ENDSELECT
|
Howard Bullock
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 ]
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1114 anonymous users online.
|
|
|