Sign in to follow this  
Followers 0
Bru

URL Manager

13 posts in this topic

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]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

IniRead/IniWrite? Or you could store them in a registry key with RegRead/RegWrite.

Edited by exodius

Share this post


Link to post
Share on other sites

That's easy enough for adding, and reading.

But how easy would it be to delete from those?

Thanks by the way.


[right] [/right]

Share this post


Link to post
Share on other sites

LOL, IniDelete and RegDelete. :)

Share this post


Link to post
Share on other sites

Ah yes, true true.

Thanks.

I'll give it a go later after the gym.


[right] [/right]

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

Go to the Help File, go to the Index Tab, look for the keyword _SQL

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks mate.

Edited by Bru

[right] [/right]

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Ahh thanks again...


[right] [/right]

Share this post


Link to post
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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0