Bru Posted February 23, 2009 Share Posted February 23, 2009 Okai guys and girls. So i would like to start up another project. Called URL Manager. I would just like to know what is the most practical way of going about saving the url's? So it's easy enough to add and delete. What i mean by save is. So when the program is closed, and reopened, they are still there. Okay so what this will be. A listbox. To contain all urls. And add button, delete button and connect button. Self explanitory really. But yes, what would be the best way to save / store the urls for the next time it's opened? Thanks Ant [right][/right] Link to comment Share on other sites More sharing options...
exodius Posted February 23, 2009 Share Posted February 23, 2009 (edited) IniRead/IniWrite? Or you could store them in a registry key with RegRead/RegWrite. Edited February 23, 2009 by exodius Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 That's easy enough for adding, and reading. But how easy would it be to delete from those? Thanks by the way. [right][/right] Link to comment Share on other sites More sharing options...
exodius Posted February 23, 2009 Share Posted February 23, 2009 LOL, IniDelete and RegDelete. Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 Ah yes, true true. Thanks. I'll give it a go later after the gym. [right][/right] Link to comment Share on other sites More sharing options...
Bert Posted February 23, 2009 Share Posted February 23, 2009 Use SQLite. That way it is in a database. You can add comments if needed, ID and passwords if needed, and possible logon scripts. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 Would you mind if i ask for a link to SQLite? I remember using that when coding in PureBASIC, never worked for me though. I'll give it a shot. (: [right][/right] Link to comment Share on other sites More sharing options...
exodius Posted February 23, 2009 Share Posted February 23, 2009 Go to the Help File, go to the Index Tab, look for the keyword _SQL Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 (edited) Thanks mate. Edited February 23, 2009 by Bru [right][/right] Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 Sorry about double post but i have a small, hmmm. Problem.. Well, This is my delete func. Func _DeleteURL() $state = _GUICtrlListBox_GetSel($ListURL, 0) _GUICtrlListbox_DeleteString($ListURL, $state) EndFunc How can i do a little error checking on here? Say, how could i check that something is selected before deleting. If it isn't then a msgbox is shown. Thanks. Ant [right][/right] Link to comment Share on other sites More sharing options...
exodius Posted February 23, 2009 Share Posted February 23, 2009 Func _DeleteURL() $state = _GUICtrlListBox_GetCurSel($ListURL) If $state <> -1 Then _GUICtrlListbox_DeleteString($ListURL, $state) Else MsgBox(0, "None Selected", "") Endif EndFunc Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 Ahh thanks again... [right][/right] Link to comment Share on other sites More sharing options...
Bru Posted February 23, 2009 Author Share Posted February 23, 2009 Okay so here is it so far. expandcollapse popup#include <GUIConstants.au3> #include <GUIListBox.au3> #include <SQLite.au3> _SQLite_Startup() $Form1 = GUICreate("oURL Manager", 323, 338, 272, 188) $ListURL = GUICtrlCreateList("", 8, 8, 305, 253) $SelectedURL = GUICtrlCreateInput("", 8, 272, 305, 21) $AddURL = GUICtrlCreateButton("Add", 8, 304, 97, 25, 0) $DeleteURL = GUICtrlCreateButton("Delete", 112, 304, 97, 25, 0) $ConnectURL = GUICtrlCreateButton("Connect", 216, 304, 97, 25, 0) GUISetState(@SW_SHOW) Global $hQuery, $aRow _SQLite_Open() _SQLite_Exec(0, "CREATE TABLE urls (url);") _RefreshList() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $AddURL _AddURL() Case $DeleteURL _DeleteURL() Case $ConnectURL _ConnectURL() Case $ListURL $state = _GUICtrlListBox_GetCurSel($ListURL) $url = GUICtrlRead($ListURL, $state) GUICtrlSetData($SelectedURL, $url) EndSwitch WEnd Func _AddURL() If GUICtrlRead($SelectedURL) = "" Then MsgBox(0, "Error..", "Please enter a URL to add.", 5) Else _GUICtrlListBox_AddString($ListURL, GUICtrlRead($SelectedURL)) _SQLite_Exec(-1, "INSERT INTO urls (url) VALUES ('" & GUICtrlRead($SelectedURL) & "');") GUICtrlSetData($SelectedURL, "") EndIf EndFunc Func _DeleteURL() $state = _GUICtrlListBox_GetCurSel($ListURL) If $state <> -1 Then _GUICtrlListbox_DeleteString($ListURL, $state) Else MsgBox(0, "Error..", "Please select a URL to delete.", 5) Endif EndFunc Func _ConnectURL() $state = _GUICtrlListBox_GetCurSel($ListURL) If $state <> -1 Then $url = GUICtrlRead($ListURL, $state) ShellExecute($url) Else MsgBox(0, "Error..", "Please select a URL to connect.", 5) EndIf EndFunc Func _RefreshList() _SQLite_Exec(-1, "SELECT url FROM urls;", $hQuery) While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK _GUICtrlListBox_AddString($ListURL, $aRow[0]) WEnd EndFunc _SQLite_Close() _SQLite_Shutdown() I have to say i have done quite a bit. I just need a little help with a few things. I don't think it is writing to a db, as when i re-open the program the links are not there. Also, once i do get that part working, how do i delete using SQLite? DELETE url FROM urls ? Thanks [right][/right] 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