Psychobird25 Posted November 9, 2019 Posted November 9, 2019 (edited) I'm trying to get a bunch of variables with arrays that are setup like this (I know this input sucks - I really don't have a way around it. It's the way it was given to me). Local $data1 = [1000010, 41, 17] Local $data2 = [1000010, 41, 16] Local $data3 = [1000010, 40, 16] Local $data4 = [1000010, 39, 16] Local $data5 = [1000010, 38, 16] Into code which is like this: $math1 = -($y*100) + ($x*300) + 496 ConsoleWrite($math1) What I'm attempting to do is something like this, except in a For loop. $x = $data1[1] $y = $data1[2] $math1 = -($y*100) + ($x*300) + 496 ConsoleWrite($math1) $x = $data2[1] $y = $data2[2] $math1 = -($y*100) + ($x*300) + 496 ConsoleWrite($math1) $x = $data3[1] $y = $data3[2] $math1 = -($y*100) + ($x*300) + 496 ConsoleWrite($math1) Is there a way to get around the imposed limitation above where each variable is $data1, $data2, etc? Thanks. Edited November 9, 2019 by Psychobird25
Gianni Posted November 10, 2019 Posted November 10, 2019 (edited) do you want to use or don't want to use a "for next" loop ? Edited November 10, 2019 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Zedna Posted November 10, 2019 Posted November 10, 2019 (edited) Look at Eval() and/or Execute() https://www.autoitscript.com/autoit3/docs/functions/Eval.htm https://www.autoitscript.com/autoit3/docs/functions/Execute.htm Edited November 10, 2019 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Gianni Posted November 10, 2019 Posted November 10, 2019 .... better Execute() Local $data1 = [1000010, 41, 17] Local $data2 = [1000010, 41, 16] Local $data3 = [1000010, 40, 16] Local $data4 = [1000010, 39, 16] Local $data5 = [1000010, 38, 16] For $i = 1 To 5 $x = Execute('$data' & $i & '[1]') $y = Execute('$data' & $i & '[2]') $math1 = -($y * 100) + ($x * 300) + 496 ConsoleWrite($math1 & @CRLF) Next Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Psychobird25 Posted November 10, 2019 Author Posted November 10, 2019 11 minutes ago, Chimp said: .... better Execute() Local $data1 = [1000010, 41, 17] Local $data2 = [1000010, 41, 16] Local $data3 = [1000010, 40, 16] Local $data4 = [1000010, 39, 16] Local $data5 = [1000010, 38, 16] For $i = 1 To 5 $x = Execute('$data' & $i & '[1]') $y = Execute('$data' & $i & '[2]') $math1 = -($y * 100) + ($x * 300) + 496 ConsoleWrite($math1 & @CRLF) Next This works! Thanks
Gianni Posted November 10, 2019 Posted November 10, 2019 You are welcome Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
jchd Posted November 10, 2019 Posted November 10, 2019 You don't even need intermediate variables $x, $y, $math1: Local $data1 = [1000010, 41, 17] Local $data2 = [1000010, 41, 16] Local $data3 = [1000010, 40, 16] Local $data4 = [1000010, 39, 16] Local $data5 = [1000010, 38, 16] For $i = 1 To 5 ConsoleWrite(Execute("$data" & $i & "[1] * 300 - $data" & $i & "[2] * 100 + 496") & @LF) Next This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Nine Posted November 10, 2019 Posted November 10, 2019 (edited) Well, you don't even need to use Execute : Local $data = [[1000010, 41, 17],[1000010, 41, 16],[1000010, 40, 16],[1000010, 39, 16],[1000010, 38, 16]] For $i = 0 To UBound($data,1)-1 ConsoleWrite($data [$i][1]*300 - $data[$i][2]*100 + 496 & @LF) Next or you absolutely need to live with the data1...data5 Local $data1 = [1000010, 41, 17] Local $data2 = [1000010, 41, 16] Local $data3 = [1000010, 40, 16] Local $data4 = [1000010, 39, 16] Local $data5 = [1000010, 38, 16] Local $data = [$data1,$data2,$data3,$data4,$data5], $dt For $i = 0 To UBound($data,1)-1 $dt = $data[$i] ConsoleWrite($dt[1]*300 - $dt[2]*100 + 496 & @LF) Next Edited November 10, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
jchd Posted November 10, 2019 Posted November 10, 2019 Changing to input format is kinda cheating This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Nine Posted November 10, 2019 Posted November 10, 2019 Was just edited... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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