Jump to content

Strange List Box malfunction...


LetsAuto
 Share

Recommended Posts

In my program, i have a list box that will have at most 2 strings inside of it. The information from the first line is being written to the proper text file, the information from the second line is getting ignored and not written to my text file. if I re-arrange them its always ONLY data from line 1 and NEVER data from line 2.. I need both lines to be written to independant text files which works, but its only writing line 1 to the text file.. I used the exact same code for each instance so there is no code variation aside from the variables to be written to a text document.. If anyone could help that would be excellent. Thanks.

Link to comment
Share on other sites

  • Moderators

LetsAuto,

It is obvious that the problem is on line......

Oh wait a minute, we have no code to debug. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

#include 
#include 
#include 
#include 
#include 

#region ### START Koda GUI section ### Form=f:autoit3testingsautowizardform1.kxf
$Form1_1 = GUICreate("CALs", 752, 447, 425, 188)
$serverButton = GUICtrlCreateButton("Server", 240, 56, 105, 41)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$deskButton = GUICtrlCreateButton("Desktop", 400, 56, 105, 41)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$addedListBox = GUICtrlCreateList("", 432, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$finishButton = GUICtrlCreateButton("Finish", 320, 336, 124, 49)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$addButton = GUICtrlCreateButton("--->", 336, 184, 75, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$deleteButton = GUICtrlCreateButton("<---", 336, 240, 75, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;; in log, updates list box ITEM 1 ONLY, ignores update for ITEM 3 ;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;server variables
$sServer1 = "aaaaaaaaaaaaaaa"
$sServer2 = "bbbbbbbbbbbbbbbbbb"
$sServer3 = "ccccccccccccccc"
$sServer4 = "dddddddddddddddddddd"
$sServer = ""
;;;
$aServer1 = "eeeeeeeeeeeeeeeeeeeee"
$aServer2 = "fffffffffffffffffffffffffffff"
$aServer3 = "ggggggggggggggggggggg"
$aServer4 = "hhhhhhhhhhhhhhhhhhhhh"
$aServer = ""
;;;
$dServer1 = "iiiiiiiiiiiiiiiiii"
$dServer = ""
;;;
$iServer1 = "jjjjjjjjjjjjjjjjjjjjjjjjjj"
$iServer2 = "kkkkkkkkkkkkkkkkkkkkkkkkk"
$iServer = ""
;;;;;;;

;;;;;;;desktop variables
$sDesk1 = "lllllllllllllllllllllllll"
$sDesk2 = "mmmmmmmmmmmmmmmmmmmm"
$sDesk3 = "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"
$sDesk4 = "oooooooooooooooooooooooo"
$sDesk5 = "pppppppppppppppppppppp"
$sDesk6 = "qqqqqqqqqqqqqqqqqqqqqqq"
$sDesk = ""
;;;
$aDesk1 = "rrrrrrrrrrrrrrrrrrrrrrrrrrr"
$aDesk2 = "sssssssssssssssssssssss"
$aDesk = ""
;;;
$dDesk1 = "tttttttttttttttttttttttt"
$dDesk = ""
;;;
$iDesk1 = "uuuuuuuuuuuuuuuuuuuuuuuuuu"
$iDesk2 = "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
$iDeskTen = "wwwwwwwwwwwwwwwwwwwwww"
$iDesk = ""
;;;
$wDesk1 = "xxxxxxxxxxxxxxxxxxxxxxxx"
$wDesk = ""
;;;;;;;

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $serverButton
$sValue = IniRead("C:IanLogTestradioButton.ini", "Brand", "Radio Checked", "Error!")
Switch $sValue ;;;;;;;;;;;;;;;;;;;;;;;;;populates for servers
Case "0" ;;;syam
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "1 sServer1")
_GUICtrlListBox_InsertString($calListBox, "5 sServer2")
_GUICtrlListBox_InsertString($calListBox, "10 sServer3")
_GUICtrlListBox_InsertString($calListBox, "20 sServer4")
Case "1" ;;;acer
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "1 aServer1")
_GUICtrlListBox_InsertString($calListBox, "1 aServer2")
_GUICtrlListBox_InsertString($calListBox, "1 aServer3")
_GUICtrlListBox_InsertString($calListBox, "1 aServer4")
Case "2" ;;;depo
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "5 dServer1")
Case "3" ;;;itautec
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "1 iServer1")
_GUICtrlListBox_InsertString($calListBox, "5 iServer2")
Case Else ;;disable server button for wipro
GUICtrlSetState($serverButton, $GUI_DISABLE)
EndSwitch
Case $deskButton
$sValue = IniRead("C:IanLogTestradioButton.ini", "Brand", "Radio Checked", "Error!")
Switch $sValue ;;;;;;;;;;;;;;;;;;;;;;;; populates for desktops
Case "0" ;;;syam
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "1 sDesk1")
_GUICtrlListBox_InsertString($calListBox, "5 sDesk2")
_GUICtrlListBox_InsertString($calListBox, "10 sDesk2")
_GUICtrlListBox_InsertString($calListBox, "20 sDesk4")
_GUICtrlListBox_InsertString($calListBox, "50 sDesk5")
_GUICtrlListBox_InsertString($calListBox, "100 sDesk6")
Case "1" ;;;acer
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "5 aDesk1")
_GUICtrlListBox_InsertString($calListBox, "5 aDesk2")
Case "2" ;;;depo
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "5 dDesk1")
Case "3" ;;;itautec
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "1 iDesk1")
_GUICtrlListBox_InsertString($calListBox, "5 iDesk2")
Case "5" ;;;wipro
GUICtrlDelete($calListBox)
$calListBox = GUICtrlCreateList("", 56, 112, 260, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
_GUICtrlListBox_InsertString($calListBox, "1 wDesk")
EndSwitch
Case $addButton
_LeftToRight($calListBox, $addedListBox)
Case $deleteButton
delete($addedListBox, $calListBox)
Case $finishButton
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardstep4.au3")
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
;;;server Log;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ $sValue = IniRead("C:IanLogTestradioButton.ini", "Brand", "Radio Checked", "Error!")
;~ Switch $sValue
;~ Case "0" ;;;s
If $sServer = _GUICtrlListBox_FindString($addedListBox, "1 sServer1", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $sServer1)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sServer = _GUICtrlListBox_FindString($addedListBox, "5 sServer2", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sServer2)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sServer = _GUICtrlListBox_FindString($addedListBox, "10 sServer3", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sServer3)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sServer = _GUICtrlListBox_FindString($addedListBox, "20 sServer4", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sServer4)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "1" ;;;a
If $aServer = _GUICtrlListBox_FindString($addedListBox, "1 aServer1", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $aServer1)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $aServer = _GUICtrlListBox_FindString($addedListBox, "1 aServer2", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $aServer2)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $aServer = _GUICtrlListBox_FindString($addedListBox, "1 aServer3", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $aServer3)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $aServer = _GUICtrlListBox_FindString($addedListBox, "1 aServer4", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $aServer4)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "2" ;;;d
If $dServer = _GUICtrlListBox_FindString($addedListBox, "5 dServers", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $dServer1)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "3" ;;;i
If $iServer = _GUICtrlListBox_FindString($addedListBox, "1 iServer1", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $iServer1)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $iServer = _GUICtrlListBox_FindString($addedListBox, "5 iServer2", True) Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $iServer2)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ EndSwitch
;;;desktop Log;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ $sValue = IniRead("C:IanLogTestradioButton.ini", "Brand", "Radio Checked", "Error!")
;~ Switch $sValue
;~ Case "0" ;;;s
If $sDesk = _GUICtrlListBox_FindString($addedListBox, "1 sDesk1", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $sDesk1)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sDesk = _GUICtrlListBox_FindString($addedListBox, "5 sDesk2", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sDesk2)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sDesk = _GUICtrlListBox_FindString($addedListBox, "10 sDesk3", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sDesk3)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sDesk = _GUICtrlListBox_FindString($addedListBox, "20 sDesk4", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sDesk4)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sDesk = _GUICtrlListBox_FindString($addedListBox, "50 sDesk5", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sDesk5)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $sDesk = _GUICtrlListBox_FindString($addedListBox, "100 sDesk6", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sDesk6)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "1" ;;;a
If $aDesk = _GUICtrlListBox_FindString($addedListBox, "5 aDesk1", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $aDesk1)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $aDesk = _GUICtrlListBox_FindString($addedListBox, "5 aDesk2", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $aDesk2)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "2" ;;;d
If $dDesk = _GUICtrlListBox_FindString($addedListBox, "5 dDesk1", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $dDesk1)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "3" ;;;i
If $iDesk = _GUICtrlListBox_FindString($addedListBox, "1 iDesk1", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $iDesk1)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf $iDesk = _GUICtrlListBox_FindString($addedListBox, "5 iDesk2", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $iDesk2)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ Case "5" ;;;w
If $wDesk = _GUICtrlListBox_FindString($addedListBox, "1 wDesk", True) Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $wDesk1)
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf
;~ EndSwitch
EndSwitch
WEnd


