Jump to content

Where is the good old %1% ?


Helge
 Share

Recommended Posts

Just wondering....

Is there any kind of command in AutoIt3, that does the same

trick as the %1% in AutoIt2?

I`ve tried to do the ExpandEnvStrings and then use %1%, but it didn`t work...

Maybe there is any other way of doing it...?

:whistle:

Edited by Helge
Link to comment
Share on other sites

if you want to use command line, AutoIt3 has that one, just improved and put in an array.

Command line params

===================

The variable $CmdLine contains command line parameters.  Note the scriptname is not classed as a parameter, get this information with @ScriptName instead

$CmdLine[0]is number of parameters

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

$CmdLine[2] is param 2 etc

example1:

the compiled autoit script bob.exe

This was run like this "Run bob.exe c:\temp1.txt c:\temp2.txt"

; bob.au3

if $CmdLine[0] =0 then exit; this will exit if no command lines are given.
msgbox(1,$CmdLine[1],$CmdLine[2]); this would output a msgbox title C:\temp1.txt and info would be c:\temp2.txt

; %1% is $CmdLine[1]
; %2% is $CmdLine[2]
; %3% is $CmdLine[3]
; %4% is $CmdLine[4]
; %5% is $CmdLine[5]
; %6% is $CmdLine[6]
; etc
; $CmdLine[0] = the total amount of command lines given to the program.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

heres how its done

;; Example;;
AutoItSetOption ( "ExpandEnvStrings", 1) ;; Lets you use variables like in v2
$var = "blahblah"
MsgBox(0, "AutoIt", "Here is the variable: %var%")
Exit

this is really just a VERY basic example i guess. When you use %varname% be sure you put it between "..." cuz i dont know if %varname% will work outside the quotes, just like $varname wont work inside the quotes :whistle:

hope this helped

~~ Safeguarding The Land ~~

Link to comment
Share on other sites

;; Example;;

AutoItSetOption ( "ExpandEnvStrings", 1) ;; Does not Let you use variables like in v2

$var = "blahblah"

MsgBox(0, "AutoIt", "Here is the variable: %var%")

Exit

ExpandEnvStrings is made for enviromentals strings, not variables. like %path%

test the code, then use:

;; Example;;
AutoItSetOption ( "ExpandEnvStrings", 1);; Lets you use enviromental variables like in v2
MsgBox(0, "AutoIt", "Here is the variable: %path%")

if you want a variable, use a $ as in $x or $filename

if you want to use a preset Enviromental string, use %path% or one of the AutoIt ones already done like @ScriptName, @ScriptDir, @ScriptFullPath, @WorkingDir, @AutoItVersion, etc.

AutoIt3 has some differences, but once you use it, you will see how many advantages

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...