home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
351-375
/
apd358
/
amos_source
/
bookbase.amos
/
bookbase.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1991-10-06
|
12KB
|
442 lines
'
' BookBase : Written by Kevin E.A. Hall of Irrelevant Software
' (If it's not irrelevant, we're not interested)
'
Set Buffer 60
Screen Open 1,320,256,32,Lowres
Unpack 5 To 1
VARS:
Dim NAME$(301),BOOK$(301),PUB$(301),PRICE$(301),SPC(1),FOUND(100)
TIMES=1 : REC=1 : TST=0 : ALT=0
Z=0 : NZ=1 : PAGE=0 : TFU=0 : NEED=0
Curs Off : Paper 25 : Pen 0
Wait Vbl : Limit Mouse
Reserve Zone 5
Set Zone 1,8,26 To 308,69
Set Zone 2,8,78 To 308,122
Set Zone 3,8,128 To 308,170
Set Zone 4,115,177 To 200,220
ZNES:
Set Zone 5,137,230 To 180,252
MENUS:
ALT=0
MUZ:
Pen 0
Menu$(1)=" Options "
Menu$(1,1)=" Load " : Menu$(1,2)=" Save " : Menu$(1,3)=" New "
Menu$(1,4)=" Print " : Menu$(1,5)=" Quit " : Menu$(1,6)=" About "
Menu$(2)=" Records "
Menu$(2,1)=" First " : Menu$(2,2)=" Last " : Menu$(2,3)=" Previous "
Menu$(2,4)=" Next " : Menu$(2,5)=" Delete " : Menu$(2,6)=" Alter "
Menu$(2,7)=" Goto " : Menu$(2,8)=" List "
Menu$(3)=" Search " : Menu$(3,1)=" Author " : Menu$(3,2)=" Title "
WHA:
On Menu Goto MENU1,MENU2,MENU3
On Menu On
If REC=301
NAME$(REC)="" : BOOK$(REC)="" : PUB$(REC)="" : PRICE$(REC)=""
Dec REC
Else
End If
LOP=1
Pen 0 : X=Mouse Zone : Y=Mouse Click
Curs Off : Clear Key
If X<>0 and Y=1
Pen 21 : Locate 7,1
Print " Adding Record Number.";TIMES;" "
Gosub Int(X)
Else
End If
If ALT>0
Locate 7,1 : Pen 21
Print "Altering Record Number.";TIMES;" "
Else
End If
Gosub BUTTON
F$=Inkey$
If Asc(F$)=29 Then Goto MENU2OPT3
If Asc(F$)=28 Then Goto MENU2OPT4
If NZ=0 Then Z=0
If Z>0 and Z<8 Then Gosub Int(Z)
If Y<>1 and ALT=0 and NEED=0 Then Menu On
Goto MUZ
1 Paste Bob 6,27,2
X=3 : Z=1 : Y=7 : TLE$="Author:" : GT=34
Gosub DISP
Paste Bob 6,27,1 : NAME$(TIMES)=B$
Return
2 Paste Bob 6,77,2
X=3 : Z=2 : Y=13 : TLE$="Title of Book:" : GT=34
Gosub DISP
Paste Bob 6,76,1 : BOOK$(TIMES)=B$
Return
3 Paste Bob 6,126,2
X=3 : Z=3 : Y=19 : TLE$="Publisher:" : GT=34
Gosub DISP
Paste Bob 6,126,1 : PUB$(TIMES)=B$
Return
4 Paste Bob 115,177,8
X=16 : Z=4 : Y=26 : TLE$="Price:" : GT=8
Gosub DISP
Paste Bob 115,177,7 : PRICE$(TIMES)=B$
Return
5 If Len(NAME$(301))>0 Then Return
If REC=300 Then Reset Zone 5
If TIMES=301 Then Return
If Len(NAME$(TIMES))=0 or Len(BOOK$(TIMES))=0 Then Goto NEEDMORE
NEED=0
Paste Bob 137,230,6 : Wait 10
Paste Bob 137,230,5
If ALT>0 Then TIMES=ALT-1
Inc TIMES : TST=1 : Inc REC : ALT=0 : Z=1 : NZ=1
If TIMES=301 Then Goto FULL
WIFFLE:
Paste Bob 6,28,1 : Paste Bob 6,77,1
Paste Bob 6,127,1 : Paste Bob 115,177,7
BUTTON:
Locate 7,1 : Pen 21
If ALT=0 Then Print " Display of Record No.";REC;" "
Pen 29
Locate 3,5 : Print "Author:"
Locate 3,11 : Print "Title of Book:" : Locate 3,17 : Print "Publisher:"
Locate 16,24 : Print "Price:"
Pen 5
Locate 3,7 : Print NAME$(REC)
Locate 3,13 : Print BOOK$(REC)
Locate 3,19 : Print PUB$(REC)
Locate 16,26 : Print PRICE$(REC)
Return
MENU1:
If Choice(2)=1 Then Goto MENU1OPT1
If Choice(2)=2 Then Goto MENU1OPT2
If Choice(2)=3 Then Goto MENU1OPT3
If Choice(2)=4 Then Goto MENU1OPT4
If Choice(2)=5 Then Goto MENU1OPT5
If Choice(2)=6 Then Goto MENU1OPT6
MENU2:
If Choice(2)=1 Then Goto MENU2OPT1
If Choice(2)=2 Then Goto MENU2OPT2
If Choice(2)=3 Then Goto MENU2OPT3
If Choice(2)=4 Then Goto MENU2OPT4
If Choice(2)=5 Then Goto MENU2OPT5
If Choice(2)=6 Then Goto MENU2OPT6
If Choice(2)=7 Then Goto MENU2OPT7
If Choice(2)=8 Then Goto MENU2OPT8
MENU3:
If Choice(2)=1 Then Goto MENU3OPT1
If Choice(2)=2 Then Goto MENU3OPT2
MENU1OPT1:
FLE$=Fsel$("*.DAT","","Load Data File")
If FLE$="" Then Goto MENUS
If Not Exist(FLE$+".bookbase") Then Goto WRONG
If Not Exist(FLE$) Then Goto NOFOUND
Open In 1,FLE$ : Input #1,TIMES,REC,TST
For N=1 To TIMES-1
Input #1,NAME$(N),BOOK$(N),PUB$(N),PRICE$(N)
Next N
Close 1
If TIMES=301 Then Reset Zone 5 : TFU=0 : REC=TIMES-1
Gosub WIFFLE : Goto MENUS
MENU1OPT2:
FLE$=Fsel$("*.DAT","","Save Data File")
If FLE$="" and TIMES>300 Then TFU=0 : Goto FINI
If FLE$="" Then Goto MENUS
FLE2$=FLE$+".bookbase"
Open Out 1,FLE2$
Print #1,"Dummy File - Do NOT delete"
Close 1
If Instr(FLE$,".")=0 Then FLE$=FLE$+".DAT"
Open Out 1,FLE$ : Print #1,TIMES;",";REC;",";TST
For N=1 To TIMES-1
Print #1,NAME$(N);",";BOOK$(N);",";PUB$(N);",";PRICE$(N)
Next N
Close 1
If TIMES=301 Then TFU=0 : Goto FINI
Gosub WIFFLE : Goto MENUS
MENU1OPT3:
Gosub RUSURE
For N=0 To 301
NAME$(N)="" : BOOK$(N)="" : PUB$(N)="" : PRICE$(N)="" : Next N
Paste Bob 6,28,1 : Paste Bob 6,77,1
Paste Bob 6,126,1 :
Paste Bob 115,177,7
TIMES=1 : TST=0 : REC=1 : K=Free : Goto ZNES
MENU1OPT4:
Gosub NORECS
For M=1 To TIMES Step 2
LTH=Len(NAME$(M)) : Lprint NAME$(M); : Gosub PRSPC : Lprint NAME$(M+1)
LTH=Len(BOOK$(M)) : Lprint BOOK$(M); : Gosub PRSPC : Lprint BOOK$(M+1)
LTH=Len(PUB$(M)) : Lprint PUB$(M); : Gosub PRSPC : Lprint PUB$(M+1)
LTH=Len(PRICE$(M)) : Lprint PRICE$(M); : Gosub PRSPC : Lprint PRICE$(M+1)
Lprint : Lprint
Next M
Goto MENUS
PRSPC:
For Z=LTH To 40 : Lprint " "; : Next Z : Return
MENU1OPT5:
TFU=1
Gosub RUSURE
Screen Close 1
End
MENU1OPT6:
Wind Save
Wind Open 1,16,48,32,10,16 : Border 1,0,0 : Paper 22 : Curs Off : Clw
Print : Pen 10 : Print " Book-Base V1.1 " : Pen 8 :
Print : Print " Written by Kevin E.A. Hall"
Print " of Irrelevant Software" : Print :
Pen 2 : Print " Press left mouse button"
Do
If Mouse Key=1 Then Wind Close : Goto MENUS Else Loop
MENU2OPT1:
Gosub NORECS : REC=1 : Gosub WIFFLE : Goto MENUS
MENU2OPT2:
Gosub NORECS : REC=(TIMES-1) : Gosub WIFFLE : Goto MENUS
MENU2OPT3:
Gosub NORECS : If REC>1 Then Dec REC
Gosub WIFFLE : Goto MENUS
MENU2OPT4:
Gosub NORECS : If REC+1<=TIMES-1 Then Inc REC
Gosub WIFFLE : Goto MENUS
MENU2OPT5:
If REC=301 Then Return
TFU=1
Gosub NORECS
Gosub RUSURE :
DEL=REC
For N=DEL To TIMES-1
NAME$(N)=NAME$(N+1) : BOOK$(N)=BOOK$(N+1)
PUB$(N)=PUB$(N+1) : PRICE$(N)=PRICE$(N+1)
Next N
K=Free
Dec TIMES
If TIMES=300 Then Gosub WIFFLE : Goto ZNES
If TIMES=1 Then TST=0 : REC=TIMES : Gosub WIFFLE
Goto MENUS
MENU2OPT6:
If REC>=301 Then Return
If REC<301 Then Set Zone 5,137,230 To 180,252
NZ=0
Menu Off
Gosub NORECS
ALT=TIMES
Gosub WIFFLE : TIMES=REC : Goto WHA
DISP:
Locate 7,1 : Pen 21 : Print " Adding Record Number.";TIMES;" "
If ALT=0 Then If REC<TIMES Then REC=TIMES
Locate X,Y-2 : Print TLE$
Locate X,Y : Pen 29 : Print "_" : Pen 21
B$=""
MAIN:
T$=Inkey$ : T=Asc(T$)
If T=8 and LOP>1
A$=Left$(B$,Len(B$)-1)
Locate X,Y : Print A$;
Pen 29 : Print "_ " : Pen 21
B$=A$ : Dec LOP
Else
End If
If Mouse Zone=0 Then Z=0 : Return
If LOP>GT or T=13 Then Inc Z : LOP=1 : Return
If T>31 and T<255
B$=B$+T$ :
Locate X,Y : Print B$; :
Pen 29 : Print "_"; : Pen 21 :
Inc LOP
Else
End If
Goto MAIN
MENU2OPT7:
SEL=1
Gosub NORECS
Wind Save : Wind Open 1,2,2,35,11,1 : Curs Off
Paper 0 : Pen 26 : Border 1,0,2 : Clw
Print " Current existing records:"; : Pen 5 : Print TIMES-1 : Pen 26
Print " Press Left mouse button to" : Print " increase selection. Right"
Print " button to decrease it." : Print
Print " Hit any key to accept number"
Menu Off
Do
If SEL>TIMES-1 Then SEL=TIMES-1
If SEL<1 Then SEL=1
Locate 5,7 : Pen 26 : Print "Selected Record - "; : Pen 5 : Print SEL;" "
T=Mouse Click
If T=2 Then Dec SEL
If T=1 Then Inc SEL
T$=Inkey$
If T$<>""
REC=SEL
Wind Close
Menu On
Gosub WIFFLE
Goto MENUS
Else
End If
Loop
MENU2OPT8:
PAGE=0
PGE=1 : PGES=0
For D=1 To TIMES-1 Step 5 : PGES=PGES+1 : Next D
If TIMES-1<=5 Then PAGE=1
FRM=1 : LAS=5
Gosub NORECS
Screen Open 2,640,512,8,Hires : Paper 0 : Cls
Wind Open 1,0,0,79,31,1 : Curs Off : Paper 0 : Clw : Border 0,0,7
Title Top "Full record list (Press ESC to quit)"
LOPZ:
Clear Key
If PGE<1 Then PGE=1
Clw : Locate 62,0 : Pen 6 : Print "Page";PGE;" Of";PGES : Locate 0,2
If LAS>=TIMES Then LAS=TIMES-1
For N=FRM To LAS
SPC(0)=34-Len(NAME$(N))+1 : SPC(1)=34-Len(PUB$(N))+1
Pen 1 : Print " Author";Space$(28);" Title"
Pen 2 : Print " ";NAME$(N);Space$(SPC(0));BOOK$(N) : Pen 1
Print " Publisher";Space$(25);" Price" : Pen 2
Print " ";PUB$(N);Space$(SPC(1));PRICE$(N) : Print
Next N : Pen 6 : Locate 1,27
If LAS>=TIMES-1 Then Goto EOB
Print " Left button to move on a page, right button to move back a page"
Do
Y=Mouse Click
T$=Inkey$ : If Asc(T$)=27 Then Goto ESC
If Y=1 Then Goto PAGEON
If Y=2 Then Goto PAGEBACK
Loop
PAGEON:
FRM=LAS+1 : LAS=LAS+5
Inc PGE
Goto LOPZ
EOB:
Pen 6 : Locate 1,27
Print " End of BookBase: Left button to exit, right button to go back a page"
Do
Y=Mouse Click
T$=Inkey$ : If Asc(T$)=27 Then Goto ESC
If Y=1 Then Goto ESC
If Y=2 and PAGE=0 Then Goto PAGEBACK
Loop
ESC:
Wind Close : Screen Close 2
Goto MENUS
PAGEBACK:
FRM=FRM-5 : If FRM<1 Then FRM=1
LAS=FRM+4 : Dec PGE
Goto LOPZ
MENU3OPT1:
Gosub NORECS : D=0 : FOU=0 : NM$="Author" : Gosub SEARCH
Title Top "Author Search"
For N=1 To TIMES
If Upper$(NAME$(N))=Upper$(NAM$)
REC=N
FOUND(D)=N : Inc D
Pen 3 : Print " Record";N,
Pen 4 : Inc FOU
Inc CLO
Else
End If
If CLO=3 Then CLO=0 : Print
Next N : Print : Print : Pen 1 : Print " Records matched ";FOU
Pen 24 : Print : Print " Press left mouse button" : Goto HANGONAMO
MENU3OPT2:
Gosub NORECS : FOU=0 : D=0 : NM$="Title" : Gosub SEARCH
Title Top "Book Title Search"
For N=1 To TIMES :
If Upper$(BOOK$(N))=Upper$(NAM$)
REC=N
FOUND(D)=N : Inc D
Pen 3 : Print " Record";N,
Pen 4 : Inc FOU
Inc CLO
Else
End If
If CLO=3 Then CLO=0 : Print
Next N : Print : Print : Pen 1 : Print " Records matched ";FOU
Pen 24 : Print : Print " Press left mouse button"
HANGONAMO:
Repeat
Until Mouse Click=1
Wind Close
If FOU=0 Then Goto MENUS
For B=0 To D-1 : REC=FOUND(B)
Gosub WIFFLE
Do
M=Mouse Click
If M=0 Then Loop
If M=2 Then Goto MENUS
Next B
Goto MENUS
NORECS:
If TST>0 Then Return
Wind Save : Wind Open 1,16,16,32,6,1 : Curs Off
Paper 0 : Pen 7 : Border 1,0,5 : Clw
Print " No records in memory." : Print
Pen 2 : Print " Press the left mouse button"
Do
If Mouse Click=1 Then Wind Close : Goto MENUS
Loop
NOFOUND:
Wind Save : Wind Open 1,16,16,25,5,1 : Curs Off
Paper 0 : Pen 5 : Border 1,0,2 : Clw
Print " File not found" : Print " Press a mouse button"
Do
T=Mouse Click
If T<>0 Then Wind Close : Goto MENUS
Loop
RUSURE:
If REC>301 and TFU=0 Then Return
Menu Off
Wind Save : Wind Open 1,5,20,23,7,1 : Curs Off
Paper 0 : Pen 2 : Border 1,0,9 : Clw
Print " Are you sure?" : Print : Pen 12 : Print " Left button - Yes"
Print " Right button - No"
Do
T=Mouse Click
If T=2 Then Wind Close : Menu On : Goto MENUS
If T=1 Then Wind Close : Return
Loop
SEARCH:
Wind Save : Wind Open 1,0,5,36,6,1 : Curs Off
Paper 0 : Pen 8 : Border 1,0,7
FIND:
Clw : Print NM$;" to search for?" : Print : Pen 10 : Input "";NAM$
If NAM$="" Then Goto FIND
Wind Size 38,25 : Curs Off : Clw : Print
Print " Matched records found in : "
CLO=0
Return
Do
T=Mouse Click
If T=2 Then Wind Close : Menu On : Goto MENUS
If T=1 Then Wind Close : Return
Loop
FULL:
Wind Save : Wind Open 1,5,20,23,6,1 : Curs Off
Paper 0 : Pen 13 : Border 1,0,9 : Clw
Print " DataBase Full" : Print : Pen 12 : Print " Press mouse button"
Do
T=Mouse Click
If T<>0 Then Wind Close : Goto MENU1OPT2
Loop
FINI:
Wind Save : Wind Open 1,5,10,25,7,1 : Curs Off
Paper 0 : Pen 11 : Border 1,0,10 : Clw
Print " Restart Program?" : Print
Pen 12 : Print " Press mouse button"
Do
T=Mouse Click
If T<>0 Then Wind Close : Goto MENU1OPT3
Loop
NEEDMORE:
Wind Save : Wind Open 1,5,10,20,6,1 : Curs Off
Paper 0 : Pen 19 : Border 1,0,1 : Clw
Print : Print " Need More Input " : Wait 40 : Wind Close
Z=1 : NEED=1
Goto MUZ
WRONG:
Wind Save : Wind Open 1,16,16,25,5,1 : Curs Off
Paper 0 : Pen 2 : Border 1,0,5 : Clw
Print " Incorrect File Type!" : Pen 27 : Print " Press a mouse button"
Do
T=Mouse Click
If T<>0 Then Wind Close : Goto MENUS
Loop