mark2004 Posted December 19, 2006 Posted December 19, 2006 I'm trying to figure out how to dynamically create a variable with the execute statement. The simple code example below does not set the variable $tempadd3 equal to 5 as I intended. Is this an improper use of the execute function??? If so, can I do what I am trying to do in a different way?? Dim $tempadd3 $counter=3 $tempstr="$tempadd" & $counter & "=5" ;;;creates the string "$tempadd3=5" Execute($tempstr) MsgBox(0,"",$tempadd3)
Thatsgreat2345 Posted December 19, 2006 Posted December 19, 2006 (edited) ??? Dim $tempadd3 $counter=3 $tempadd3 = Execute("$counter +2") MsgBox(0,"",$tempadd3) oÝ÷ ÚêܡצjG¬Ç°«l¡ëÞ®Øb²+-ç±jjezÞÅç.µæ®¶s`¢b33c¶Ó¢b33c·cÔWV7WFRgV÷C²b33c¶³gV÷C²²b33c·b26WBFò Edited December 19, 2006 by Thatsgreat2345
mark2004 Posted December 19, 2006 Author Posted December 19, 2006 What is so hard to understand? The code itself is just a simple way to illustrate the problem. I want to create the variables $var1, $var2......$varX and set them equal to something dynamically in the code. I will not know what X is until I process some information. It may be 5 or it may be 500. So, I need some way of looping through and creating/assigning values to the new $varX variables. Clear as mud right??...;>
xcal Posted December 19, 2006 Posted December 19, 2006 It'd probably be a lot easier to read to/from an array. How To Ask Questions The Smart Way
xcal Posted December 19, 2006 Posted December 19, 2006 I made this a good while back as an example for myself. I think this is what you're after. Keywords being Assign and Eval. For $i = 1 To 5 Assign('var' & $i, 'this is var' & $i) Next For $i = 1 To 7 If IsDeclared('var' & $i) Then MsgBox(0, '', Eval('var' & $i)) Else MsgBox(0, '', 'var' & $i & ' does not exist.') EndIf Next I've never actually ever had to do something like this before, though, and I still think you'd be better off reading to/from an array. How To Ask Questions The Smart Way
ptrex Posted December 19, 2006 Posted December 19, 2006 @mark2004 Look for my Dynamic functions in my signature. This demontrates exactly what the Execute command can do. Enjoy !! ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
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