;;;;;;;;;;;;;functions and button operations;;;;;;;;;;;;
Func _LeftToRight(Const $list, Const $addlist)
Local $sRead
$sRead = GUICtrlRead($list)
ConsoleWrite($sRead & @CR)
If $sRead = "" Then
MsgBox(16 + 262144, @ScriptName, "No value selected!")
Else
ConsoleWrite(_GUICtrlListBox_DeleteString($list, _GUICtrlListBox_FindString($list, $sRead, True)) & @CR)
ConsoleWrite(_GUICtrlListBox_AddString($addlist, $sRead) & @CR)
EndIf
EndFunc ;==>_LeftToRight

Func delete(Const $list, Const $rmvlist)
Local $sRead
$sRead = GUICtrlRead($list)
ConsoleWrite($sRead & @CR)
If $sRead = "" Then
MsgBox(16 + 262144, @ScriptName, "No value selected!")
Else
ConsoleWrite(_GUICtrlListBox_DeleteString($list, _GUICtrlListBox_FindString($list, $sRead, True)) & @CR)
ConsoleWrite(_GUICtrlListBox_AddString($rmvlist, $sRead) & @CR)
EndIf
EndFunc ;==>delete

.... its long just because its extremely repetative

Link to comment
Share on other sites

  • Moderators

