locutus243 Posted March 27, 2006 Share Posted March 27, 2006 Hiya, I'm using a loop which looks up in a text file. When a certain condition is met then it writes information to a variable. But the condition can be met a few times so its always overwriting my original variable. Therefore I was wondering if it was possible to use a variable in a variable. (e.g. $UnRes & $ping = "Complete") I've included the portion of my script below. I want $UnRes to go up one each time so first time in the loop it writes to variable $UnRes1, then $UnRes2 etc... (This includes my attempt at it ($UnRes & $ping = "Time Travel", although this errors so it obviously doesn't work, thought I'd leave it in to give you an example of what I'm trying to do!) Any help greatly appreciated. Mark $ini = IniReadSectionNames("C:\temp\test.ini") $count = $ini[0] $ping = 1 Do $result = IniReadSection("C:\temp\test.ini", $ini[$ping]) $count2 = $result[0][0] $ping2 = 1 Do If $result[$ping2][1] = "Resolved" Then $UnRes & $ping = "Time Travel" EndIf $ping2 = $ping2 + 1 Until $ping2 = $count2 $ping = $ping + 1 Until $ping = $count Link to comment Share on other sites More sharing options...
Helge Posted March 27, 2006 Share Posted March 27, 2006 If I understand you correct you should check out Assign(). Link to comment Share on other sites More sharing options...
nfwu Posted March 27, 2006 Share Posted March 27, 2006 hate looking at code that can be written another easier to understand way... Rewriting it using For loops (and correcting your problem):$ini = IniReadSectionNames("C:\temp\test.ini") For $ping = 1 to $ini[0] $result = IniReadSection("C:\temp\test.ini", $ini[$ping]) For $ping2 = 1 to $result[0][0] If $result[$ping2][1] = "Resolved" Then Assign("UnRes"&$ping, "Time Travel") EndIf Next Next I think you should use arrays instead, though. #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
locutus243 Posted March 27, 2006 Author Share Posted March 27, 2006 Hiya, Assign function seems to work, should do anyway. I'm interested in the array idea, although not quite sure it would work here? Thanks Mark Link to comment Share on other sites More sharing options...
nfwu Posted March 27, 2006 Share Posted March 27, 2006 (edited) Here:$ini = IniReadSectionNames("C:\temp\test.ini") Dim $UnResArray[$ini[0]+1] For $ping = 1 to $ini[0] $result = IniReadSection("C:\temp\test.ini", $ini[$ping]) For $ping2 = 1 to $result[0][0] If $result[$ping2][1] = "Resolved" Then $UnResArray[$ping] = "Time Travel" EndIf Next Next $UnResArray[0] = $ini[0] NOTE: $UnResArray[0] is the length of the array. #) Edited March 27, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() 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