Jump to content

URL Manager


Bru
 Share

Recommended Posts

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

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

Okay so here is it so far.

#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

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...