LetsAuto,

Be reasonable - I am willing to help but I need some pointers. ;)

Whereabouts are the problem lines? I see multiple FileWriteLine commands in an almost uncommented script which does not even fill the listboxes when I run it. :wacko:

Which lines are not working? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

ohhhh its not filling the list boxes for you because thats dependant on a separate script/: sorry i forgot about that... well basically its some type of logical error somewhere... i mean the list boxes work perfectly fine in my other scripts, but for some reason its not working, there are no "problem lines" per say, because the program functions, but logically its not running the Write command... what is posted is the exact code im having trouble with.. this is the only time that i try to write separate information from a single text box to multiple files.. but thinking about it and how to explain it to you, i think i could just write it to a single document with a little foot note telling the user which encrypted password is which, for you itsjust those letters in the early variables..

Link to comment
Share on other sites

Without the INI file it's hard to see exactly what you're doing here, but if there is more than one possible, for example $sServer##, in the list, it's only going to write the first one it finds to the file because of the way the If statements are written.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

LetsAuto,

thats dependant on a separate script/: sorry i forgot about that

I suggest you post a small reproducer script that shows the same symptoms - without a working script to play with we are just whistling in the dark. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

so, @BrewManNH, why are my if statements making it so only line 1 of the list box will be read? because i guess thats where the error is.. i need both lines to be read.. and i just tried this.....

FileDelete("C:IanLogTestcalLog.log")
$line1 = _GUICtrlListBox_GetText($addedListBox, 0)
$line2 = _GUICtrlListBox_GetText($addedListBox, 1)
$logdir = "C:IanLogTest"
$logfile = $logdir & "calLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $line1& @CRLF &$line2)
FileWriteLine($file, @CRLF)
FileClose($file)

