Page 1 of 1

Help with URL Manager

Posted: Sat Feb 21, 2009 5:10 pm
by oToom
Hello again,

just to get it out the way. Here is my code so far for URL Manager.

Code: Select all

UseSQLiteDatabase()

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #ListURL
  #DeleteURL
  #ConnectURL
  #AddURL
  #SelectedURL
  #oSoft
  #Items
  #ItemCount
EndEnumeration



OpenWindow(#Window_0, 412, 48, 341, 400, "oURL Manager",  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar )
    ;CreateGadgetList(WindowID(#Window_0))
      ListViewGadget(#ListURL, 10, 10, 320, 270)
      ButtonGadget(#DeleteURL, 250, 290, 80, 30, "Delete")
      ButtonGadget(#ConnectURL, 250, 360, 80, 30, "Connect")
      ButtonGadget(#AddURL, 10, 360, 80, 30, "Add")
      StringGadget(#SelectedURL, 10, 330, 320, 20, "")
      HyperLinkGadget(#oSoft, 140, 370, 50, 20, "oSoftware", RGB(255, 0, 0))    
  
      If ReadFile(0, "websites.inf")   
          While Eof(0) = 0          
            AddGadgetItem(#ListURL, -1, ReadString(0))     
          Wend               
      Else
          MessageRequester("Information","Couldn't open the file!")
      EndIf

If OpenFile(0, "websites.inf")
  FileSeek(0, Lof(0))
  
Repeat
  Event = WaitWindowEvent()

    Select Event
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #AddURL
              url$ = GetGadgetText(#SelectedURL)
              If url$ = ""
                MessageRequester("Error", "Please enter a URL to add.")
              Else
                AddGadgetItem(#ListURL, -1, url$)
                WriteStringN(0, url$)
                SetGadgetText(#SelectedURL, "")
              EndIf
            
          Case #DeleteURL
              checked.l = GetGadgetState(#ListURL)
              If checked = -1
                MessageRequester("Error", "Please select a URL to delete.")
              Else
                removed = RemoveGadgetItem(#ListURL, checked)
              EndIf
              
          Case #ConnectURL
              state.l = GetGadgetState(#ListURL)
              If state = -1
                MessageRequester("Error", "Please select a URL to connect.")
              Else
                urlconnect$ = GetGadgetText(GetGadgetState(#ListURL))
                RunProgram(url$)
              EndIf
            
        EndSelect
    EndSelect

Until Event = #PB_Event_CloseWindow

EndIf

CloseFile(0)

A couple of questionss...


What is the best way to go about saving the urls. So i can open the app next time with the url's still there.


Also i get an error now. Now i use the file. When i try and open the url.
( RunProgram(url$) ) i get an error.
- A filename must be specified.


Anyhelp on this appreciated greatly!

Thanks
Otoom

Posted: Sat Feb 21, 2009 7:02 pm
by srod

Code: Select all

urlconnect$ = GetGadgetText(#ListURL) 
RunProgram(urlconnect$) 

Posted: Sun Feb 22, 2009 10:25 pm
by oToom
Ah, yes. My bad.

Thank you for spotting that out for me.



Also, what would be the more practical way of storing the url's. Instead of using a file?



Thanks.
oT