spac3m0nk3y Posted June 28, 2007 Share Posted June 28, 2007 I have a listbox containing items like so: JDM BCC PAJ REP I want to replace each item in the listbox with a corresponding item in an INI file: INI: [Names] JDM=Mack, Joe (JDM) BCC=Carver, Brian (BCC) PAJ=Johnson, Paul (PAJ) REP=Plink, Ralph (REP) So, after it's done, my listbox will have: Mack, Joe (JDM) Carver, Brian (BCC) Johnson, Paul (PAJ) Plink, Ralph (REP) How do I do this? Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
evilertoaster Posted June 28, 2007 Share Posted June 28, 2007 GUICtrlSetData() is used to change list items. The values can be read in using IniRead()'s. Link to comment Share on other sites More sharing options...
spac3m0nk3y Posted June 28, 2007 Author Share Posted June 28, 2007 GUICtrlSetData() is used to change list items. The values can be read in using IniRead()'s.Perhaps I didn't explain what I'm looking for well enough.I'm looking for instruction on how to compare the items in my listbox to those in the INI file to get the full name and then place the full name in the listbox. Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
Josbe Posted June 28, 2007 Share Posted June 28, 2007 Perhaps I didn't explain what I'm looking for well enough. I'm looking for instruction on how to compare the items in my listbox to those in the INI file to get the full name and then place the full name in the listbox.Like evilertoaster says: Comparing: Read the values stored in the INI file and listbox [GUICTRLRead()], use the '=' operator or StringInStr(). Replacing: GUICtrlSetData() or some UDF function(GuiList UDF) for this task. You need some help in the code? Please, try post your code first. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
spac3m0nk3y Posted June 28, 2007 Author Share Posted June 28, 2007 Here's the code that I have so far: Func OnList() GUICtrlSetData($lblStatus, "Getting Providers...") $dictationPath = @UserProfileDir & "\Desktop\Dictation\" $provArray = _FileListToArrayEx($dictationPath, '*.dss') If (Not IsArray($provArray)) Or (@error = 1) Then MsgBox(262208, "List Providers Error", "No Files\Folders Found. ") Return EndIf $pArray = '';$pArray has to be declared first since are using &= below to add to it For $x = 1 To $provArray[0] ; for loop to place the files in the list. $pArray &= StringLeft($provArray[$x], 3) & Chr(1); Notice &= to add each element to $pArray and notice & Chr(1) to use a delimiter for the next array Next $pArray = StringSplit(StringTrimRight($pArray, 0), Chr(1));StringTrimRight() is used to get rid of the last delimiter or we will have an empty element. _ArrayUnique($pArray, Chr(1), 1);Depending on which _ArrayUnique() you are using, you may have to do: $pArray = _ArrayUnique($pArray) GUICtrlSetData($lstProviders, $pArray) ;Now we have to loop through each one to make it one string to add to the $lstproviders... of course, I can only assume that $lstProviders is an edit GUICtrlSetData($lstProviders, '');Empty the control $lstProviders $sHoldNewList = '';We will use this to hold the new list. For $iCC = 1 To UBound($pArray) - 1 $sHoldNewList &= $pArray[$iCC] & Chr(124) Next $sHoldNewList = StringTrimRight($sHoldNewList, 2);@CRLF is 2 Chars, have to trim the fat off the ends GUICtrlSetData($lstProviders, $sHoldNewList) $provNames = IniReadSection(@ScriptDir & "\providers.ini", "Names") ;Read provider names into a 2D array ; Code to place names into Listbox goes here. EndFunc Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
spac3m0nk3y Posted June 29, 2007 Author Share Posted June 29, 2007 Bump. Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 29, 2007 Moderators Share Posted June 29, 2007 Bump.That code looks familiar You have to read it into an array (the section) $inireadsection = IniReadSection()... Then you have to read the Control List into an array $splitcontrol = StringSplit(StringStripCR(GUICtrlRead(Control)), @LF), then go through the Section If $inireadsection[n][0] = $splitcontrol[n] Then do something. There's your foundation... look forward to seeing what you come up with. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
spac3m0nk3y Posted June 29, 2007 Author Share Posted June 29, 2007 That code looks familiar You have to read it into an array (the section) $inireadsection = IniReadSection()... Then you have to read the Control List into an array $splitcontrol = StringSplit(StringStripCR(GUICtrlRead(Control)), @LF), then go through the Section If $inireadsection[n][0] = $splitcontrol[n] Then do something. There's your foundation... look forward to seeing what you come up with. Heh, I wonder why it looks familiar. Anyway, let me bang on it for a while and see what I can do. I will post whatever I come up with here. Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
spac3m0nk3y Posted June 29, 2007 Author Share Posted June 29, 2007 Ugh, I totally suck at this, I'm coming up empty here. ;--------------- Functions --------------- Func OnList() GUICtrlSetData($lblStatus, "Getting Providers...") $dictationPath = @UserProfileDir & "\Desktop\Dictation\" $provArray = _FileListToArrayEx($dictationPath, '*.dss') If (Not IsArray($provArray)) Or (@error = 1) Then MsgBox(262208, "List Providers Error", "No Files\Folders Found. ") Return EndIf $pArray = '';$pArray has to be declared first since are using &= below to add to it For $x = 1 To $provArray[0] ; for loop to place the files in the list. $pArray &= StringLeft($provArray[$x], 3) & Chr(1); Notice &= to add each element to $pArray and notice & Chr(1) to use a delimiter for the next array Next $pArray = StringSplit(StringTrimRight($pArray, 0), Chr(1));StringTrimRight() is used to get rid of the last delimiter or we will have an empty element. _ArrayUnique($pArray, Chr(1), 1);Depending on which _ArrayUnique() you are using, you may have to do: $pArray = _ArrayUnique($pArray) ;Now we have to loop through each one to make it one string to add to the $lstproviders... of course, I can only assume that $lstProviders is an edit ;GUICtrlSetData($lstProviders, '');Empty the control $lstProviders ;$sHoldNewList = '';We will use this to hold the new list. ;For $iCC = 1 To UBound($pArray) - 1 ; $sHoldNewList &= $pArray[$iCC] & Chr(124) ;Next ;$sHoldNewList = StringTrimRight($sHoldNewList, 2);@CRLF is 2 Chars, have to trim the fat off the ends ;0GUICtrlSetData($lstProviders, $sHoldNewList) GUICtrlSetData($lstProviders, '');Empty the control $lstProviders $provNames = IniReadSection(@ScriptDir & "\providers.ini", "Names") ;Read provider names into a 2D array ;_ArrayDisplay($provNames) For $z = 1 To UBound($pArray) - 1 If $provNames[$z][0] = $pArray[$z] Then CtrlSetData($lstProviders, $provNames[0][$z]) EndIf Next EndFunc --> Array variable has incorrect number of subscripts or subscript dimension range exceeded I have no idea why this is happening, although, I guess if I knew more about arrays I might be able to figure it out, but I've gone through what seems like a hundred examples and I'm even more confused. Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
Josbe Posted June 29, 2007 Share Posted June 29, 2007 Ugh, I totally suck at this, I'm coming up empty here. ;--------------- Functions --------------- Func OnList() GUICtrlSetData($lblStatus, "Getting Providers...") $dictationPath = @UserProfileDir & "\Desktop\Dictation\" $provArray = _FileListToArrayEx($dictationPath, '*.dss') If (Not IsArray($provArray)) Or (@error = 1) Then MsgBox(262208, "List Providers Error", "No Files\Folders Found. ") Return EndIf $pArray = '';$pArray has to be declared first since are using &= below to add to it For $x = 1 To $provArray[0] ; for loop to place the files in the list. $pArray &= StringLeft($provArray[$x], 3) & Chr(1); Notice &= to add each element to $pArray and notice & Chr(1) to use a delimiter for the next array Next $pArray = StringSplit(StringTrimRight($pArray, 0), Chr(1));StringTrimRight() is used to get rid of the last delimiter or we will have an empty element. _ArrayUnique($pArray, Chr(1), 1);Depending on which _ArrayUnique() you are using, you may have to do: $pArray = _ArrayUnique($pArray) ;Now we have to loop through each one to make it one string to add to the $lstproviders... of course, I can only assume that $lstProviders is an edit ;GUICtrlSetData($lstProviders, '');Empty the control $lstProviders ;$sHoldNewList = '';We will use this to hold the new list. ;For $iCC = 1 To UBound($pArray) - 1 ; $sHoldNewList &= $pArray[$iCC] & Chr(124) ;Next ;$sHoldNewList = StringTrimRight($sHoldNewList, 2);@CRLF is 2 Chars, have to trim the fat off the ends ;0GUICtrlSetData($lstProviders, $sHoldNewList) GUICtrlSetData($lstProviders, '');Empty the control $lstProviders $provNames = IniReadSection(@ScriptDir & "\providers.ini", "Names") ;Read provider names into a 2D array ;_ArrayDisplay($provNames) For $z = 1 To UBound($pArray) - 1 If $provNames[$z][0] = $pArray[$z] Then CtrlSetData($lstProviders, $provNames[0][$z]) EndIf Next EndFunc --> Array variable has incorrect number of subscripts or subscript dimension range exceeded I have no idea why this is happening, although, I guess if I knew more about arrays I might be able to figure it out, but I've gone through what seems like a hundred examples and I'm even more confused. Looks something wrong in $provNames[$z][0] variable, maybe it's exceeding its dimension. Check it. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 30, 2007 Share Posted June 30, 2007 Looks something wrong in $provNames[$z][0] variable, maybe it's exceeding its dimension. Check it. Well, this is trimming zero characters from the right: StringTrimRight($pArray, 0)oÝ÷ ٩ݶ¬$²X¤{*.ëޮǶ¬¹»®*mÓ~³ÒÚ4Ó~³jëh×6 If $provNames[$z][0] = $pArray[$z] Then CtrlSetData($lstProviders, $provNames[0][$z]) EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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