if FileReadLine("C:IanLogTestcalLog.log", 1) = "1 sDesktop1" Then; Or FileReadLine("C:IanLogTestcalLog.log", 2) = "1 sDesktop1" Then
FileDelete("C:IanLogTestcalDeskLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calDeskLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
FileWriteLine($file, $sDeskOne)
FileWriteLine($file, @CRLF)
FileClose($file)
ElseIf FileReadLine("C:IanLogTestcalLog.log", 2) = "1 sServer1" Then; Or FileReadLine("C:IanLogTestcalLog.log", 2) = "1 sServer1" Then
FileDelete("C:IanLogTestcalServerLog.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "calServerLog.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
FileWriteLine($file, "fish")
FileWriteLine($file, @CRLF)
FileClose($file)
EndIf

instead of my if statements, and it is reading the list box, but when i have the "ElseIf File Read Line(...., 2)" it reads line 2.. but when i tell it to write the variable to another text document -in this copy i have it writing the word "fish"- it does not write anything to the new text document

Link to comment
Share on other sites

Your original If statements only checked for each type of string once, it would find the first match then drop through to the next If statement.

Here's a small reproducer that demonstrates how to get all the text from the list box and deal with it one line at a time. I'm sure there's a much simpler way of going about this, but this is what I came up with on the spur of the moment.

Run this in Scite and watch the console output when you hit the List Contents button.

#include <GUIConstantsEx.au3>
#include <GUIListbox.au3>
Example()

Func Example()
    Local $MESSAGE = "The following buttons have been clicked|More Stuff|Even more stuff"
    Local $add, $clear, $mylist, $close, $msg
    Local $aArray[1], $Text
    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

    $add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $MESSAGE)
    $close = GUICtrlCreateButton("List contents", 64, 160, 175, 25)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()

        Select
            Case $msg = $add
                GUICtrlSetData($mylist, "You clicked button No1|")
            Case $msg = $clear
                GUICtrlSetData($mylist, "")
            Case $msg = $close
                Local $Count = _GUICtrlListBox_GetCount($mylist)
                ReDim $aArray[$Count]
                For $i = 0 To  $Count - 1
                    $Text = _GUICtrlListBox_GetText($mylist, $i)
                    Switch $Text
                        Case "You clicked button No1"
                            ConsoleWrite("Clicked button #1" & @CRLF)
                        Case "More stuff"
                            ConsoleWrite("Stuff" & @CRLF)
                        Case "buttons that have been clicked"
                            ConsoleWrite("Buttons have been clicked" & @CRLF)
                        Case "Even more stuff"
                            ConsoleWrite("Even more stuff" & @CRLF)
                        Case "The following buttons have been clicked"
                            ConsoleWrite("Following buttons clicked" & @CRLF)
                    EndSwitch
                Next

                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

okay, i think I understand what youre saying.. so basically my if statements arent running both, its only looking for one case or the other.. so should i put it all inside of a single Switch? ie... Switch (my ini.read thing) then case "0" look for desktops and servers

case "1"

look for desktops2 and servers2....

something like that?

Link to comment
Share on other sites

You should read the lines of the listbox one at a time. Compare what you read in that line to what you're looking for, if a match is found do what you need to do with that information, then the loop will run again on the next line and repeat the actions needed. You can even shorten the code a bit to have it look for just the word Server in the string or Desk and then look for a specific server string or a specific desk string. I'd have to have a running script to verify this because I have no idea what your listbox contents look like so I can't be sure of what to put in the search strings.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

the list box would contain sSever1, sServer2, sServer3, sServer4.. if the other button is clicked it deletes the current contents and populates it with sDesk1 sDesk2 sDesk3.... how would i write a loop to process one line at a time.. would i use

_GUICtrlListBox_GetText($addedListBox, 0)

...? i guess im just wondering what the easiest way to evaluate each line would be without having to re-write 300lines. i mean if thats the only way it would work it looks like im going to be re-writing for a while but its gotta get done.. right now what im using to evaluate the list box is "_GUICtrlListBox_FindString($addedListBox, "1 sServer", True)".... is there a way to write a control that searches each line rather than a "_FindString"? because i think the problem is that it finds the first valid string(line 1) and then terminates all of the following functions

Link to comment
Share on other sites

what would happen if i assigned the text a certain data and then used "_GUICtrlListBox_GetItemData()"...? or is that for objects within a gui and not text? if i can use it for text, can i make a variable with one string be displayed as a different string within that list box? so basically my list box says "1 sServer" if the user clicks the Finish Button... can i assign data (in this case a variable with an encrypted string), to the string "1 sServer" ? if thats complicated let me know.. ALSO this just hit me, if you want the whole program to run and whatnot, PM me, im not at liberty to display the program in public..

Link to comment
Share on other sites

Did you even run the script I posted? If you had it would have demonstrated EXACTLY how to get the text from the list box one line at a time.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

LetsAuto,

If you are going to use the ListBox UDF then read the values like this

;
;
#include <GuiListBox.au3>
#include <GUIConstantsEx.au3>

local $gui010   =   guicreate('Listbox Example')
local $lst010   =   _guictrllistbox_create($gui010,'',10,10)
local $btn010   =   guictrlcreatebutton('List ListBox Entries',10,350,300,20)
                    guisetstate()

for $1 = 1 to 10
    _GUICtrlListBox_AddString($lst010,stringformat('%02i',$1))
next

while 1

    switch guigetmsg()
        case $gui_event_close
            Exit
        case $btn010
            for $1 = 0 to _GUICtrlListBox_GetCount($lst010) - 1
                ConsoleWrite(_guictrllistbox_gettext($lst010,$1) & @LF)
            Next
    EndSwitch

wend

You may want to read the Help file, it is very specific about how to use these functions.

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

LetsAuto,

This more closely mimics what you are doing (e.g. create a listbox with the native function and manipulate it wih the UDF).

;
;
#include <GuiListBox.au3>
#include <GUIConstantsEx.au3>

local $gui010    =    guicreate('Listbox Example',200,300)
;local $lst010    =    _guictrllistbox_create($gui010,'',10,10,50,200)
local $lst010    =    guictrlcreatelist('',10,10,50,200)
local $lbl010    =    guictrlcreatelabel('',100,10,50,200)
                    guictrlsetfont(-1,8.5,800)
local $btn010    =    guictrlcreatebutton('List ListBox Entries',10,250,180,20)
                    guisetstate()

for $1 = 1 to 10
    _GUICtrlListBox_AddString($lst010,stringformat('%02i',$1))
next

local $lbstr
while 1

    switch guigetmsg()
        case $gui_event_close
            Exit
        case $btn010
            for $1 = 0 to _GUICtrlListBox_GetCount($lst010) - 1
                $lbstr &= _guictrllistbox_gettext($lst010,$1) & @lf
            Next
            guictrlsetdata($lbl010,$lbstr)
    EndSwitch

wend

Additional observations:

You are deleting and re-defining the listbox based on the results of a find. Just Empty the listbox by setting it to "" and re-populate it.

I would create a function for your file writes (appends) and call the function when appropriate with the string to write to the file. The function would open, write then close the file, not delete it.

Instead of this long string of compare's I would put all values that you are searching for in an array and loop through the array. You can use a 2D array if you need to pass different info based on the search hit. Better would be an "ini" file read into an array. Then use _GUICtrlListBox_FindString to do whatever you are dong with the compares.

Lastly, as to your original problem. It appears that you are deleting the file then opening it for append (and create dir if it does not exist), kind of a contradiction as you are doing this for every write. Consequently you are getting one record per file (I hope I'm wrong about this cause it's gonna piss you off if this is the problem!)

Good Luck,

kylomas

edit: additional info (24 hrs. later)

The code that I posted was in response to post #17. After re-reading this I think you may be losing track of what you are doing. My understanding of what you are attempting to do:

1 - Populate a LB from an ini file following a button click

2 - Move entries between LB's based on a button click

3 - Write a log file entry of LB's value for each user action

Is this right?

Edited 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...