Jump to content

Recommended Posts

Posted

Hi,

I want to get words attribued to variables for example :

$01="FireFox"
;If user enter "FireFox" so script will display $01

I know how to do conversely but im only interesed by this way...

Thanks for anyhelp :)

Posted

Hi,

I want to get words attribued to variables for example :

$01="FireFox"
;If user enter "FireFox" so script will display $01

I know how to do conversely but im only interesed by this way...

Thanks for anyhelp :)

Sounds like an associative array (Scripting.Dictionary object). Search the forum for many examples.

:o

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Sounds like an associative array (Scripting.Dictionary object). Search the forum for many examples.

:)

I agree that a dictionary is probably the best route. But for some simple case it could be sufficient to use Assign and Eval.

;associate "FireFox" with some text or value

Assign("FireFox","$01");firefox is to be represented by "$01"
$text = "FireFox"
ConsoleWrite("method 1 gives " & Eval($text) & @CRLF)

;or if you want the value of variable $01 assigned to "FireFox" then
Assign("FireFox","01"); FireFox is associated with the value of $01

$01 = 245
$text = "FireFox"

ConsoleWrite("Method 2 gives " &Eval(Eval($text)) & @CRLF)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

A slightly more dynamic version of the Assign/Eval idea.

Works if your variables are all numerically assigned

$01="FireFox"
$02 = "IE"
$03 = "Chrome"

;If user enter "FireFox" so script will display $01
For $i = 1 to 3
    ConsoleWrite(Eval("0" & $i) & @crlf)
    Assign(Eval("0" & $i),"0" & $i)
Next

While 1
$input = InputBox("Input","Type something")
If @error = 1 then Exit

If IsDeclared($input) Then
    MsgBox(0,"","You entered the text for the variable $" & Eval($input))
Else
    MsgBox(0,"","No matching variable found")
EndIf
WEnd

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
×
×
  • Create New...