supersonic Posted July 21, 2009 Share Posted July 21, 2009 (edited) Hi! I'm trying to create several variables during script runtime: For $i = 1 To 3 $dummy & $i = "test_string" ConsoleWrite($dummy & $i & @CRLF) Next This should result in three different variables: $dummy1 $dummy2 $dummy3 Any ideas? Greets, -supersonic. Edited July 21, 2009 by supersonic Link to comment Share on other sites More sharing options...
KaFu Posted July 21, 2009 Share Posted July 21, 2009 Why not use an array? Global $dummy[3] For $i = 0 To 2 $dummy[$i] = "test_string" & $i+1 ConsoleWrite($dummy[$i] & @CRLF) Next OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Authenticity Posted July 21, 2009 Share Posted July 21, 2009 Opt("ExpandVarStrings", 1) For $i = 1 To 3 Assign("dummy$i$", Random(-5, 5)) ConsoleWrite(Eval('dummy$i$') & @LF) Next ConsoleWrite($dummy1 & @TAB & $dummy2 & @TAB & $dummy3 & @LF) The AutoIt Check will generate an error, it's a completely valid script though, but not wise one. Link to comment Share on other sites More sharing options...
supersonic Posted July 22, 2009 Author Share Posted July 22, 2009 Good idea. I modified the script using an array. Why not use an array? Global $dummy[3] For $i = 0 To 2 $dummy[$i] = "test_string" & $i+1 ConsoleWrite($dummy[$i] & @CRLF) Next 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