loki1982 Posted August 21, 2008 Share Posted August 21, 2008 ok say I have 4 variables $test1 $test2 $test3 $num and depending on the result I want to display one of them. Is it possible to do somthing like msgbox(0,"", $test & $num) so that it displays one of the test variables depending on what the var %num is? I really dont want to do an if or select statment Link to comment Share on other sites More sharing options...
gadzail Posted August 21, 2008 Share Posted August 21, 2008 I think "eval" can do the job.. search in autoit help . Link to comment Share on other sites More sharing options...
spudw2k Posted August 21, 2008 Share Posted August 21, 2008 (edited) Or Execute() For example. $test1 = "Yay" $num = 1 Execute('msgbox(0,"",$test' & $num & ')') Edited August 21, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
aslani Posted August 21, 2008 Share Posted August 21, 2008 (edited) I really dont want to do an if or select statmentI think you kinda have to since how do you intend to check each value and return the appropriate result?Edit:I completely missed what you're trying to do Hubertus72 got it right. Edited August 21, 2008 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
LarryDalooza Posted August 21, 2008 Share Posted August 21, 2008 Dim $test[3] $test[0] $test[1] $test[2] $num MsgBox(0,"",$test[$num]) Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
loki1982 Posted August 21, 2008 Author Share Posted August 21, 2008 $test1=111 $test2=222 $test3=333 $num=2 msgbox(0,"", Eval ("test" & $num)) This worked great. Then I tried to apply it to my code $dearraynum1 = 1 Dim $encryptmethod1[62] = ["1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","B","A","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] MsgBox(0,"",$dearraynum1) MsgBox(0,"",$encryptmethod1[0]) MsgBox(0,"", Eval ("encryptmethod" & $dearraynum1 & "[0]")) The first box displayed 1 like it should second 1 like it should third is blank Link to comment Share on other sites More sharing options...
loki1982 Posted August 21, 2008 Author Share Posted August 21, 2008 ok got it to work using msgbox(0,"",Execute ('$encryptmethod' & $dearraynum1 & ' [0]')) Still cant seem to reason why my first attempt wouldnt work. Link to comment Share on other sites More sharing options...
LarryDalooza Posted August 21, 2008 Share Posted August 21, 2008 oh boy... Arrays are the accepted "variable variable" solution... Execute() or Eval() are hacks. Lar AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
weaponx Posted August 21, 2008 Share Posted August 21, 2008 ok got it to work using msgbox(0,"",Execute ('$encryptmethod' & $dearraynum1 & ' [0]')) Still cant seem to reason why my first attempt wouldnt work. I think you totally are missing the point of the array. Look at Larry's post again. Do not use Execute. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now