Kyan Posted March 26, 2013 Share Posted March 26, 2013 Hi, I don't know what should be the proper title for this question I'm trying to create a way to change the output order by using a .ini file, the problem is using the correct "row" from the array and passing it as a variable, don't know how to explain it properly so here's what I done so far, and is not working: Global $ini = @ScriptDir & "\test.ini", $x IniWrite($ini,"Test","CustomView","#name# (#yold#) - #contry#") Dim $aListMembers[5][3] = [['19','Tiago','Brazil'], _ ['34','GUILERMO','Spain'], _ ['25','NICOLAO','Spain'], _ ['20','ELENA','Italy'], _ ['18','KRISTEN','Germany']] $sConfig = IniRead($ini,"Test","CustomView","#contry# - #name# (#yold#)") FileDelete($ini) $list = StringReplace($sConfig,"#contry#",$aListMembers[$x][2]) $list = StringReplace($sConfig,"#name#",$aListMembers[$x][1]) $list = StringReplace($sConfig,"#yold#",$aListMembers[$x][0]) For $x = 0 To UBound($aListMembers)-1 ConsoleWrite($list&@LF) Next Exit the array is not being read correctly, the output (from the code above) is: #name# (19) - #contry# #name# (19) - #contry# #name# (19) - #contry# #name# (19) - #contry# #name# (19) - #contry# the expected output is: Tiago (19) - Brazil GUILERMO (34) - Spain NICOLAO (25) - Spain ELENA (20) - Italy KRISTEN (18) - Germany This even possible to do? thanks Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
AutoBert Posted March 26, 2013 Share Posted March 26, 2013 If you want this result:Tiago (19) - Brazil GUILERMO (34) - Spain NICOLAO (25) - Spain ELENA (20) - Italy KRISTEN (18) - Germanymake it this way:Global $ini = @ScriptDir & "\test.ini", $x IniWrite($ini, "Test", "CustomView", "#name# (#yold#) - #contry#") Dim $aListMembers[5][3] = [['19', 'Tiago', 'Brazil'], _ ['34', 'GUILERMO', 'Spain'], _ ['25', 'NICOLAO', 'Spain'], _ ['20', 'ELENA', 'Italy'], _ ['18', 'KRISTEN', 'Germany']] $sConfig = IniRead($ini, "Test", "CustomView", "#contry# - #name# (#yold#)") FileDelete($ini) For $x = 0 To UBound($aListMembers) - 1 $list = StringReplace($sConfig, "#contry#", $aListMembers[$x][2]) $list = StringReplace($list, "#name#", $aListMembers[$x][1]) $list = StringReplace($list, "#yold#", $aListMembers[$x][0]) ConsoleWrite($list & @LF) Next Exit Link to comment Share on other sites More sharing options...
kylomas Posted March 26, 2013 Share Posted March 26, 2013 (edited) AutoBert, That addresses the array problem, however, it looks like the OP is trying to integrate an INI file. @DiOgO, INI file keys have to be unique. Is the following code what you are trying to do? expandcollapse popup#include <array.au3> ; this is how I would create the ini file. The numbers are suffixed to the keys because each key has to be unique local $ini = @ScriptDir & "\test.ini" Dim $aListMembers[5][3] = [['19','Tiago','Brazil'], _ ['34','GUILERMO','Spain'], _ ['25','NICOLAO','Spain'], _ ['20','ELENA','Italy'], _ ['18','KRISTEN','Germany']] iniwrite($ini,'CustomView','Total Users',ubound($aListMembers - 1)) ; used to provide a reference for # of entries to read For $x = 0 To UBound($aListMembers)-1 iniwrite($ini,'CustomView','Name' & stringformat('%03i',$x),$aListMembers[$x][1]) iniwrite($ini,'CustomView','Age' & stringformat('%03i',$x),$aListMembers[$x][0]) iniwrite($ini,'CustomView','Country' & stringformat('%03i',$x),$aListMembers[$x][2]) Next shellexecute($ini) ; this is how you can read the ini file local $total_users = iniread($ini,'CustomView','Total Users',0) if $total_users = 0 then msgbox(0,'ERROR','Total Users key not found') Exit endif ; display all users and values for $1 = 0 to $total_users- 1 ConsoleWrite(stringformat('%-30s%-30s%-30s',iniread($ini,'CustomView','Name' & stringformat('%03i',$1),0), _ iniread($ini,'CustomView','Age' & stringformat('%03i',$1),0), _ iniread($ini,'CustomView','Country' & stringformat('%03i',$1),0)) & @crlf) next kylomas edit:spelling - wrong code posted...duh! Edited March 26, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Kyan Posted March 26, 2013 Author Share Posted March 26, 2013 If you want this result:Tiago (19) - Brazil GUILERMO (34) - Spain NICOLAO (25) - Spain ELENA (20) - Italy KRISTEN (18) - Germanymake it this way:Global $ini = @ScriptDir & "\test.ini", $x IniWrite($ini, "Test", "CustomView", "#name# (#yold#) - #contry#") Dim $aListMembers[5][3] = [['19', 'Tiago', 'Brazil'], _ ['34', 'GUILERMO', 'Spain'], _ ['25', 'NICOLAO', 'Spain'], _ ['20', 'ELENA', 'Italy'], _ ['18', 'KRISTEN', 'Germany']] $sConfig = IniRead($ini, "Test", "CustomView", "#contry# - #name# (#yold#)") FileDelete($ini) For $x = 0 To UBound($aListMembers) - 1 $list = StringReplace($sConfig, "#contry#", $aListMembers[$x][2]) $list = StringReplace($list, "#name#", $aListMembers[$x][1]) $list = StringReplace($list, "#yold#", $aListMembers[$x][0]) ConsoleWrite($list & @LF) Next Exit using your way works, thx AutoBert, That addresses the array problem, however, it looks like the OP is trying to integrate an INI file. @DiOgO, INI file keys have to be unique. Is the following code what you are trying to do? expandcollapse popup#include <array.au3> ; this is how I would create the ini file. The numbers are suffixed to the keys because each key has to be unique local $ini = @ScriptDir & "\test.ini" Dim $aListMembers[5][3] = [['19','Tiago','Brazil'], _ ['34','GUILERMO','Spain'], _ ['25','NICOLAO','Spain'], _ ['20','ELENA','Italy'], _ ['18','KRISTEN','Germany']] iniwrite($ini,'CustomView','Total Users',ubound($aListMembers - 1)) ; used to provide a reference for # of entries to read For $x = 0 To UBound($aListMembers)-1 iniwrite($ini,'CustomView','Name' & stringformat('%03i',$x),$aListMembers[$x][1]) iniwrite($ini,'CustomView','Age' & stringformat('%03i',$x),$aListMembers[$x][0]) iniwrite($ini,'CustomView','Country' & stringformat('%03i',$x),$aListMembers[$x][2]) Next shellexecute($ini) ; this is how you can read the ini file local $total_users = iniread($ini,'CustomView','Total Users',0) if $total_users = 0 then msgbox(0,'ERROR','Total Users key not found') Exit endif ; display all users and values for $1 = 0 to $total_users- 1 ConsoleWrite(stringformat('%-30s%-30s%-30s',iniread($ini,'CustomView','Name' & stringformat('%03i',$1),0), _ iniread($ini,'CustomView','Age' & stringformat('%03i',$1),0), _ iniread($ini,'CustomView','Country' & stringformat('%03i',$1),0)) & @crlf) next kylomas edit:spelling - wrong code posted...duh! Hi kylomas I read the array from other place and show the output as the same order as it is read from the ini file, in the example the order is: "#name# (#yold#) - #contry#", but can be changed to other like "#contry#, #name# (#yold#)", etc... The idea is change the order(or number) of results Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
kylomas Posted March 26, 2013 Share Posted March 26, 2013 DiOgO, Cool, my mistake, good luck. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Kyan Posted March 26, 2013 Author Share Posted March 26, 2013 DiOgO,Cool, my mistake, good luck.kylomasno problem if you know a way to "byref" variables it would improve script speed props Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted March 26, 2013 Author Share Posted March 26, 2013 Is not possible to replace it with "pointers" and use stringformat? (I'm looking into strformat help file, and is more complicated than SRE's :s) Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
kylomas Posted March 26, 2013 Share Posted March 26, 2013 DiOgO, stringformat is nowhere near a complicated a regexp...what are you trying that isn't working? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Kyan Posted March 26, 2013 Author Share Posted March 26, 2013 DiOgO,stringformat is nowhere near a complicated a regexp...what are you trying that isn't working?kylomasit is, but seems a noob's way Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better 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