| View previous topic :: View next topic |
| Author |
Message |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Mon Nov 28, 2005 6:42 pm Post subject: More than ONE Link |
|
|
| Code: | Title Links catalog
DIALOG CREATE,Links catalog,-1,0,520,295,,NOMIN
DIALOG ADD,BITLIST,BITLIST1,4,4,170,287,,CLICK,MULTI,SORTED
gosub BITLIST1
DIALOG ADD,GROUP,GROUP1,4,190,312,143,Properties
DIALOG ADD,BUTTON,BUTTON1,261,444,64,24,Close
DIALOG ADD,BUTTON,BUTTON2,159,195,64,24,Add
DIALOG ADD,BUTTON,BUTTON3,159,270,64,24,Remove
DIALOG ADD,EDIT,EDIT1,36,254,232,19,
DIALOG ADD,EDIT,EDIT2,91,254,232,19,
DIALOG ADD,TEXT,TEXT1,40,223,,,Title:
DIALOG ADD,TEXT,TEXT2,94,205,,,Address:
DIALOG ADD,BUTTON,BUTTON5,261,195,64,24,Run
DIALOG ADD,LINE,LINE1,195,190,310,2
DIALOG SHOW
:loop
wait event
goto @event()
:BITLIST1
inifile open,@PATH(%0)lcdata.ini
%T = @iniread("Title",Title)
if @zero(%T)
exit
else
list add,BITLIST1,%T|Link.ico
inifile CLOSE
exit
:BITLIST1CLICK
inifile open,@PATH(%0)lcdata.ini
%T = @iniread("Title",Title)
%A = @iniread("Address",Address)
dialog set,EDIT1,%T
dialog set,EDIT2,%A
inifile CLOSE
goto loop
:BUTTON1BUTTON
goto close
:BUTTON2BUTTON
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
warn A title is missing!
else
if @zero(%A)
warn An address is missing!
else
list add,BITLIST1,%T|Links.ico
inifile open,@PATH(%0)lcdata.ini
inifile write,Title,Title,%T
inifile write,Address,Address,%A
inifile CLOSE
dialog clear,EDIT1
dialog clear,EDIT2
end
end
goto loop
:BUTTON5BUTTON
shell open,%A
goto loop
:Close
exit |
This script add/read/load/run only ONE web link to database...HELP WANTED!
How to add more than one link to database ? |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Nov 28, 2005 7:39 pm Post subject: |
|
|
Everytime you add a link, you overwrite the last one that was put in.
Your INI looks like this now:
| Quote: |
[Title]
Title=Test
[Address]
Address=Test
|
You might want to try something like:
| Quote: |
[Links]
Amount=2
[Link 1]
Title=Test
Address=Test
[Link 2]
Title=VDSWorld
Address=http://www.vdsworld.com
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 2:05 am Post subject: |
|
|
If you have an unknown number of Links in the ini file use sections Link1 and Link2 etc.
| Quote: | [Link1]
Title=ToppyTools
Address=http://optusnet.com/~toppytools
[Link2]
Title=VDSWorld
Address=http://www.vdsworld.com
|
| Code: |
:BITLIST1CLICK
inifile open,@PATH(%0)lcdata.ini
# Loop for each link in the ini file.
%%Count = 1
repeat
%T = @iniread(Link%%Count,Title)
%A = @iniread(Link%%Count,Address)
dialog set,EDIT1,%T
dialog set,EDIT2,%A
%%Count = @succ(%%Count)
until @null(%A)
inifile CLOSE
goto loop
|
Though, unless you want to display the last entry in EDIT1 and EDIT2, I'd suggest using a combo box or list box - or leaving EDIT1 and EDIT2 blank.
Then when writing each new entry use something like this:
| Code: |
:BUTTON2BUTTON
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
warn A title is missing!
else
if @zero(%A)
warn An address is missing!
else
list add,BITLIST1,%T|Links.ico
inifile open,@PATH(%0)lcdata.ini
# Loop to find the last link in the ini file.
%%Count = 1
repeat
%X = @iniread(Link%%Count,Address)
%%Count = @succ(%%Count)
until @null(%X)
inifile write,Link%%Count,Title,%T
inifile write,Link%%Count,Address,%A
inifile CLOSE
dialog clear,EDIT1
dialog clear,EDIT2
end
end
goto loop
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 3:19 am Post subject: |
|
|
Ok, I just tested your code with my changes and there was another bit that needed a %%Count loop added.
| Code: |
Title Links Catalog
DIALOG CREATE,Links Catalog,-1,0,520,295,,NOMIN
DIALOG ADD,BITLIST,BITLIST1,4,4,170,287,,CLICK,MULTI,SORTED
DIALOG ADD,GROUP,GROUP1,4,190,312,143,Properties
DIALOG ADD,BUTTON,BUTTON1,261,444,64,24,Close
DIALOG ADD,BUTTON,BUTTON2,159,195,64,24,Add
DIALOG ADD,BUTTON,BUTTON3,159,270,64,24,Remove
DIALOG ADD,EDIT,EDIT1,36,254,232,19,
DIALOG ADD,EDIT,EDIT2,91,254,232,19,
DIALOG ADD,TEXT,TEXT1,40,223,,,Title:
DIALOG ADD,TEXT,TEXT2,94,205,,,Address:
DIALOG ADD,BUTTON,BUTTON5,261,195,64,24,Run
DIALOG ADD,LINE,LINE1,195,190,310,2
DIALOG SHOW
gosub BITLIST1
:EvLoop
wait event
goto @event()
:BITLIST1
inifile open,@PATH(%0)lcdata.ini
# Loop for each link in the ini file.
%%Count = 1
repeat
%T = @iniread(Link%%Count,Title)
if %T
list add,BITLIST1,%T|Link.ico
end
%%Count = @succ(%%Count)
until @not(%T)
inifile close
exit
:BITLIST1CLICK
inifile open,@PATH(%0)lcdata.ini
# Loop for each link in the ini file.
%%Count = 1
repeat
%T = @iniread(Link%%Count,Title)
%A = @iniread(Link%%Count,Address)
dialog set,EDIT1,%T
dialog set,EDIT2,%A
%%Count = @succ(%%Count)
until @null(%A)
inifile close
goto evloop
:BUTTON1BUTTON
goto close
:BUTTON2BUTTON
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
warn A title is missing!
else
if @zero(%A)
warn An address is missing!
else
list add,BITLIST1,%T|Links.ico
inifile open,@PATH(%0)lcdata.ini
# Loop to find the last link in the ini file.
%%Count = 1
repeat
%X = @iniread(Link%%Count,Address)
%%Count = @succ(%%Count)
until @null(%X)
inifile write,Link%%Count,Title,%T
inifile write,Link%%Count,Address,%A
inifile CLOSE
dialog clear,EDIT1
dialog clear,EDIT2
end
end
goto evloop
:BUTTON5BUTTON
shell open,%A
goto evloop
:Close
exit
|
Once you get the Remove button working (and add an Edit button) it'll be a nice little application. Coding the remove button will be a pain because you'll have to re-number any Link# sections that come after the one you're removing. Personally I'd use the registry for storing the links as it's FAR easier. Then if you require portability just add Backup-Database-to-File and Restore-Database-from-File buttons. _________________ cheers
Dave |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 5:31 am Post subject: |
|
|
Here's a working example using the registry instead of an ini file: (plus a few other changes - I couldn't stop myself )
| Code: |
Title Links Catalog
DIALOG CREATE,Links Catalog,-1,0,520,295
DIALOG ADD,BITLIST,BITLIST1,4,4,170,287,,CLICK,SORTED
DIALOG ADD,GROUP,GROUP1,4,190,312,143,Properties
DIALOG ADD,TEXT,Title_,40,223,,,Title:
DIALOG ADD,TEXT,Address_,94,205,,,Address:
DIALOG ADD,BUTTON,Add_,159,195,64,24,&Add
DIALOG ADD,BUTTON,Change_,159,270,64,24,&Change
DIALOG ADD,BUTTON,Remove_,159,345,64,24,R&emove
DIALOG ADD,EDIT,EDIT1,36,254,232,19,
DIALOG ADD,EDIT,EDIT2,91,254,232,19,
DIALOG ADD,LINE,LINE1,195,190,310,2
DIALOG ADD,BUTTON,Run_,261,195,64,24,&Run,,DEFAULT
DIALOG ADD,BUTTON,Close_,261,444,64,24,&Close
dialog disable,add_
dialog disable,change_
dialog disable,remove_
dialog disable,run_
DIALOG SHOW
gosub BITLIST1
:EvLoop
wait event
goto @event()
:BITLIST1
# Read Links List from Registry
# LIST REGVALS,<list>,<root key>,<subkey>
LIST REGVALS,BITLIST1,DEFAULT,Links
exit
:BITLIST1CLICK
%T = @dlgtext(BITLIST1)
# Read Link Address from Registry
# @REGREAD( <root key>, <subkey>, <name> ,<default> )
%A = @regread(DEFAULT,Links,%T)
dialog set,EDIT1,%T
dialog set,EDIT2,%A
if @null(%T)
dialog disable,add_
dialog disable,change_
dialog disable,remove_
dialog disable,run_
else
dialog enable,add_
dialog enable,change_
dialog enable,remove_
dialog enable,run_
end
goto evloop
:Add_BUTTON
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
warn A title is missing!
elsif @zero(%A)
warn An address is missing!
else
# REGISTRY WRITE, <root key>, <subkey>, <name>, <value>,<type>
REGISTRY WRITE,DEFAULT,Links,%T,%A
dialog clear,EDIT1
dialog clear,EDIT2
end
gosub BITLIST1
goto evloop
:Change_BUTTON
%X = @dlgtext(BITLIST1)
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
warn A title is missing!
elsif @zero(%A)
warn An address is missing!
else
if @not(@equal(%X,%T))
# REGISTRY RENAME, <root key>, <subkey>, <name>, <new name>
REGISTRY RENAME,DEFAULT,Links,%X,%T
end
# REGISTRY WRITE, <root key>, <subkey>, <name>, <value>,<type>
REGISTRY WRITE,DEFAULT,Links,%T,%A
dialog clear,EDIT1
dialog clear,EDIT2
end
gosub BITLIST1
goto evloop
:Remove_BUTTON
%T = @dlgtext(EDIT1)
if %T
# REGISTRY DELETE, <root key>, <subkey> {, <value>}
REGISTRY DELETE,DEFAULT,Links,%T
dialog clear,EDIT1
dialog clear,EDIT2
end
gosub BITLIST1
goto evloop
:Run_BUTTON
%T = @dlgtext(BITLIST1)
# Read Link Address from Registry
# @REGREAD( <root key>, <subkey>, <name> ,<default> )
%A = @regread(DEFAULT,Links,%T)
shell open,%A
goto evloop
:Close
:Close_BUTTON
exit
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Sat Dec 03, 2005 8:07 am Post subject: |
|
|
You just modified my code...that's fantastic
What if i move to australia and we try together create a soft. company there ?
It will be nice to show someone my work...MYBE
Why disable buttons...
dialog disable,add_
dialog disable,change_
dialog disable,remove_
dialog disable,run_
I'm catching up with your code... |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 9:08 am Post subject: |
|
|
| filip wrote: | Why disable buttons...
dialog disable,add_
dialog disable,change_
dialog disable,remove_
dialog disable,run_ |
I disable them when clicking on them would do nothing. Then re-enable them when they can be used. It just makes it cleaner looking to the user.
I've actually modified your code a lot more since I posted as I think it'd be a nice little application to have sitting in my tool tray. But my UPS just blew a fuse so I'm about to have a look and see how much work I lost. _________________ cheers
Dave |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Sat Dec 03, 2005 12:10 pm Post subject: |
|
|
| yes sure, but the dialog start with disable buttons what's the point then...? |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 12:21 pm Post subject: |
|
|
Because you can't use the other buttons until you've selected a link from the list. As soon as you select a link all the buttons are enabled. _________________ cheers
Dave |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 12:30 pm Post subject: |
|
|
Here's what I've finished up with (for my own personal use):
And if you're wondering why the ToppyTools logo, it was the only logo I had lying around (from my freeware applications for Topfield PVRs) http://optusnet.com/~toppytools/
| Code: |
TITLE Quick Links
OPTION SCALE, 96
OPTION DECIMALSEP, "."
OPTION TIPTIME, 2.5
OPTION FIELDSEP, "|"
OPTION REGKEY, ToppyTools\Quick Links
OPTION SHUTDOWN, Close
# TrayIcon Menu
rem #DEFINE COMMAND,POPUP
rem #DEFINE FUNCTION,POPUP
rem EXTERNAL vdspopup.dll,DEMO
# Logo Background
#RESOURCE ADD, BITMAP, header-med.bmp
# BitList Icons
#RESOURCE ADD, ICON, web.ico
#RESOURCE ADD, ICON, app.ico
DIALOG CREATE,Quick Links,-1,0,517,290
DIALOG ADD,TASKICON,TrayIcon,#Icon_1.ico
DIALOG ADD,STYLE,STYLE1,Times New Roman,24,BIR,DFDFDF,RED
DIALOG ADD,STYLE,STYLE2,Times New Roman,24,BIR,DFDFDF,SILVER
DIALOG ADD,TEXT,TEXT1,216,263,,,Quick Links,,STYLE2,TRANSPARENT
DIALOG ADD,BITLIST,BITLIST1,0,0,169,290,,CLICK,SORTED
DIALOG ADD,BITMAP,BITMAP1,0,164,352,36,#header-med.bmp
DIALOG ADD,GROUP,GROUP1,53,186,315,135
DIALOG ADD,TEXT,Title_,73,224,,,Title:
DIALOG ADD,TEXT,Address_,107,205,,,Address:
DIALOG ADD,BUTTON,Clear_,147,204,64,24,&Clear
DIALOG ADD,BUTTON,Add_,147,276,64,24,&Add
DIALOG ADD,BUTTON,Change_,147,348,64,24,C&hange
DIALOG ADD,BUTTON,Remove_,147,419,64,24,R&emove
DIALOG ADD,EDIT,EDIT1,70,253,230,19,,@cr()" "Enter a name to display in the list. @cr()
DIALOG ADD,EDIT,EDIT2,105,253,230,19,,@cr()" "Enter the URL or Application to Link to. @cr()
DIALOG ADD,BUTTON,Run_,252,186,64,24,&Run
DIALOG ADD,BUTTON,Close_,252,438,64,24,&Close,,DEFAULT
dialog disable,clear_
dialog disable,change_
dialog disable,remove_
dialog disable,run_
DIALOG SHOW
%%hwnd = @winexists("Quick Links")
%%show = 1
dialog focus,EDIT1
gosub BITLIST1
rem bitlist icon test
rem list add,bitlist1,icontest@fsep()#web.ico
:EvLoop
if %%show
wait event, .5
else
wait event
end
goto @event()
:Close
:Close_BUTTON
exit
:TIMER
# Minimise to Tray
# Check if "minimized"
if @equal(@winpos(%%hwnd, S), 2)
DIALOG HIDE
%%show =
end
goto EvLoop
:TrayIconCLICK
DIALOG SHOW
WINDOW NORMAL, %%hwnd
%%show = 1
goto EvLoop
:BITLIST1
# Read Links List from Registry
# LIST REGVALS,<list>,<root key>,<subkey>
LIST REGVALS,BITLIST1,DEFAULT,Links
exit
:BITLIST1CLICK
dialog focus,EDIT1
%T = @dlgtext(BITLIST1)
# Read Link Address from Registry
# @REGREAD( <root key>, <subkey>, <name> ,<default> )
%A = @regread(DEFAULT,Links,%T)
dialog set,EDIT1,%T
dialog set,EDIT2,%A
if @null(%T)
dialog disable,clear_
dialog disable,add_
dialog disable,change_
dialog disable,remove_
dialog disable,run_
else
dialog enable,clear_
dialog enable,add_
dialog enable,change_
dialog enable,remove_
dialog enable,run_
end
gosub RunDefault
goto EvLoop
:Clear_BUTTON
# ReRead Links List from Registry
# LIST REGVALS,<list>,<root key>,<subkey>
LIST REGVALS,BITLIST1,DEFAULT,Links
dialog clear,EDIT1
dialog clear,EDIT2
dialog focus,EDIT1
gosub AddDefault
gosub DisableUnusableButtons
goto EvLoop
:Add_BUTTON
dialog focus,EDIT1
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
if @zero(%A)
warn Title and Address are blank! ,
else
warn Title is blank! ,
end
elsif @zero(%A)
warn Address is blank! ,
else
# REGISTRY WRITE, <root key>, <subkey>, <name>, <value>,<type>
REGISTRY WRITE,DEFAULT,Links,%T,%A
dialog clear,EDIT1
dialog clear,EDIT2
end
gosub BITLIST1
gosub RunDefault
gosub DisableUnusableButtons
goto EvLoop
:Change_BUTTON
dialog focus,EDIT1
%X = @dlgtext(BITLIST1)
%T = @dlgtext(EDIT1)
%A = @dlgtext(EDIT2)
if @zero(%T)
warn A title is missing!
elsif @zero(%A)
warn An address is missing!
else
if @not(@equal(%X,%T))
# REGISTRY RENAME, <root key>, <subkey>, <name>, <new name>
REGISTRY RENAME,DEFAULT,Links,%X,%T
end
# REGISTRY WRITE, <root key>, <subkey>, <name>, <value>,<type>
REGISTRY WRITE,DEFAULT,Links,%T,%A
dialog clear,EDIT1
dialog clear,EDIT2
end
gosub BITLIST1
gosub RunDefault
gosub DisableUnusableButtons
goto EvLoop
:Remove_BUTTON
dialog focus,EDIT1
%T = @dlgtext(EDIT1)
if %T
# REGISTRY DELETE, <root key>, <subkey> {, <value>}
REGISTRY DELETE,DEFAULT,Links,%T
dialog clear,EDIT1
dialog clear,EDIT2
end
gosub BITLIST1
gosub RunDefault
gosub DisableUnusableButtons
goto EvLoop
:Run_BUTTON
%T = @dlgtext(BITLIST1)
# Read Link Address from Registry
# @REGREAD( <root key>, <subkey>, <name> ,<default> )
%A = @regread(DEFAULT,Links,%T)
shell open,%A
gosub RunDefault
goto EvLoop
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# GOSUBS
:DisableUnusableButtons
dialog disable,clear_
dialog disable,change_
dialog disable,remove_
dialog disable,run_
exit
:RunDefault
# Change Default button to Run Button
DIALOG REMOVE,Add_
DIALOG ADD,BUTTON,Add_,147,276,64,24,&Add
DIALOG REMOVE,Run_
DIALOG ADD,BUTTON,Run_,252,186,64,24,&Run,,DEFAULT
DIALOG REMOVE,Close_
DIALOG ADD,BUTTON,Close_,252,438,64,24,&Close
exit
:AddDefault
# Change Default button to Add Button
DIALOG REMOVE,Add_
DIALOG ADD,BUTTON,Add_,147,276,64,24,&Add,,DEFAULT
DIALOG REMOVE,Run_
DIALOG ADD,BUTTON,Run_,252,186,64,24,&Run
DIALOG REMOVE,Close_
DIALOG ADD,BUTTON,Close_,252,438,64,24,&Close
exit
:CloseDefault
# Change Default button to Close Button
DIALOG REMOVE,Add_
DIALOG ADD,BUTTON,Add_,147,276,64,24,&Add
DIALOG REMOVE,Run_
DIALOG ADD,BUTTON,Run_,252,186,64,24,&Run
DIALOG REMOVE,Close_
DIALOG ADD,BUTTON,Close_,252,438,64,24,&Close,,DEFAULT
exit
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Dec 03, 2005 12:42 pm Post subject: |
|
|
PS The only thing left that I wanted to do was add bitmaps or icons to the bitlist. But I couldn't think of an easy way to do that since I'm using "LIST REGVALS" to create the list. _________________ cheers
Dave |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Sat Dec 03, 2005 12:52 pm Post subject: |
|
|
Nice
you put buttons inside group (nice touch if dialog is main not child)
I my self run links with URL bypass for security reasons (you can load anything with shell open)
You have working minimized-> to tray too
someone was experimenting with Option MSGEVENT with no luck
My program has links everywhere from menus from icons and you can config them... |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Sat Dec 03, 2005 6:29 pm Post subject: |
|
|
Icon solution
:BITLIST1
LIST REGVALS,BITLIST1,DEFAULT,Links
LIST add,BITLIST1,|link.ico
list seek,BITLIST1
list delete,BITLIST1,0
exit |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sun Dec 04, 2005 4:12 am Post subject: |
|
|
Cool! That would've taken me hours to figure out. This whole list thing is new to me. _________________ cheers
Dave |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|