JetlagJad Posted June 27, 2009 Share Posted June 27, 2009 Func SplitVariables() Local $Accounts[999] $SplitAccounts = StringSplit('a=b/c=d', '/') For $i = 1 To $SplitAccounts[0] $Accounts[$i] = StringSplit($SplitAccounts[$i], '=') Next MsgBox(0, 'Accounts:', $Accounts[1][1]) EndFunc Please help, I'm not sure why but $Accounts[1][1] should be returning 'a' but it isn't Thanks in advance! Link to comment Share on other sites More sharing options...
Developers Jos Posted June 27, 2009 Developers Share Posted June 27, 2009 You cannot have a receiving one dimensional Array and then expect it to become 2 dimensional after doing a stringsplit. try Local $Accounts[999] $SplitAccounts = StringSplit('a=b/c=d', '/') For $i = 1 To $SplitAccounts[0] $tAccounts = StringSplit($SplitAccounts[$i], '=') MsgBox(0, 'Accounts:', $Accounts[1] & "<=>" & $Accounts[2] ) Next Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BrettF Posted June 27, 2009 Share Posted June 27, 2009 Please look at your code again, starting with declaring a single dimension array and calling it as a 2D array... Doesn't work like that. What I think you meant to do: SplitVariables() Func SplitVariables() Local $Accounts[999][99] $SplitAccounts = StringSplit('a=b/c=d', '/') For $i = 1 To $SplitAccounts[0] $split = StringSplit($SplitAccounts[$i], '=') For $x = 1 to $split[0] $Accounts[$i][$x] = $split[$x] Next Next MsgBox(0, 'Accounts:', $Accounts[1][1]) EndFunc ;==>SplitVariables Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
JetlagJad Posted June 27, 2009 Author Share Posted June 27, 2009 You cannot have a receiving one dimensional Array and then expect it to become 2 dimensional after doing a stringsplit. try Local $Accounts[999] $SplitAccounts = StringSplit('a=b/c=d', '/') For $i = 1 To $SplitAccounts[0] $tAccounts = StringSplit($SplitAccounts[$i], '=') MsgBox(0, 'Accounts:', $Accounts[1] & "<=>" & $Accounts[2] ) Next Jos Thanks, but this isn't quite what I was looking for, in this script, $Accounts[1] and $Accounts[2] are replaced every time it loops. Please look at your code again, starting with declaring a single dimension array and calling it as a 2D array... Doesn't work like that. What I think you meant to do: SplitVariables() Func SplitVariables() Local $Accounts[999][99] $SplitAccounts = StringSplit('a=b/c=d', '/') For $i = 1 To $SplitAccounts[0] $split = StringSplit($SplitAccounts[$i], '=') For $x = 1 to $split[0] $Accounts[$i][$x] = $split[$x] Next Next MsgBox(0, 'Accounts:', $Accounts[1][1]) EndFunc ;==>SplitVariables Cheers, Brett Thanks, this worked perfect Irrelevant, but I live near Brisbane too Go Australia 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