home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
qb_pds
/
qtoolsa
/
names.bas
< prev
next >
Wrap
BASIC Source File
|
1987-01-22
|
9KB
|
275 lines
rem $linesize:132
rem $title:'Names - Partial creation by Application Engineer'
rem $subtitle:'(c) Copyright Roy Barrow 1987.'
rem $include:'aecommon.bas'
' Screen Generator Version used was : 5.36a
dim dl$(6%)
call Color.Init("appcolor.ctl") ' Initialize color parameters
open "r",2%,"names.dat",512
w!=lof(2%)
if w!=0 then ' New file
call init.new.file(2%,512%) ' Initialise it
call mark.file.open(2%,512%) ' Mark it open
call bit.creatq(3%,"namesidx",40%) ' Create index
if aesb.fatal% or aesb.warning% then
call ae.error("NAMES - namesidx index creation error")
end if
call mark.file.closed(2%,512%) ' Mark it closed
end if
call mark.file.open(2%,512%) ' Mark open
field #2,2 as du$,40 as nm$,30 as tl$,440 as notes$ ' Fielding
call bit.open(3%,"namesidx") ' Open index
if aesb.fatal% then
call ae.error("NAMES - namesidx index opening error")
end if
call names.frame ' Display Screen
menu:
data 3,"Edit","Options","Exit"
data 5,"Insert","Amend","Delete","","Browse"
data 2,"Color preferences","Details"
data 1,"To DOS"
loop%=0%
while loop%=0%
call names.frame
call centre.text("NAMES Indexing Demonstration Program",1%)
call centre.text("By Roy Barrow",2%)
restore menu ' Menu data statements
gosub get.menu ' Put values in common array
call pull.down.menu ' Display & get menu options
if menu%=1% then ' Editing functions
if menop%=1% then ' Insert a new record
iloop%=0% ' For correct? Y/N
while iloop%=0%
call input.block(9%,19%,1%,40%,inm$,0%)
call ctrl.trim(inm$)
iloop%=1%
if len(inm$) then ' Good name
call input.block(11%,30%,1%,30%,tnum$,0%)
call input.block(13%,13%,8%,55%,hist$,0%)
call correct(iloop%) ' Get flag
end if
wend
if len(inm$) then ' Good record !
call get.avail.record(2%,512%,rr%)
call bit.ins(3%,inm$,rr%,success%)
get #2,rr%
lset nm$=inm$
lset tl$=tnum$
lset notes$=hist$
put #2,rr%
end if
end if
if menop%=2% then ' Amend an existing record
if xh%(3%,2%)<>0% then
dialog$(1%)="Select item to"
dialog$(2%)="amend from the"
dialog$(3%)="list on the left"
dialog$(4%)=""
dl$(1%)="Type in the initial search key value for the"
dl$(2%)="item that you wish to amend."
call Key.Select.Box(30%,dl$(),opt$,3%,ky$,rrec%,success%)
if rrec%>0% and success%>0% then
get #2,rrec%
gosub disp.frame
iloop%=0%
hist$=notes$
tnum$=tl$
while iloop%=0%
call input.block(11%,30%,1%,30%,tnum$,0%)
call input.block(13%,13%,8%,55%,hist$,0%)
call correct(iloop%) ' Get flag
wend
lset tl$=tnum$
lset notes$=hist$
put #2,rrec%
end if
else
dialog$(1%)="Sorry, no records to amend !"
dialog$(2%)="Use the INSERT option now."
call Press.Any.Key(2%)
end if
end if
if menop%=3% then ' Delete a record
if xh%(3%,2%)<>0% then
dialog$(1%)="Select item to"
dialog$(2%)="delete from the"
dialog$(3%)="list on the left"
dialog$(4%)=""
dl$(1%)="Type in the initial search key value for the"
dl$(2%)="item that you wish to delete."
call Key.Select.Box(30%,dl$(),opt$,3%,ky$,rrec%,success%)
if rrec%>0% and success%>0% then
get #2,rrec%
gosub disp.frame
dialog$(1%)="DELETE this record"
dialog$(2%)="Are you sure ?"
call yes.no(yn$)
if yn$="Y" then
call bit.kill(3%,ky$,rrec%,success%)
call Release.Avail.Record(2%,512%,rrec%)
end if
get #2,rrec%
lset tl$=string$(30%,0%)
lset notes$=string$(440%,0%)
lset nm$=string$(40%,0%)
put #2,rrec%
end if
else
dialog$(1%)="Sorry, no records to delete !"
dialog$(2%)="Use the INSERT option now."
call Press.Any.Key(2%)
end if
end if
if menop%=5% then ' Browse
if xh%(3%,2%)<>0% then
dialog$(1%)="Select item to"
dialog$(2%)="start browsing"
dialog$(3%)="at from the list"
dialog$(4%)="on the left."
dl$(1%)="Type in the initial search key value for the"
dl$(2%)="item that you wish to browse from."
call Key.Select.Box(30%,dl$(),opt$,3%,ky$,rrec%,success%)
if rrec%>0% and success%>0% then
get #2,rrec%
gosub disp.frame
iloop%=0%
while iloop%=0%
call qprint ("- for previous, + for next, ESC to exit",25%,10%)
call Get.Single( co%, ct%)
if ct%=1% then
if co%=asc("+") then
call bit.next(3%,ky$,rrec%,success%)
if rrec%>0% and success%>0% then
get #2,rrec%
gosub disp.frame
end if
end if
if co%=asc("-") then
call bit.prev(3%,ky$,rrec%,success%)
if rrec%>0% and success%>0% then
get #2,rrec%
gosub disp.frame
end if
end if
if co%=27% then
iloop%=1%
locate 25,1
call clreol
end if
end if
wend
end if
else
dialog$(1%)="Sorry, no records to browse !"
dialog$(2%)="Use the INSERT option now."
call Press.Any.Key(2%)
end if
end if
end if
if menu%=2% then ' Color & Details
if menop%=1% then ' It's color
call aecolins ' Color options
cls
call names.frame
end if
if menop%=2% then ' Display info
dialog$(1%)="NAMES, a simple demonstration of using the"
dialog$(2%)="binary tree indexing routines. This program"
dialog$(3%)="and the indexing, menu & dialogue routines"
dialog$(4%)="was written by Roy Barrow. If you want the"
dialog$(5%)="source code for these routines, then send "
dialog$(6%)="a contribution to:"
dialog$(7%)="R.Barrow, 3J-222 Church Street, Philadelphia"
dialog$(8%)="PA 19107. (215) 922-2557"
call Press.Any.Key(8%)
end if
end if
if menu%=3% then ' Exit
if menop%=1% then ' True Exit
dialog$(1%)="Exit to DOS, are you sure that"
dialog$(2%)="this is what you want to do ?"
call Yes.No(yn$)
if yn$="Y" then ' Yes, they're sure
loop%=1% ' Exit the endless loop (paradox)
call bit.close(3%) ' Close the index
call mark.file.closed(2%,512%)' Write parameters
close 2 ' Truly closed
end if
end if
end if
wend
locate 24,1
print
print
print "NAMES returning you to DOS";
end
rem $subtitle:'Read menu definitions from DATA statements'
rem $page
get.menu:
e.count%=0%
read mcount%
for mop%=1% to mcount%
e.count%=e.count%+1%
read ae.menu$(e.count%)
next mop%
for mop%=1% to mcount%
read sop%
for j%=1% to sop%
e.count%=e.count%+1%
read ae.menu$(e.count%)
next j%
ae.op%(mop%)=sop%
next mop%
return
disp.frame: ' Display text for selected record
call qprint(nm$,9%,19%)
call qprint(tl$,11%,30%)
for j%=1% to 8%
call qprint(mid$(notes$,(j%-1%)*55%+1%,55%),j%+12%,13%)
next j%
return
sub names.frame static
call qprint("╒════════════════════════════════════════════════════════════╕",8,10)
call qprint("│Name: │",9,10)
call qprint("├────────────────────────────────────────────────────────────┤",10,10)
call qprint("│Telephone Number: │",11,10)
call qprint("├────────────────────────────────────────────────────────────┤",12,10)
call qprint("│ │",13,10)
call qprint("│ │",14,10)
call qprint("│ │",15,10)
call qprint("│ │",16,10)
call qprint("│ │",17,10)
call qprint("│ │",18,10)
call qprint("│ │",19,10)
call qprint("│ │",20,10)
call qprint("╘═══════════════════════════NOTES════════════════════════════╛",21,10)
end sub ' names