Jump to content
Sign in to follow this  
phew

Cannot assign values to constants.

Recommended Posts

phew

I received the error:

$cmdline = StringRegExp($cmdstring, '(.*?) (.*)', 1)
^ERROR
Error: Cannot assign values to constants.

in my script

If ($foundhost = $hostmatch) Then
                    MsgBox(0, "", $cmdstring)
                    $cmdline = StringRegExp($cmdstring, '(.*?) (.*)', 1)
                    $cmdsplit = StringSplit($cmdline, " ")
                    For $i = 0 To UBound($cmdsplit) - 1 
                        Select 
                        Case $i = 1
                            $cmdparam_1 = StringStripWS($cmdsplit[$i], 8)
                        Case $i = 2 
                            $cmdparam_2 = StringStripWS($cmdsplit[$i], 8)
                        Case $i = 3
                            $cmdparam_3 = StringStripWS($cmdsplit[$i], 8)
                        EndSelect
                    Next
            EndIf

EDIT:

while the string $cmdstring = "debug debug ikdkaksometextskdkakjs123"

someone can help pls :|

Edited by phew

Share this post


Link to post
Share on other sites
BrettF

$cmdline is already defined. As I hear you ask? Read on:

The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way.

$CmdLine[0] is number of parameters

$CmdLine[1] is param 1 (after the script name)

$CmdLine[2] is param 2 etc

...

$CmdLine[$CmdLine[0]] is one way to get the last parameter...

So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"

If the script was compiled it would have been run like this:

myscript.exe param1 "this is another param"

$CmdLineRaw equals... param1 "this is another param"

Note that $CmdLineRaw just return the parameters.

Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.

If you change the varible name you will be good to go.

Share this post


Link to post
Share on other sites
phew

$cmdline is already defined. As I hear you ask? Read on:

If you change the varible name you will be good to go.

aye, thanks, didn't know that $CmdLine is an autoit-constant

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×