hi,
another quicky from miki.....
daft address book.... code works in classic and pro
no media..
here'a some screenshots:
and here's the code:
set display mode 800,600,16
set window on
set window title "DAFT ADDRESS"
set window position 100,100
sync on
` name directories and paths
dir$=get dir$()
data$ = "daft add"
cd "C:\Documents and Settings\All Users"
if path exist(data$)=0 then make directory data$
set dir dir$
` array dimensions
dim con$(26)
dim name$(20)
dim address$(20)
dim number$(20)
` get entry quantitys
gosub get_con1
` letters graphs
gosub letters
`
do
`
gosub name
gosub address
gosub number
gosub onscreen_info
gosub letter_bobs
gosub view_data
gosub edit_entry
`
sync
loop
` +++++++++++++++++++++++++++++ pre loop subs ++++++++++++++++++++++++++++++++++++++++
` letters graphs
letters:
ink rgb(255,150,255),0
text 0,0,"A"
get image 1,0,0,20,20
cls
text 0,0,"B"
get image 2,0,0,20,20
cls
text 0,0,"C"
get image 3,0,0,20,20
text 0,0,"D"
get image 4,0,0,20,20
cls
text 0,0,"E"
get image 5,0,0,20,20
cls
text 0,0,"F"
get image 6,0,0,20,20
cls
text 0,0,"G"
get image 7,0,0,20,20
cls
text 0,0,"H"
get image 8,0,0,20,20
cls
text 0,0,"I"
get image 9,0,0,20,20
cls
text 0,0,"J"
get image 10,0,0,20,20
cls
text 0,0,"K"
get image 11,0,0,20,20
cls
text 0,0,"L"
get image 12,0,0,20,20
cls
text 0,0,"M"
get image 13,0,0,20,20
cls
text 0,0,"N"
get image 14,0,0,20,20
cls
text 0,0,"O"
get image 15,0,0,20,20
cls
text 0,0,"P"
get image 16,0,0,20,20
cls
text 0,0,"Q"
get image 17,0,0,20,20
cls
text 0,0,"R"
get image 18,0,0,20,20
cls
text 0,0,"S"
get image 19,0,0,20,20
cls
text 0,0,"T"
get image 20,0,0,20,20
cls
text 0,0,"U"
get image 21,0,0,20,20
cls
text 0,0,"V"
get image 22,0,0,20,20
cls
text 0,0,"W"
get image 23,0,0,20,20
cls
text 0,0,"X"
get image 24,0,0,20,20
cls
text 0,0,"Y"
get image 25,0,0,20,20
cls
text 0,0,"Z"
get image 26,0,0,20,20
cls
ink rgb(255,150,0),0
box 0,0,7,7
get image 101,0,0,7,7
cls
return
` get con1
get_con1:
cd "C:\Documents and Settings\All Users"
set dir data$
for t=1 to 26
if file exist(str$(t)+".dat")=1
open to read t,str$(t)+".dat"
read string t,contains$
con$(t)=contains$
close file t
endif
next t
set dir dir$
return
`
` +++++++++++++++++++++++++++++++ looped subs ++++++++++++++++++++++++++++++++++
`
` letter bobs
letter_bobs:
for t=1 to 26
sprite t,720,20*t,t
text 760,20*t,con$(t)
next t
sprite 101,mousex(),mousey(),101:` pointer
return
` name
name:
if in=0
if scancode()=28 then in=in+1:clear entry buffer:wait 1000
new$=entry$()
for n=1 to len(new$)
if asc(mid$(new$,n))=8
line$=left$(line$,len(line$)-1)
else
line$=line$+mid$(new$,n)
endif
next n
clear entry buffer
endif
return
` address
address:
if in=1
if scancode()=28 then in=in+1:clear entry buffer:wait 1000
new2$=entry$()
for n=1 to len(new2$)
if asc(mid$(new2$,n))=8
line2$=left$(line2$,len(line2$)-1)
else
line2$=line2$+mid$(new2$,n)
endif
next n
clear entry buffer
endif
return
` number
number:
if in=2
if scancode()=28 then in=in+1:gosub record_entry:clear entry buffer:wait 1000
new1$=entry$()
for n=1 to len(new1$)
if asc(mid$(new1$,n))=8
line1$=left$(line1$,len(line1$)-1)
else
line1$=line1$+mid$(new1$,n)
endif
next n
clear entry buffer
endif
return
` record entry
record_entry:
con1=val(con$(letter))
con2=con1
if con1=0 then con1=1
con3=con2+1
cd "C:\Documents and Settings\All Users"
set dir data$
if file exist(str$(letter)+".dat")=1
open to read letter,str$(letter)+".dat"
if c<21
repeat
c=c+1
read string letter,contains$
read string letter,name$
read string letter,address$
read string letter,number$
name$(c)=name$
address$(c)=address$
number$(c)=number$
until c=con1
endif
close file letter
endif
if file exist(str$(letter)+".dat")=1 then delete file (str$(letter)+".dat")
open to write letter,str$(letter)+".dat"
if con2>0
if d<21
repeat
d=d+1
contains$=str$(con3)
write string letter,contains$
write string letter,name$(d)
write string letter,address$(d)
write string letter,number$(d)
until d=con1
endif
endif
contains$=str$(con3)
name$=line$
address$=line2$
number$=line1$
write string letter,contains$
write string letter,name$
write string letter,address$
write string letter,number$
write string letter, "delete the required entry/entrys then edit the top number by -1 or -2 etc. ... then save file"
close file letter
set dir dir$
c=0:d=0:start=0:gosub get_con1
return
` onscreen info
onscreen_info:
ink rgb(255,255,255),0
cls rgb(25,75,25)
text 20,20,"input name .... then press enter..>":text 320,20,line$
if in>0
text 20,40,"input address .... then press enter..>":text 320,40,line2$
endif
if in>1
text 20,60,"input number .... then press enter..>":text 320,60,line1$
endif
if in=3 then line$="":line2$="":line1$="": cls:in=0
text 20,570,"left click a letter to view listings... right click a letter to edit listings."
return
` view data
view_data:
first$=left$(line$, 1)
tot=ASC(first$)
letter=tot-96
if mouseclick()=1
hit = sprite collision(101,0)
endif
letter1=hit
cd "C:\Documents and Settings\All Users"
set dir data$
if file exist(str$(letter1)+".dat")=1
open to read letter1,str$(letter1)+".dat"
for b=1 to val(con$(letter1))
read string letter1,contains$
read string letter1,name$
read string letter1,address$
read string letter1,number$
b1=val(contains$)
name$(b)=name$
number$(b)=number$
ink rgb(255,255,185),0
text 20,120+20*b,name$
ink rgb(155,155,255),0
text 180,120+20*b,address$
ink rgb(155,255,255),0
text 580,120+20*b,number$
next b
close file letter1
b=0
endif
set dir dir$
return
` edit_entry
edit_entry:
if mouseclick()=2
hit2 = sprite collision(101,0):wait 1000
letter2$=str$(hit2)
cd "C:\Documents and Settings\All Users\daft add"
directory$=""
commandline$=letter2$+".dat"
if file exist(commandline$)=1
execute file "C:\Windows\NOTEPAD.EXE",commandline$,directory$,1
endif
endif
return
enjoy,
miki.
in the end