ca143508 Posted June 3, 2007 Posted June 3, 2007 Hi Guys, I have had a look around but can't find what I am looking for. I have a CSV file similar to the one listed below. I want to take that information and drop it into a ListView box which allows the user to select a line, delete it from the CSV if they choose, edit it if they choose etc etc. Any help ou can give me would be great. 2007/05/23, Bill Gates, 08:30, 11:00, 1, Microsoft.com 2007/05/23, GWB, 12:30, 14:00, 3, The UN Thanks for your help. Cheers, Mike.
PsaltyDS Posted June 4, 2007 Posted June 4, 2007 Hi Guys,I have had a look around but can't find what I am looking for. I have a CSV file similar to the one listed below. I want to take that information and drop it into a ListView box which allows the user to select a line, delete it from the CSV if they choose, edit it if they choose etc etc. Any help ou can give me would be great.2007/05/23, Bill Gates, 08:30, 11:00, 1, Microsoft.com2007/05/23, GWB, 12:30, 14:00, 3, The UNThanks for your help.Cheers,Mike.Soooo... what have you got so far? Have you coded the basic GUI with a ListView in it? What part did you need help with? 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
ca143508 Posted June 4, 2007 Author Posted June 4, 2007 IT's all good now guys. The code is messy but it does do exactly what I needed it to do. Thanks for taking the time to help out.
randallc Posted June 4, 2007 Posted June 4, 2007 hi, Good news; care to share? - maybe post to scripts and scraps; I never know when I might need something like that... Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
ca143508 Posted June 4, 2007 Author Posted June 4, 2007 hi, Good news; care to share? - maybe post to scripts and scraps; I never know when I might need something like that... Best, randall This is the source code for the app I am working with. It's just an in house app for staff to book the use of the meeting rooms. expandcollapse popup;========================================================= ; Application Name: iMeet ; Purpose: Used as a calendar for those wishing to book ; certain meeting rooms. ; Author: Mike Smith ;========================================================= #include <GuiConstants.au3> #include <GuiListView.au3> #include <GuiList.au3> #include <File.au3> $Form1 = GUICreate("iMeet", 233, 257) $MonthCal101 = GUICtrlCreateMonthCal("", 24, 32, 183, 157) $Label101 = GUICtrlCreateLabel("Select the date of your meeting:", 8, 8, 154, 17) $Label102 = GUICtrlCreateLabel("Which meeting room would you like?", 8, 195, 177, 17) $Combo101 = GUICtrlCreateCombo("Choose...", 24, 216, 177, 25) GUICtrlSetData(-1, "Meeting Room 1|Meeting Room 2|Meeting Room 3|The Board Room||The Data Projector") GUISetState(@SW_SHOW) $Form2 = GUICreate("", 633, 401) $ListView2 = GUICtrlCreateListView("Date|Name|Start Time|End Time|Reference", 24, 29, 578, 150,BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_SORTASCENDING)) $Label201 = GUICtrlCreateLabel("Previous Bookings", 16, 8, 109, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button201 = GUICtrlCreateButton("Select a Different Meeting Room", 32, 192, 179, 25, 0) $Group201 = GUICtrlCreateGroup(" Make a New Booking ", 24, 232, 577, 153) $Label202 = GUICtrlCreateLabel("Your Full Name:", 72, 259, 79, 17) $Label203 = GUICtrlCreateLabel("Meeting Reference:", 50, 291, 98, 17) $Label204 = GUICtrlCreateLabel("Start Time:", 96, 322, 55, 17) $Label205 = GUICtrlCreateLabel("End Time:", 98, 355, 52, 17) $Input201 = GUICtrlCreateInput("", 160, 256, 145, 21) $Input202 = GUICtrlCreateInput("", 160, 288, 145, 21) $Combo201 = GUICtrlCreateCombo("", 160, 320, 145, 25) GUICtrlSetData(-1, "08:00|08:30|09:00|09:30|10:00|10:30|11:00|11:30|12:00|12:30|13:00|13:30|14:00|14:30|15:00|15:30|16:00|16:30|17:00") $Combo202 = GUICtrlCreateCombo("", 160, 352, 145, 25) GUICtrlSetData(-1, "08:00|08:30|09:00|09:30|10:00|10:30|11:00|11:30|12:00|12:30|13:00|13:30|14:00|14:30|15:00|15:30|16:00|16:30|17:00") $Button203 = GUICtrlCreateButton("Save the New Booking", 424, 352, 155, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button202 = GUICtrlCreateButton("Delete the Selected Booking", 224, 192, 163, 25, 0) GUISetState(@SW_HIDE) Func _ListPreBookedMeetings() Sleep(250) $SelectedRoom = GUICtrlRead($Combo101) WinSetTitle("","",$SelectedRoom) GUICtrlDelete($ListView2) Opt("GUIDataSeparatorChar","|") $ListView2 = GUICtrlCreateListView("Date|Name|Start Time|End Time|Reference", 24, 29, 578, 150,BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$LVS_SORTASCENDING)) _GUICtrlListViewSetColumnWidth ( -1, 0, 0 ) _GUICtrlListViewSetColumnWidth ( -1, 1, 150 ) _GUICtrlListViewSetColumnWidth ( -1, 2, 75 ) _GUICtrlListViewSetColumnWidth ( -1, 3, 75 ) _GUICtrlListViewSetColumnWidth ( -1, 4, 150) $file = FileOpen($SelectedRoom & ".csv", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop Opt("GUIDataSeparatorChar",",") $SelectedDate = GUICtrlRead($MonthCal101) $tDate = StringLeft($line, 10) If $tDate = $SelectedDate Then GUICtrlCreateListViewItem($line, $ListView2) Else ;Do Nothing EndIf Wend FileClose($file) EndFunc Func _DeleteABooking() $ReplacementText = "" $Selected = _GUICtrlListViewGetItemText ($ListView2) $SelectedRoom = GUICtrlRead($Combo101) $FilePath = $SelectedRoom & ".csv" If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $NewSelection = StringReplace($Selected,"|",",") $iMsgBoxAnswer = MsgBox(20,"iMeet","You are about to delete the following booking:" & @CRLF & @CRLF & $NewSelection & @CRLF & @CRLF & "Do you wish to continue?") Select Case $iMsgBoxAnswer = 6;Yes _ReplaceStringInFile ( $FilePath, $NewSelection, $ReplacementText) MsgBox(0,"iMeet","Your meeting has been removed from iMeet. Thankyou.", 5) _ListPreBookedMeetings() Case $iMsgBoxAnswer = 7;No EndSelect FileWriteLine("Log.txt","Meeting '" & $NewSelection & "' was deleted by " & @UserName & " on the " & @MDay & "/" & @MON & "/" & @YEAR & " at " & @HOUR & ":" & @MIN) EndFunc Func _AddNewBooking() $SelectedDate = GUICtrlRead($MonthCal101) $SelectedRoom = GUICtrlRead($Combo101) $FullName = GUICtrlRead($Input201) $Reference = GUICtrlRead($Input202) $Start = GUICtrlRead($Combo201) $End = GUICtrlRead($Combo202) FileWriteLine($SelectedRoom & ".csv", $SelectedDate & ", " & $FullName & ", " & $Start & ", " & $End & ", " & $Reference) MsgBox(0,"iMeet","Your booking has been recorded into iMeet. Thankyou.") GUICtrlSetData($Input201,"") GUICtrlSetData($Input202,"") GUICtrlSetData($Combo201,"") GUICtrlSetData($Combo202,"") _ListPreBookedMeetings() EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo101 GUISetState(@SW_HIDE, $Form1) GUISetState(@SW_SHOW, $Form2) _ListPreBookedMeetings() Case $Button201 GUISetState(@SW_HIDE, $Form2) GuiSetState(@SW_SHOW, $Form1) Case $Button202 _DeleteABooking() Case $Button203 _AddNewBooking() EndSwitch WEnd
randallc Posted June 4, 2007 Posted June 4, 2007 OK, neat, thanks! Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
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