home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software 2000
/
Software 2000 Volume 1 (Disc 1 of 2).iso
/
utilities
/
u303.dms
/
in.adf
/
BomBase1_0.AMOS
/
BomBase1_0.amosSourceCode
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
AMOS Source Code
|
1990-11-07
|
29.1 KB
|
1,214 lines
Screen Open 0,640,300,16,Hires
Rem **************************
Rem * The Set-Up Routine *
Rem **************************
Break Off
Dim FS$(10),FS(10),M$(10),C$(10),N$(10),K$(10),DEL(80)
DELETED=0
For F=1 To 10
FS(F)=1
Next F
Wind Save
Paper 0
Cls
CS
VMR=1 : VD=0
WO["Database Editing Window","Inputting Window","File Information","Keyboard Shortcuts"]
MENUS
PTH$="Apd76:"
DBF$="temp"
STATUS=0
Global I$,VZ2,VMR,VD,K$(),N$(),DELETED,DEL(),C$(),X$,Z$,ESC,Q$,PTH$,DBF$,FS$(),FS(),FIE,STATUS,FI$,CD$,LOT,M$()
Window 1
KEY1
2 AC
Menu On
Do
Q$=Inkey$ : Q$=Upper$(Q$) : If Q$="" Then Goto ILO
If Q$="N" Then NEW : Goto 2
If Q$="O" Then OPEN : Goto 2
If Q$="D" Then DELETE : Goto 2
If Q$="U" Then UNLOAD : Goto 2
If Q$="Q" Then QUIT : Goto 2
If Q$="A" Then AREC : Goto 2
If Q$="M" Then MREC : Goto 2
If Q$="E" Then DREC : Goto 2
If Q$="F" Then EFD : Goto 2
If Q$="P" Then PAR : Goto 2
If Q$="V" Then VR : Goto 2
If Q$="S" Then Gosub 5000 : Goto 2
If Q$="C" Then SER : Goto 2
If Q$="L" Then LIF : Goto 2
If Q$="*" Then VID : Goto 2
Rem If Q$="I" Then AII : Goto 2
Rem If Q$="X" Then FLF : Goto 2
Goto 2
ILO:
On Menu Gosub PROJECT,ED,OUT,MAN,UTILS
On Menu On
Loop
Rem *********************
Rem * Keyboard shorts 1 *
Rem *********************
Procedure KEY1
Window 4
Clw
Pen 2
Print "N = New File"
Print "O = Open File"
Print "D = Delete File"
Print "U = UnLoad File"
Print "Q = Quit"
Print "A = Add Records"
Print "M = Amend Records"
Print "E = Delete Records"
Print "F = Edit File Data"
Print "P = Print All Records"
Print "V = View Records"
Print "S = Sort Records"
Print "C = Search Records"
Print "L = List On A Field"
Rem Print "I = Write ASCII file"
Rem Print "X = Write Fixed len. file"
Print "* = Validate"
Window 1
End Proc
Rem ***********************
Rem * Write in ASCII form *
Rem ***********************
Procedure AII
Window 1 : Clw : Pen 2
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you want to write in ASCII(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Clw
Print "Enter name for your ASCII file-"
AII1:
SLI[0,1,20,"",14,13,0,0]
If ESC=1 Then Clw : Pop Proc
If Z$=Space$(20) Then Clw : Pop Proc
For F=20 To 1 Step -1
If Mid$(Z$,F,1)<>" " Then Z$=Mid$(Z$,1,F) : Goto AII6
Next F
AII6:
If Exist(Z$) Then Print : Print "This file already exists" : PAUSE : Locate 0,3 : Cline : Goto AII1
Print
Pen 2
Print "Are you sure you want to continue(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Open Out 2,Z$
Clw
For F=1 To LOT-DELETED
Z2=F
Locate 0,0 : Print "Current Record-";F
For G=1 To LOT
If DELETED=0 Then Goto AII2
For E=1 To 80
If DEL(E)=G and G<=Z2 Then Z2=Z2+1 : Goto AII3
Next E
AII3:
If G>Z2 Then Goto AII2
Next G
AII2:
Get 1,Z2
OUT$="" : J1$=Chr$(34) : J2$=Chr$(34)+","
For I=1 To FIE
If I<FIE Then OUT$=OUT$+J1$+M$(I)+J2$
If I=FIE Then OUT$=OUT$+J1$+M$(I)+J2$
Next I
Print #2,OUT$
Next F
Close 2
PAUSE: Clw
End Proc
Rem *************************
Rem * Write in Fixed Length *
Rem *************************
Procedure FLF
End Proc
Rem ******************************
Rem * Viewing keyboard Shortcuts *
Rem ******************************
Procedure KEY2
Window 4
Clw
Pen 2
Print "Curs U = Next Record"
Print "Curs D = Previous Record"
Print " F = First Record"
Print " L = Last Record"
Print " P = Print Record"
Print " Q = Quit to main"
Window 1
End Proc
Rem ******************************
Rem * Selecting the Project Menu *
Rem ******************************
PROJECT:
INAC
If Choice(2)=1 Then NEW : Goto 2
If Choice(2)=2 Then OPEN : Goto 2
If Choice(2)=3 Then DELETE : Goto 2
If Choice(2)=4 Then UNLOAD : Goto 2
If Choice(2)=6 Then QUIT : Goto 2
Goto 2
ED:
INAC
If Choice(2)=1 Then AREC : Goto 2
If Choice(2)=2 Then MREC : Goto 2
If Choice(2)=3 Then DREC : Goto 2
If Choice(2)=4 Then EFD : Goto 2
Goto 2
OUT:
INAC
If Choice(2)=1 Then PAR : Goto 2
If Choice(2)=2 Then VR : Goto 2
Goto 2
MAN:
INAC
If Choice(2)=1 Then Gosub 5000 : Goto 2
If Choice(2)=2 Then SER : Goto 2
If Choice(2)=3 Then LIF : Goto 2
Goto 2
UTILS:
INAC
If Choice(2)=1 Then VID : Goto 2
If Choice(2)=2 Then Goto WOT
WOT:
If Choice(3)=1 Then AII : Goto 2
If Choice(3)=2 Then FLF : Goto 2
Rem *******************
Rem * List on a field *
Rem *******************
Procedure LIF
Window 1
Clw
Pen 2
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to list on a field(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Clw
For F=1 To FIE
If F>9 Then Print F;":";FS$(F)
If F<10 Then Print " ";F;":";FS$(F)
Next F
Print
Print "Which field do you wish to list on-"
LIF1:
SLI[0,FIE+2,2,"",14,13,0,0]
If Val(Z$)>FIE Then Locate 4,FIE+2 : Print "Not Valid" : PAUSE : Locate 4,FIE+2 : Print " " : Pen 2 : Goto LIF1
If Val(Z$)<1 Then Clw : Pop Proc
CV=Val(Z$)
Clw
Pen 2
Print "Display to (S)creen or (P)rinter-"
LIF3:
SLI[0,1,1,"",14,13,0,0]
Z$=Upper$(Z$)
If(Z$<>"S") and(Z$<>"P") Then Locate 4,1 : Print "Not Valid" : PAUSE : Locate 4,1 : Print " " : Pen 2 : Goto LIF3
TP$=Z$
Pen 2
If Z$="P" Then Goto LIF5
Print
Print "(P)ause or (M)ouse click between records-"
LIF4:
SLI[0,4,1,"",14,13,0,0]
Z$=Upper$(Z$)
If(Z$<>"P") and(Z$<>"M") Then Locate 4,4 : Print "Not Valid" : PAUSE : Locate 4,4 : Print " " : Pen 2 : Goto LIF4
TP2$=Z$
LIF5:
Print
Pen 2
Print "Are you sure you want to execute(Y/N)?"
Pen 14 : Print "Press ESCAPE during listing to quit"
Pen 2
QIN
If Q$<>"Y" Then Clw : Pop Proc
If TP$="P" Then Lprint "List on field - ";FS$(CV);" - Field number:";CV : Lprint
Clw
For F=1 To LOT-DELETED
Z2=F
For G=1 To LOT
If DELETED=0 Then Goto LIF6
For E=1 To 80
If DEL(E)=G and G<=Z2 Then Z2=Z2+1 : Goto LIF7
Next E
LIF7:
If G>Z2 Then Goto LIF6
Next G
LIF6:
Get 1,Z2
If TP$="S" Then Gosub LIF8
If TP$="P" Then Gosub LIF9
LIF10:
Next F
Pen 14 : Print "The listing is complete - press RETURN" : Pen 2
LIF50:
QIN
If Q$<>Chr$(13) Then Goto LIF50
Clw : Pop Proc
LIF8:
Print Using "#####";F;
Print ":";M$(CV)
Q$=Inkey$
If Q$=Chr$(27) Then Clw : Pop Proc
If TP2$="P" Then PAUSE
If TP2$="M" Then Repeat : Until Mouse Key
Return
LIF9:
Lprint Using "#####";F;
Lprint ":";M$(CV)
Return
End Proc
Rem ***********************
Rem * Search The Database *
Rem ***********************
Procedure SER
Clw : Pen 2
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to search database(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Clw
For F=1 To FIE
If F>9 Then Print F;":";FS$(F)
If F<10 Then Print " ";F;":";FS$(F)
Next F
Print
Print "Which field do you wish to search on- "
SER1:
SLI[0,FIE+2,2,"",14,13,0,0]
If Val(Z$)>FIE Then Locate 4,FIE+2 : Print "Not Valid" : PAUSE : Locate 4,FIE+2 : Print " " : Pen 2 : Goto SER1
If Val(Z$)<1 Then Clw : Pop Proc
CV=Val(Z$)
Print
Clw
Pen 2
Print "Enter text you wish to search for-"
SLI[0,1,FS(CV),"",14,13,0,0]
CV$=Z$
Print
Pen 2
Print "Is this a (F)ull or (P)artial search-"
SER2:
SLI[0,4,1,"",14,13,0,0]
Z$=Upper$(Z$)
If(Z$<>"P") and(Z$<>"F") Then Locate 4,4 : Print "Not Valid" : PAUSE : Locate 4,4 : Print " " : Pen 2 : Goto SER2
TP$=Z$
Print
Pen 2
Print "View records on (S)creen or (P)rinter-"
SER3:
SLI[0,7,1,"",14,13,0,0]
Z$=Upper$(Z$)
If(Z$<>"S") and(Z$<>"P") Then Locate 4,7 : Print "Not Valid" : PAUSE : Locate 4,7 : Print " " : Pen 2 : Goto SER3
TP2$=Z$
Print
Pen 2
Print "Is this a (C)ase sensitive search or (I)gnore-"
SER77:
SLI[0,10,1,"",14,13,0,0]
Z$=Upper$(Z$)
If(Z$<>"C") and(Z$<>"I") Then Locate 4,10 : Print "Not Valid" : PAUSE : Locate 4,10 : Print " " : Pen 2 : Goto SER77
CS$=Z$
Print
Pen 2
Print "Do you wish to execute the search(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Clw
If TP2$="S" Then Locate 0,(FIE*2)+4 : Print "Please Wait - Searching Database"
CC=0
PL=66
405 PL=PL-(FIE+4) : If PL>FIE+4 Then CC=CC+1 : Goto 405
PAGE=1 : PP=1
C=1
SER4:
If TP2$="P" Then Lprint "Search for - ";CV$;" - on Field - ";FS$(CV)
For F=1 To LOT-DELETED
Z2=F
For G=1 To LOT
If DELETED=0 Then Goto SER5
For E=1 To 80
If DEL(E)=G and G<=Z2 Then Z2=Z2+1 : Goto SER6
Next E
SER6:
If G>Z2 Then Goto SER5
Next G
SER5:
Get 1,Z2
If TP$="F" Then Gosub SER7
If TP$="P" Then Gosub SER8
SER20:
Next F
Clw
Print "The search is complete!" : PAUSE : Clw
Pop Proc
SER7:
If(CS$="C") and(CV$=M$(CV)) Then Goto SER9
If(CS$="I") and(Upper$(CV$)=Upper$(M$(CV))) Then Goto SER9
Return
SER8:
For I=FS(CV) To 1 Step -1
If Mid$(CV$,I,1)<>" " Then I$=Mid$(CV$,1,I) : Goto SER10
Next I
SER10:
For I=1 To FS(CV)-Len(I$)
If(CS$="C") and(Mid$(M$(CV),I,Len(I$))=I$) Then Goto SER9
If(CS$="I") and(Upper$(Mid$(M$(CV),I,Len(I$)))=Upper$(I$)) Then Goto SER9
Next I
Return
SER9:
If TP2$="S" Then Goto SER12
If TP2$="P" Then Goto SER11
SER11:
CUSTLIST2:
If C=1 Then Lprint Space$(70);"PAGE: ";PAGE : Lprint String$("-",60)
Lprint "Record Number:";F
Lprint "==================="
For O=1 To FIE
Lprint FS$(O);": ";M$(O)
Next O
Lprint String$("-",60)
If C=CC Then Lprint Chr$(12) : C=1 : PAGE=PAGE+1
C=C+1
Return
SER12:
Locate 0,0 : Print "Record Number-"; : Pen 14 : Print F : Pen 2
For W=1 To FIE
Locate 0,(W*2) : If W<10 Then Print " ";W;":"; Else Print W;":";
Print FS$(W)
Locate 2,1+(W*2) : Pen 14 : Print M$(W) : Pen 2
Next W
Print
Locate 0,(FIE*2)+4 : Cline : Print "Press RETURN to continue or ESCAPE to quit"
SER50:
QIN
If Q$=Chr$(27) Then Clw : Pop Proc
If Q$<>Chr$(13) Then Goto SER50
Locate 0,(FIE*2)+4 : Cline : Print "Please Wait - Searching Database"
Return
End Proc
Rem *********************
Rem * Validate Database *
Rem *********************
Procedure VID
Clw : Pen 2
If STATUS=0 Then Print "There is no database file to be validated" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to validate this database"
Print "It can take a while depending on no. of records"
Print "(Y/N)?" : QIN
If Q$<>"Y" Then Clw : Pop Proc
Open Random 2,"temp"
F1=FS(1)
F2=FS(2)
F3=FS(3)
F4=FS(4)
F5=FS(5)
F6=FS(6)
F7=FS(7)
F8=FS(8)
F9=FS(9)
F10=FS(10)
Field 2,F1 As N$(1),F2 As N$(2),F3 As N$(3),F4 As N$(4),F5 As N$(5),F6 As N$(6),F7 As N$(7),F8 As N$(8),F9 As N$(9),F10 As N$(10)
Clw
SS=1
For F=1 To LOT
Locate 0,0 : Print "Current record-";SS
For G=1 To 80
If DEL(G)=F Then Goto VA1
Next G
Get 1,F
For O=1 To 10
N$(O)=M$(O)
Next O
Put 2,SS
SS=SS+1
VA1:
Next F
Pen 2
Close 1
Close 2
Kill DBF$+".DBF"
Rename "temp" To DBF$+".DBF"
Open Random 1,DBF$+".DBF"
F1=FS(1)
F2=FS(2)
F3=FS(3)
F4=FS(4)
F5=FS(5)
F6=FS(6)
F7=FS(7)
F8=FS(8)
F9=FS(9)
F10=FS(10)
Field 1,F1 As M$(1),F2 As M$(2),F3 As M$(3),F4 As M$(4),F5 As M$(5),F6 As M$(6),F7 As M$(7),F8 As M$(8),F9 As M$(9),F10 As M$(10)
DELETED=0
For F=1 To 80
DEL(F)=0
Next F
Open Out 2,DBF$+".IDX"
O$=Mid$(Str$(FIE),2,2)
OUT$=FI$+CD$+O$
For F=1 To FIE
O$=Mid$(Str$(FS(F)),2,2)
O$=O$+Space$(3-Len(O$))
OUT$=OUT$+FS$(F)+O$
Next F
Print #2,OUT$
Print #2,Str$(DELETED)
For F=1 To 80
Print #2,Str$(DEL(F))
Next F
Close 2
PAUSE
Clw
LOT=SS-1
End Proc
Rem ****************
Rem * View Records *
Rem ****************
Procedure VR
VMR=1
If LOT-DELETED<1 Then Clw : Pop Proc
Window 1 : Clw : Pen 2
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you want to view records(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Clw
Menu Del
KEY2
MENUS2
VMR=1
Gosub VR3
VR1:
Menu On
Q$=Inkey$ : Q$=Upper$(Q$) : If Q$="" Then Goto VD9
If Q$=Chr$(30) Then VMR=VMR+1 : Gosub VR3 : Goto VR1
If Q$=Chr$(31) Then VMR=VMR-1 : Gosub VR3 : Goto VR1
If Q$="F" Then VMR=1 : Gosub VR3 : Goto VR1
If Q$="L" Then VMR=LOT-DELETED : Gosub VR3 : Goto VR1
If Q$="P" Then PRIM=1 : Gosub VR3 : Goto VR1
If Q$="Q" Then Menu Off : MENUS : Clw : Pen 2 : KEY1 : Pop Proc
Goto VR1
VD9:
On Menu Goto VR2
On Menu On
Goto VR1
VR2:
PRIM=0
If Choice(2)=1 Then VMR=VMR+1 : Gosub VR3 : Goto VR1
If Choice(2)=2 Then VMR=VMR-1 : Gosub VR3 : Goto VR1
If Choice(2)=3 Then VMR=1 : Gosub VR3 : Goto VR1
If Choice(2)=4 Then VMR=LOT-DELETED : Gosub VR3 : Goto VR1
If Choice(2)=5 Then PRIM=1 : Gosub VR3 : Goto VR1
If Choice(2)=6 Then Menu Off : MENUS : Clw : Pen 2 : KEY1 : Pop Proc
Goto VR1
VR3:
If VMR>LOT-DELETED Then VMR=VMR-1
If VMR<1 Then VMR=1
VZ2=VMR
If DELETED=0 Then Goto VR4
For G=1 To LOT
For E=1 To DELETED
If DEL(E)=G and G<=VZ2 Then VZ2=VZ2+1 : Goto VR5
Next E
VR5:
If G>VZ2 Then Goto VR4
Next G
VR4:
If PRIM=1 Then Goto VR7
Locate 0,0 : Pen 2 : Print "Record-"; : Pen 14 : Print VMR;" " : Pen 2
Get 1,VZ2
For F=1 To FIE
Pen 2 : Locate 0,F*2 : If F<9 Then Print " ";F;":"; Else Print F;":";
Print FS$(F)
Locate 2,(F*2)+1 : Pen 14 : Print M$(F) : Pen 2
Next F
Return
VR7:
Lprint String$("-",60)
Lprint "Record Number:";VMR
Lprint "==================="
For F=1 To FIE
Lprint FS$(F);": ";M$(F)
Next F
Lprint String$("-",60)
Return
End Proc
Rem ***********************
Rem * The second menu bar *
Rem ***********************
Procedure MENUS2
Menu$(1)=A$+"View Records "+B$
A$="(ss 1)" : B$="(ss 0)"
Menu$(1,1)=" Next Record "
Menu$(1,2)=" Previous Record "
Menu$(1,3)=" First Record "
Menu$(1,4)=" Last Record "
Menu$(1,5)=" Print Record "
Menu$(1,6)=" Quit to Main "
End Proc
Rem ******************
Rem * Delete Records *
Rem ******************
Procedure DREC
Window 1 : Clw : Pen 2
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
If DELETED=80 Then Print "Please validate file before deleting more records" : PAUSE : Clw : Pop Proc
Print "Are you sure you want to delete records(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
102 Clw
Pen 2
Print "Please enter record number you wish to delete"
101 SLI[0,1,6,"",14,13,0,0]
If Val(Z$)>LOT-DELETED Then Locate 10,1 : Print "Not Valid" : PAUSE : Locate 10,1 : Print " " : Goto 101
If Val(Z$)<1 Then Clw : Pen 2 : Pop Proc
For F=1 To 10
M$(F)=""
Next F
VZ=Val(Z$)
If DELETED=0 Then Goto JMP3
For G=1 To LOT
For F=1 To DELETED
If DEL(F)=G and G<=VZ Then VZ=VZ+1 : Goto JMP4
Next F
JMP4:
If G>VZ Then Goto JMP3
Next G
JMP3:
Get 1,VZ
Print
For Z=1 To FIE
Pen 2 : Locate 0,(Z*2)+3 : If Z<9 Then Print " ";Z;":"; Else Print Z;":";
Print FS$(Z)
Locate 2,(Z*2)+4 : Pen 14 : Print M$(Z) : Pen 2
Next Z
Print
Print "Are you sure you wish to delete this(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
For F=1 To FIE
M$(F)=""
Next F
Put 1,VZ
DEL(DELETED+1)=VZ
DELETED=DELETED+1
Z2UP
Goto 102
End Proc
Rem ******************
Rem * Edit File Data *
Rem ******************
Procedure EFD
Window 1 : Clw : Pen 2
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to edit file data(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Clw
Print "Please enter new filenote-"
SLI[0,1,45,FI$,14,13,0,0]
FI$=Z$
Print
Pen 2
Print "Please enter creation date-"
SLI[0,4,10,CD$,14,13,0,0]
CD$=Z$
Z2UP
Window 1 : Clw
End Proc
Rem *********************
Rem * Print all records *
Rem *********************
Procedure PAR
Clw : Window 1 : Pen 2
CC=0
PL=66
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to print(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Print
Print "Press "; : Pen 14 : Print "RETURN "; : Pen 2 : Print "when ready to print"
41 QIN
If Q$=Chr$(13) Then Goto 40
Goto 41
40 PL=PL-(FIE+4) : If PL>FIE+4 Then CC=CC+1 : Goto 40
CUSTLIST:
PAGE=1 : PP=1 : Lprint Space$(70);"PAGE: ";PAGE
Lprint String$("-",60)
FF=1
For F=1 To LOT
For G=1 To DELETED
If F=DEL(G) Then Goto 43
Next G
Get 1,F
Lprint "Record Number:";FF
Lprint "==================="
FF=FF+1
For G=1 To FIE
Lprint FS$(G);": ";M$(G)
Next G
Lprint String$("-",60)
If C=CC Then Lprint Chr$(12) : C=1 : PAGE=PAGE+1 : Lprint Space$(70);"PAGE: ";PAGE : Lprint String$("-",60) : Goto 43
C=C+1
43 Next F
Lprint Chr$(12)
Clw
End Proc
Rem *****************
Rem * Amend Records *
Rem *****************
Procedure MREC
Window 1 : Pen 2
Clw
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to amend records(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
30 Clw
Pen 2
Print "Please enter number of record that you wish"
Print "to amend(press return to quit)- "
SLI[32,1,5,"",14,13,0,0]
If Val(Z$)>LOT-DELETED Then Locate 35,1 : Print "Not Valid" : PAUSE : Locate 35,1 : Print " " : Pen 2 : Goto 30
If Val(Z$)>0 Then Goto 31
If Val(Z$)<1 Then Clw : Pop Proc
Goto 30
31 VZ=Val(Z$) : VZ2=VZ
If DELETED=0 Then Goto JMP1
For G=1 To LOT
For F=1 To DELETED
If DEL(F)=G and G<=VZ2 Then VZ2=VZ2+1 : Goto JMP2
Next F
JMP2:
If G>VZ2 Then Goto JMP1
Next G
JMP1:
Clw : Pen 2 : Print "Amending Record-"; : Pen 14 : Print VZ
Print
Pen 2
Get 1,VZ2
For F=1 To FIE
Pen 2 : Locate 0,F*2 : If F<9 Then Print " ";F;":"; Else Print F;":";
Print FS$(F)
SLI[2,(F*2)+1,FS(F),M$(F),14,13,1,0]
Next F
Print
32 Pen 2 : Locate 0,(FIE*2)+3
Print "Enter a field number if you wish to change data"
Print "or press return to continue-"
33 SLI[29,(FIE*2)+4,2,"",14,13,0,0]
If Val(Z$)>FIE Then Locate 33,(FIE*2)+4 : Print "Not Valid" : PAUSE : Locate 33,(FIE*2)+4 : Print " " : Goto 33
If Val(Z$)<1 Then Goto 34
F=Val(Z$)
Pen 2
SLI[2,(F*2)+1,FS(F),M$(F),14,13,0,0]
M$(F)=Z$
Goto 32
34 Put 1,VZ2
Goto 30
End Proc
Rem ***************
Rem * Add Records *
Rem ***************
Procedure AREC
Clw
Pen 2
Window 1
If STATUS=0 Then Print "There is no database file loaded" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to edit records(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
20 Clw
Pen 2
Print "Adding Record-"; : Pen 14 : Print LOT+1-DELETED
Print
Pen 2
For F=1 To FIE : C$(F)="" : Next F
For F=1 To FIE
Pen 2 : Locate 0,F*2 : If F<9 Then Print " ";F;":"; Else Print F;":";
Print FS$(F)
SLI[2,(F*2)+1,FS(F),C$(F),14,13,1,0]
Next F
For F=1 To FIE
SLI[2,(F*2)+1,FS(F),C$(F),14,13,0,1]
If ESC=1 Then Clw : Pen 2 : Pop Proc
C$(F)=Z$
Next F
Print
Pen 2
18 Locate 0,(FIE*2)+3
Pen 2
Print "Enter a field number if you wish to change data"
Print "or press return to continue-"
16 SLI[29,(FIE*2)+4,2,"",14,13,0,0]
If Val(Z$)>FIE Then Locate 33,(FIE*2)+4 : Print "Not Valid" : PAUSE : Locate 33,(FIE*2)+4 : Print " " : Goto 16
If Val(Z$)<1 Then Goto 17
Pen 2
F=Val(Z$)
SLI[2,(F*2)+1,FS(F),C$(F),14,13,0,0]
C$(F)=Z$
Goto 18
17 For F=1 To FIE
M$(F)=C$(F)
Next F
Put 1,LOT+1
LOT=LOT+1
Z2UP
Goto 20
End Proc
Rem ****************************************
Rem * The fantastic multi-line input proc! *
Rem ****************************************
Rem **********
Rem * Delete *
Rem **********
Procedure DELETE
F$=Fsel$("","","Please select a file to","DELETE")
If Mid$(F$,Len(F$),1)=":" Then Print "You can not delete a device!" : PAUSE : Clw : Pop Proc
If F$="" Then Clw : Pop Proc
If Exist(F$) Then Goto 14
Pen 2
Print "That file does not exist" : PAUSE : Clw : Pop Proc
14 Print "Are you sure you wish to delete this file(Y/N)?"
Pen 14 : Print F$
Pen 2
QIN
If Q$="Y" Then Kill F$
Clw
Pop Proc
End Proc
Rem ********
Rem * Quit *
Rem ********
Procedure QUIT
Window 1
Clw
Pen 2
If STATUS=1 Then Print "There is a database file loaded - please UnLoad" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to quit(Y/N)?"
QIN
If Q$="Y" Then Edit
Clw
Pop Proc
End Proc
Rem ************************
Rem * UnLoad database file *
Rem ************************
Procedure UNLOAD
Clw
If STATUS=0 Then Print "There is no database to UnLoad" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to Unload database(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
Close 1
Open Out 1,DBF$+".IDX"
O$=Mid$(Str$(FIE),2,2)
OUT$=FI$+CD$+O$
For F=1 To FIE
O$=Mid$(Str$(FS(F)),2,2)
O$=O$+Space$(3-Len(O$))
OUT$=OUT$+FS$(F)+O$
Next F
Print #1,OUT$
Print #1,Str$(DELETED)
For F=1 To 80
Print #1,Str$(DEL(F))
Next F
Close 1
FI$="" : DBF$="" : LOT=0 : FIE=0 : DEL=0
For F=1 To 80 : DEL(F)=0 : Next F
DELETED=0
For F=1 To 10
FS$(F)="" : FS(F)=1 : M$(F)="" : C$(F)=""
Next F
CD$=""
Clw
CTT[1,"Database Editing Window"]
STATUS=0
CD$=" "
Z2UP
Window 1
End Proc
Rem ***********************
Rem * Creating A NEW File *
Rem ***********************
Procedure NEW
CTT[1,"Create New Database"]
If STATUS>0 Then Clw : Pen 2 : Print "A file is already loaded - please unload" : PAUSE : Clw : Pop Proc
Pen 2
Clw
Print "Are you sure you want to create a database"
Print " file(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
3 Clw
Print "Enter path and name of a new database file."
Print "(.DBF and .IDX will be added to the files)."
Print "Press ESCAPE to exit creation"
Pen 14
Pen 2
SLI[0,4,20,"Temp",14,13,0,1]
If ESC=1 Then Clw : Pop Proc
If Z$=Space$(20) Then Clw : Pop Proc
For F=20 To 1 Step -1
If Mid$(Z$,F,1)<>" " Then Z$=Mid$(Z$,1,F) : Goto 10
Next F
10 Pen 2
If Exist(Z$+".dbf") Then Print : Print "This file already exists. Please re-enter" : PAUSE : Clw : Goto 3
DBF$=Z$
CTT[1,"Creating File- "+DBF$]
Print
4 Pen 2
Locate 0,6
Print "Enter number of fields(max 10)"
SLI[0,7,2,"",14,13,0,0]
If Val(Z$)<1 Then Print : Print "You must have at least 1 field"; : PAUSE : Cline : Goto 4
If Val(Z$)>10 Then Print : Print "You can not have more than 10 fields"; : PAUSE : Cline : Goto 4
FIE=Val(Z$)
Clw
Pen 2
Print "Please enter field names and lengths"
Print
Print " Name Length"
For F=1 To FIE
Pen 2
Print "Field"; : Print Using " ##";F
SLI[9,F+2,15,"",14,13,0,0] : FS$(F)=Z$
5 SLI[29,F+2,2,"",14,13,0,0]
If Val(Z$)>99 or Val(Z$)<1 Then Locate 33,F+2 : Print "Not Valid" : PAUSE : Locate 33,F+2 : Print " " : Goto 5
FS(F)=Val(Z$)
Next F
Print
Pen 2
9 Locate 0,FIE+4
Pen 2
Print "Enter field number if you wish to change data"
Print "or press return to continue-"
6 Pen 2 : SLI[29,FIE+2+3,2,"",14,13,0,0]
If Val(Z$)>10 Then Locate 33,FIE+5 : Print "Not Valid" : PAUSE : Locate 33,FIE+5 : Print " " : Goto 6
If Val(Z$)<1 Then Goto 8
Pen 2
F=Val(Z$)
SLI[9,F+2,15,FS$(F),14,13,0,0]
FS$(F)=Z$
7 Pen 2 : SLI[29,F+2,2,Mid$(Str$(FS(F)),2,Len(Str$(FS(F)))-1),14,13,0,0]
If Val(Z$)>99 or Val(Z$)<1 Then Locate 33,F+2 : Print "Not Valid" : PAUSE : Locate 33,F+2 : Print " " : Goto 7
Goto 9
8 Pen 2
Clw
Print "Please enter filenote(if applicable)- "
SLI[0,1,45,"",14,13,0,0]
FI$=Z$
Print
Pen 2
Print "Please enter creation date-"
SLI[0,4,10,"",14,13,0,0]
CD$=Z$
Print
Pen 2
Print "Currently creating files......"
Open Out 1,DBF$+".IDX"
O$=Mid$(Str$(FIE),2,2)
OUT$=FI$+CD$+O$
For F=1 To FIE
O$=Mid$(Str$(FS(F)),2,2)
O$=O$+Space$(3-Len(O$))
OUT$=OUT$+FS$(F)+O$
Next F
Print #1,OUT$
Print #1,Str$(DELETED)
For F=1 To 80
Print #1,Str$(DEL(F))
Next F
Close 1
Open Random 1,DBF$+".DBF"
F1=FS(1)
F2=FS(2)
F3=FS(3)
F4=FS(4)
F5=FS(5)
F6=FS(6)
F7=FS(7)
F8=FS(8)
F9=FS(9)
F10=FS(10)
Field 1,F1 As M$(1),F2 As M$(2),F3 As M$(3),F4 As M$(4),F5 As M$(5),F6 As M$(6),F7 As M$(7),F8 As M$(8),F9 As M$(9),F10 As M$(10)
D=0
For F=1 To 10
D=D+FS(F)
Next F
LOT=Lof(1)/D
Pen 2
Print "...Creation complete!" : PAUSE : Clw
CTT[1,"Database Editing Window"]
Z2UP
STATUS=1
End Proc
Rem *****************************
Rem * Update Second Window Data *
Rem *****************************
Procedure Z2UP
Window 3
Pen 2
Clw
Locate 0,0
Print "Current Loaded path+file-"
Pen 15 : Print Mid$(DBF$+".DBF",1,25)
Pen 2
Print "Creation Date- "; : Pen 15 : Print CD$ : Pen 2
Print "Number of fields- "; : Pen 15 : Print FIE : Pen 2
Print "Number of records-"; : Pen 15 : Print LOT-DELETED : Pen 2
Window 1
End Proc
Rem ***********************
Rem * Opening An Old File *
Rem ***********************
Procedure OPEN
Pen 2
Clw
If STATUS=1 Then Print "A file is already loaded - please UnLoad" : PAUSE : Clw : Pop Proc
Print "Are you sure you wish to open a database(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Pop Proc
F$=Fsel$(PTH$+"*.DBF","","Load a database file","File must end in .DBF")
If F$="" Then Clw : Pop Proc
If Upper$(Mid$(F$,Len(F$)-3,4))<>".DBF" Then Print : Print "Sorry, this is not a database" : PAUSE : Clw : Pop Proc
If Exist(F$) Then Goto 11 Else Print : Print "This file does not exist" : PAUSE : Clw : Pop Proc
11 Print
Print "Loading database files..."
DBF$=Mid$(F$,1,Len(F$)-4)
Open In 1,DBF$+".IDX"
CTT[1,"Loaded Database: "+DBF$]
X$=Input$(1,56)
FI$=Mid$(X$,1,45)
CD$=Mid$(X$,46,10)
FIE=Val(Mid$(X$,55,2))
X$=Input$(1,18*FIE)
S=1
For F=1 To 18*FIE Step 18
FS$(S)=Mid$(X$,F,15)
FS(S)=Val(Mid$(X$,F+15,2))
S=S+1
Next F
Input #1,DEL$
DELETED=Val(DEL$)
Input #1,DEL$
DELETED=Val(DEL$)
For F=1 To 80
Input #1,DEL$
DEL(F)=Val(DEL$)
Next F
Close 1
Open Random 1,DBF$+".DBF"
F1=FS(1)
F2=FS(2)
F3=FS(3)
F4=FS(4)
F5=FS(5)
F6=FS(6)
F7=FS(7)
F8=FS(8)
F9=FS(9)
F10=FS(10)
Field 1,F1 As M$(1),F2 As M$(2),F3 As M$(3),F4 As M$(4),F5 As M$(5),F6 As M$(6),F7 As M$(7),F8 As M$(8),F9 As M$(9),F10 As M$(10)
D=0
For F=1 To 10
D=D+FS(F)
Next F
LOT=Lof(1)/D
Z2UP
Window 1
Print "...Loading Complete!"
PAUSE
Clw
STATUS=1
End Proc
Rem ***************************
Rem * Opening All The Windows *
Rem ***************************
Procedure WO[A1$,A2$,A3$,A4$]
Curs Off
Colour 15,$222
Colour 14,$222
Colour 1,$222
Colour 2,$222
Wind Open 1,0,5,50,30,1
Curs Off
Border ,0,14
Title Top A1$
Wind Open 3,400,5,28,10,1
Curs Off
Border ,0,14
Title Top A3$
Wind Open 4,400,85,28,20,1
Curs Off
Border ,0,14
Title Top A4$
Get Disc Fonts
Set Font 1
Colour 15,$F0
Colour 14,$0
Colour 2,$555
End Proc
Rem ************************
Rem * Setting Up The Menus *
Rem ************************
Procedure MENUS
X=7
A$="(ss 2)" : B$="(ss 0)"
Menu$(1)=A$+"Project "
Menu$(1,1)=B$+" New "
Menu$(1,2)=" Open "
Menu$(1,3)=" Delete "
Menu$(1,4)=" UnLoad "
Menu$(1,5)=" ------- " : Menu Inactive(1,5)
Menu$(1,7)=" About "
Menu$(1,6)=" Quit "
Menu$(1,X,1)="(ss 1) BOMBASE version 1.0 " : Menu Inactive(1,X,1)
Menu$(1,X,2)="(ss 0) " : Menu Inactive(1,X,2)
Menu$(1,X,3)="(ss 2) by Gareth Lancaster(ss 0) " : Menu Inactive(1,X,3)
Menu$(1,X,4)=" Contact me at; " : Menu Inactive(1,X,4)
Menu$(1,X,5)=" 40, Appleby Gardens," : Menu Inactive(1,X,5)
Menu$(1,X,6)=" Dunstable, Beds," : Menu Inactive(1,X,6)
Menu$(1,X,7)=" LU6 3DB." : Menu Inactive(1,X,7)
Menu$(1,X,8)=" TEL:0582 666680" : Menu Inactive(1,X,8)
Menu$(1,X,9)=" -------------------" : Menu Inactive(1,X,9)
Menu$(1,X,10)=" Made with: AMOS1.21 " : Menu Inactive(1,X,10)
Menu$(2)=A$+"Edit "
Menu$(2,1)=B$+" Add Records "
Menu$(2,2)=" Amend Records "
Menu$(2,3)=" Delete Records "
Menu$(2,4)=" Edit File Data "
Menu$(3)=A$+"Output "
Menu$(3,1)=B$+" Print all records "
Menu$(3,2)=" View Records "
Menu$(4)=A$+"Manipulate "
Menu$(4,1)=B$+" Sort records "
Menu$(4,2)=" Search database "
Menu$(4,3)=" List on field "
Menu$(5)=A$+"Utilities "+B$
Menu$(5,1)=" Validate "
Rem Menu$(5,2)=" Write data "
Rem Menu$(5,2,1)=" Ascii Format "
Rem Menu$(5,2,2)=" Fixed Length "
Menu On
End Proc
Rem ********************************************
Rem * The all important single line input proc *
Rem ********************************************
Procedure SLI[XPOS,YPOS,LG,X$,BIRO,CARD,DUMMY,ESCEN]
If Len(X$)<LG Then X$=X$+Space$(LG-Len(X$))
If Len(X$)>LG Then X$=Mid$(X$,1,LG)
Z$=X$
X=XPOS : Y=YPOS : XX=0 : ESC=0 : Pen BIRO : Paper CARD
Locate X,Y : Print Z$; : Locate X+XX,Y
If DUMMY=1 Then Paper 0 : Pen 1 : Print : Pop Proc
Curs On
LOPK:
Q$=Inkey$ : If Q$="" Then Goto LOPK
If Q$=Chr$(27) and ESCEN=1 Then ESC=1 : Paper 0 : Ink 1 : Print : Curs Off : Pop Proc
If Q$=Chr$(27) Then Goto LOPK
If Q$=Chr$(13) Then Paper 0 : Ink 1 : Print : Curs Off : Pop Proc
If Q$=Chr$(8) and XX>0 Then XX=XX-1 : Locate X+XX,Y : Print " "; : Locate X+XX,Y : Mid$(Z$,XX+1,1)=" " : Goto LOPK
If Q$=Chr$(8) Then Goto LOPK
If Q$=Chr$(29) and XX>0 Then XX=XX-1 : Locate X+XX,Y : Goto LOPK
If Q$=Chr$(29) Then Goto LOPK
If Q$=Chr$(28) and XX<LG Then XX=XX+1 : Locate X+XX,Y : If XX=LG Then Locate X+XX-1,Y : Goto LOPK
If Q$=Chr$(28) Then Goto LOPK
If XX<LG Then Locate X+XX,Y : Print Q$; : Mid$(Z$,XX+1,1)=Q$ : XX=XX+1 : Locate X+XX,Y : If XX=LG Then Locate X+XX-1,Y : Goto LOPK
Goto LOPK
End Proc
Rem ************************
Rem * Inactivate the menus *
Rem ************************
Procedure INAC
Menu Inactive(1)
End Proc
Rem *********************************
Rem * Changing a window's top title *
Rem *********************************
Procedure CTT[P,S$]
Curs Off
Window P
Title Top S$
End Proc
Rem ***************************
Rem * Testing Q$ for an input *
Rem ***************************
Procedure QIN
1 Q$=Inkey$
If Q$="" Then Goto 1
Q$=Upper$(Q$)
End Proc
Rem *****************************
Rem * Activate The Menu's again *
Rem *****************************
Procedure AC
Menu Active(1)
End Proc
Rem ******************************
Rem * Setting up all the colours *
Rem ******************************
Procedure CS
Colour 0,$222
Colour 2,$555
Colour 15,$F0
Colour 14,$0
Colour 13,$730
End Proc
Rem *********************************
Rem * Stall the show for a while... *
Rem *********************************
Procedure PAUSE
Wait 50
End Proc
Rem **********************
Rem * The insertion sort *
Rem **********************
5000 Window 1 : Clw : Pen 2
If STATUS=0 Then Print "There is no database file to sort" : PAUSE : Clw : Return
Print "Are you sure you wish to sort database(Y/N)?"
QIN
If Q$<>"Y" Then Clw : Return
Print : Print "Sort on which field-"
5010 SLI[21,2,2,"",14,13,0,0]
If Val(Z$)>FIE Then Locate 24,2 : Print " Not Valid " : PAUSE : Locate 24,2 : Print " " : Goto 5010
If Val(Z$)<1 Then Clw : Pen 2 : Return
JJJ=Val(Z$)
Pen 2
Clw : Print "Sorting Database!"
6000 For I=1 To LOT-1
6010 Gosub 7000
6020 For J=I To 1 Step -1
6030 Get 1,J : Gosub 9000 : If K$(JJJ)>=N$(JJJ) Then 6070
6040 Gosub 8000
6050 Next J
6060 J=0
6070 Gosub 9050
6080 Next I : Print : Print "Database is now sorted" : PAUSE : Clw : Goto 10000
7000 Get 1,I+1
7010 For F=1 To 10 : K$(F)=M$(F)
7020 Next F
7030 Return
8000 For F=1 To 10 : M$(F)=N$(F) : Next F
8010 Put 1,J+1
8020 Return
9000 For F=1 To 10 : N$(F)=M$(F)
9010 Next F
9020 Return
9050 For F=1 To 10 : M$(F)=K$(F)
9060 Next F : Put 1,J+1
9070 Return
10000 If DELETED<1 Then Return
10010 For F=1 To DELETED
10020 DEL(F)=F
10030 Next F
10040 Return