home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
d
/
dtu11b.zip
/
QSQLDEMO.EXE
/
QSQL.CLA
< prev
next >
Wrap
Text File
|
1992-09-22
|
27KB
|
593 lines
QSQL PROGRAM
! Copyright (c) 1991 Cook Database Design, Inc.
!
! This source file is provided to give you a first hand view of how to
! incorporate SQL.EXE into your Clarion applications. Feel free to
! modify this to suit your own needs. Please note that in order to
! compile this, you need a copy of our QPREVIEW product.
!
!
INCLUDE('STD_KEYS.CLA')
INCLUDE('CTL_KEYS.CLA')
INCLUDE('ALT_KEYS.CLA')
INCLUDE('SHF_KEYS.CLA')
MAP
PROC(TABLE)
MODULE('XPREQSQL')
PROC(PREVIEW)
.
MODULE('QPREVIEW'),BINARY ! REQUIRES QPREVIEW PRODUCT
PROC(QPREVIEW)
.
.
QSQLFILE FILE,PRE(QSQ),CREATE,RECLAIM
QSQLKEY KEY(QSQ:DESCRIPTION),DUP,NOCASE,OPT
RECORD RECORD
DESCRIPTION STRING(60) !Description Of File
L1 STRING(78)
L2 STRING(78)
L3 STRING(78)
L4 STRING(78)
L5 STRING(78)
L6 STRING(78)
L7 STRING(78)
L8 STRING(78)
L9 STRING(78)
L10 STRING(78)
L11 STRING(78)
L12 STRING(78)
. .
SQLIN DOS,ASCII,NAME('QSQL.IN')
RECORD
RECORD STRING(80)
..
ACTION SHORT !0 = NO ACTION
!1 = ADD RECORD
!2 = CHANGE RECORD
!3 = DELETE RECORD
!4 = LOOKUP FIELD
TRUE EQUATE(1)
FALSE EQUATE(0)
ASKDESC SCREEN WINDOW(4,62),HUE(15,2,0)
ROW(1,1) STRING('╔═{60}╗')
ROW(2,1) REPEAT(2);STRING('║<0{60}>║') .
ROW(4,1) STRING('╚═{60}╝')
ROW(2,2) STRING('ENTER A DESCRIPTION TO SAVE THE FILE UNDER:')
ROW(3,2) ENTRY(@S60),USE(QSQ:DESCRIPTION),HUE(14,0),SEL(0,7)
.
QUERYIN SCREEN WINDOW(25,80),HUE(15,1,0)
ROW(20,3) PAINT(2,10),HUE(14,1)
ROW(18,3) PAINT(1,13),HUE(14,1)
ROW(22,3) PAINT(2,7),HUE(14,1)
ROW(20,43) PAINT(3,7),HUE(14,1)
ROW(24,19) PAINT(1,45),HUE(11,1)
ROW(2,28) PAINT(2,26),HUE(12,1)
ROW(23,43) PAINT(1,8),HUE(14,1)
ROW(1,1) STRING('<201,205{78},187>')
ROW(2,1) REPEAT(2);STRING('<186,0{78},186>') .
ROW(4,1) REPEAT(2),EVERY(13);STRING('<204,205{78},185>') .
ROW(5,1) REPEAT(12);STRING('<186,0{78},186>') .
ROW(18,1) REPEAT(7);STRING('<186,0{78},186>') .
ROW(25,1) STRING('<200,205{78},188>')
ROW(2,3) STRING('Version 2.5 ')
COL(39) STRING('QSQL')
ROW(3,3) STRING('09/22/92')
COL(28) STRING('INTERACTIVE USER INTERFACE')
ROW(18,3) STRING('QUERY SYNTAX:')
COL(17) STRING('SELECT fieldnames FROM files WHERE conditions')
ROW(20,3) STRING('CTRL-ENTER')
COL(14) STRING('TO EXECUTE YOUR QUERY')
COL(43) STRING('CTRL-L')
COL(51) STRING('LOAD A PREVIOUSLY SAVED QUERY')
ROW(21,3) STRING('CTRL-ESC')
COL(14) STRING('TO EXIT FROM THIS PACKAGE')
COL(43) STRING('CTRL-S')
COL(51) STRING('SAVE THIS QUERY')
ROW(22,3) STRING('CTRL-V')
COL(14) STRING('VIEW OUTPUT FROM LAST QUERY')
COL(43) STRING('CTRL-F')
COL(51) STRING('LIST OF ALL .DAT FILES')
ROW(23,3) STRING('CTRL-E')
COL(14) STRING('ERASE CURRENT QUERY')
COL(43) STRING('CTRL-D')
COL(51) STRING('TOGGLE DEBUG')
ROW(24,19) STRING('COPYRIGHT (C) 1991 COOK DATABASE DESIGN, INC.')
ROW(5,2) TEXT(12,78),USE(QUERY),HUE(14,0),SEL(14,0)
DBUGOUT ROW(23,64) STRING(3),HUE(15,1)
.
PSCREEN SCREEN WINDOW(5,45),HUE(15,2)
ROW(1,1) STRING('╔═{43}╗')
ROW(2,1) REPEAT(3);STRING('║<0{43}>║') .
ROW(5,1) STRING('╚═{43}╝')
ROW(2,13) STRING('PROCESSING YOUR QUERY')
ROW(4,3) STRING('PRESS CTRL-BREAK TO TERMINATE PROCESSING')
.
QUERY GROUP !RP COMMENT MEMO
L1S STRING(78)
L2S STRING(78)
L3S STRING(78)
L4S STRING(78)
L5S STRING(78)
L6S STRING(78)
L7S STRING(78)
L8S STRING(78)
L9S STRING(78)
L10S STRING(78)
L11S STRING(78)
L12S STRING(78)
.
GROUP,OVER(QUERY)
QUERY_ROW STRING(78),DIM(12)
.
T1 LONG
T2 LONG
I LONG
L LONG
DEBUG LONG
OPENFLAG BYTE
CODE
DEBUG=0
OPEN(QUERYIN)
OPENFLAG=0
LOOP
ALERT(CTRL_ESC)
ALERT(ESC_KEY)
ALERT(CTRL_ENTER)
ALERT(CTRL_E)
ALERT(CTRL_D)
ALERT(CTRL_L)
ALERT(CTRL_S)
ALERT(CTRL_F)
ALERT(CTRL_V)
IF DEBUG = 0 THEN DBUGOUT='ON'.
IF DEBUG = 1 THEN DBUGOUT='OFF'.
DISPLAY
ACCEPT
UPDATE
IF KEYCODE() = CTRL_E THEN
QUERY=' '
CYCLE
.
IF KEYCODE() = CTRL_D THEN
DEBUG=1-DEBUG
CYCLE
.
IF KEYCODE() = CTRL_L THEN
DO LOAD_QUERY
CYCLE
.
IF KEYCODE() = CTRL_S THEN
DO SAVE_QUERY
CYCLE
.
IF KEYCODE() = CTRL_F THEN
RUNSMALL('DIR *.DAT > $DIR.OUT')
PREVIEW('$DIR.OUT')
CYCLE
.
IF KEYCODE() = CTRL_V THEN
PREVIEW('$QSQL.OUT')
CYCLE
.
IF KEYCODE() = ESC_KEY THEN BREAK.
IF KEYCODE() = CTRL_ESC THEN BREAK.
IF KEYCODE() <> CTRL_ENTER THEN CYCLE.
CREATE(SQLIN)
I=0
LOOP
I=I+1
IF I > 12 THEN BREAK.
IF QUERY_ROW[I] = ' ' THEN CYCLE.
RECORD=QUERY_ROW[I]
ADD(SQLIN)
.
CLOSE(SQLIN)
OPEN(PSCREEN)
IF DEBUG = 1 THEN
RUNSMALL('SQL -ds << QSQL.IN > $QSQL.OUT')
ELSE
RUNSMALL('SQL -s << QSQL.IN > $QSQL.OUT')
.
IF ERRORCODE() THEN
SHOW(1,1,ERROR())
SHOW(2,1,ERRORCODE())
BEEP
ASK
.
CLOSE(PSCREEN)
PREVIEW('$QSQL.OUT')
.
RUNSMALL('ERASE $QSQL.OUT')
RUNSMALL('ERASE $DIR.OUT')
CLOSE(QSQLFILE)
CLOSE(QUERYIN)
RETURN !EXIT TO DOS
LOAD_QUERY ROUTINE
IF OPENFLAG = 0 THEN DO OPENFILE.
ACTION=4
TABLE
IF ACTION THEN EXIT.
L1S=QSQ:L1
L2S=QSQ:L2
L3S=QSQ:L3
L4S=QSQ:L4
L5S=QSQ:L5
L6S=QSQ:L6
L7S=QSQ:L7
L8S=QSQ:L8
L9S=QSQ:L9
L10S=QSQ:L10
L11S=QSQ:L11
L12S=QSQ:L12
EXIT
SAVE_QUERY ROUTINE
IF OPENFLAG = 0 THEN DO OPENFILE.
OPEN(ASKDESC)
ALERT(CTRL_ESC)
ACCEPT
UPDATE
CLOSE(ASKDESC)
IF KEYCODE() = ESC_KEY THEN EXIT.
IF KEYCODE() = CTRL_ESC THEN EXIT.
GET(QSQLFILE,QSQ:QSQLKEY) ! ok
IF ERROR() THEN
DO SCR2FILE
ADD(QSQLFILE)
EXIT
.
DO SCR2FILE
PUT(QSQLFILE)
EXIT
OPENFILE ROUTINE
OPEN(QSQLFILE)
IF ERRORCODE() THEN CREATE(QSQLFILE).
OPENFLAG=1
EXIT
SCR2FILE ROUTINE
QSQ:L1=L1S
QSQ:L2=L2S
QSQ:L3=L3S
QSQ:L4=L4S
QSQ:L5=L5S
QSQ:L6=L6S
QSQ:L7=L7S
QSQ:L8=L8S
QSQ:L9=L9S
QSQ:L10=L10S
QSQ:L11=L11S
QSQ:L12=L12S
EXIT
TABLE PROCEDURE
DELSCR SCREEN WINDOW(9,69),HUE(15,4,0)
ROW(1,1) STRING('<201,205{67},187>')
ROW(2,1) REPEAT(7);STRING('<186,0{67},186>') .
ROW(9,1) STRING('<200,205{67},188>')
ROW(2,27) STRING('Delete Screen')
ROW(6,4) STRING('Press ENTER to DELETE the query')
ROW(7,4) STRING('Press ESC to escape back to the table without ' |
& 'deleting the query.')
DESCOUT ROW(4,4) STRING(60),HUE(7,0)
.
SCREEN SCREEN PRE(SCR),WINDOW(21,62),HUE(15,1)
ROW(20,2) PAINT(1,60),HUE(15,4)
ROW(2,2) PAINT(1,60),HUE(15,3)
ROW(1,1) STRING('╔═{60}╗')
ROW(2,1) REPEAT(17);STRING('║<0{60}>║') .
ROW(19,1) STRING('╠═{60}╣')
ROW(20,1) STRING('║<0{60}>║')
ROW(21,1) STRING('╚═{60}╝')
ROW(2,18) STRING('Description of Stored Queries')
ROW(20,6) STRING('To Select Query, move cursor to entry and ' |
& 'press enter')
ENTRY,USE(?FIRST_FIELD)
ENTRY,USE(?PRE_POINT)
REPEAT(16),EVERY(1),INDEX(NDX)
ROW(3,2) POINT(1,60),USE(?POINT),ESC(?-1)
DESCRIPTION COL(2) STRING(60)
. .
NDX BYTE !REPEAT INDEX FOR POINT AREA
ROW BYTE !ACTUAL ROW OF SCROLL AREA
COL BYTE !ACTUAL COLUMN OF SCROLL AREA
COUNT BYTE(16) !NUMBER OF ITEMS TO SCROLL
ROWS BYTE(16) !NUMBER OF ROWS TO SCROLL
COLS BYTE(60) !NUMBER OF COLUMNS TO SCROLL
FOUND BYTE !RECORD FOUND FLAG
NEWPTR LONG !POINTER TO NEW RECORD
TABLE TABLE,PRE(TBL) !TABLE OF RECORD DATA
PTR LONG ! POINTER TO FILE RECORD
DESCRIPTION STRING(60) !Description Of File
.
EJECT
CODE
ACTION# = ACTION !SAVE ACTION
OPEN(SCREEN) !OPEN THE SCREEN
SETCURSOR !TURN OFF ANY CURSOR
TBL:PTR = 1 !START AT TABLE ENTRY
NDX = 1 !PUT SELECTOR BAR ON TOP ITEM
ROW = ROW(?POINT) !REMEMBER TOP ROW AND
COL = COL(?POINT) !LEFT COLUMN OF SCROLL AREA
RECORDS# = TRUE !INITIALIZE RECORDS FLAG
CACHE(QSQ:QSQLKEY,.25) !CACHE KEY FILE
IF ACTION = 4 ! TABLE LOOKUP REQUEST
NEWPTR = POINTER(QSQLFILE) ! SET POINTER TO RECORD
IF NOT NEWPTR ! RECORD NOT PASSED TO TABLE
SET(QSQLFILE,QSQ:QSQLKEY) !ok ! POSITION TO CLOSEST RECORD
NEXT(QSQLFILE) ! READ RECORD
NEWPTR = POINTER(QSQLFILE) ! SET POINTER
.
DO FIND_RECORD ! POSITION FILE
ELSE
NDX = 1 ! PUT SELECTOR BAR ON TOP ITEM
DO FIRST_PAGE ! BUILD MEMORY TABLE OF KEYS
.
RECORDS# = TRUE ! ASSUME THERE ARE RECORDS
LOOP !LOOP UNTIL USER EXITS
ACTION = ACTION# !RESTORE ACTION
ALERT !RESET ALERTED KEYS
ALERT(CTRL_ESC) !ALERT SCREEN REJECT KEY
ALERT(CTRL_ENTER) !ALERT SCREEN ACCEPT KEY
ACCEPT !READ A FIELD
IF KEYCODE() = CTRL_ESC THEN BREAK. !RETURN ON SCREEN REJECT KEY
IF KEYCODE() = CTRL_ENTER | !ON SCREEN ACCEPT KEY
AND FIELD() <> ?POINT !BUT NOT ON THE POINT FIELD
UPDATE ! MOVE ALL FIELDS FROM SCREEN
SELECT(?) ! START WITH CURRENT FIELD
SELECT ! EDIT ALL FIELDS
CYCLE ! GO TO TOP OF LOOP
.
CASE FIELD() !JUMP TO FIELD EDIT ROUTINE
OF ?FIRST_FIELD !FROM THE FIRST FIELD
IF KEYCODE() = ESC_KEY | ! RETURN ON ESC KEY
OR RECORDS# = FALSE ! OR NO RECORDS
BREAK ! EXIT PROCEDURE
.
OF ?PRE_POINT !PRE POINT FIELD CONDITION
IF KEYCODE() = ESC_KEY ! BACKING UP?
SELECT(?-1) ! SELECT PREVIOUS FIELD
ELSE ! GOING FORWARD
SELECT(?POINT) ! SELECT MENU FIELD
.
OF ?POINT !PROCESS THE POINT FIELD
IF RECORDS(TABLE) = 0 !IF THERE ARE NO RECORDS
CLEAR(QSQ:RECORD) ! CLEAR RECORD AREA
ACTION = 1 ! SET ACTION TO ADD
GET(QSQLFILE,0) ! CLEAR PENDING RECORD
NEWPTR = POINTER(QSQLFILE) ! SET POINTER TO NEW RECORD
DO FIRST_PAGE ! DISPLAY THE FIRST PAGE
IF RECORDS(TABLE) = 0 ! IF THERE AREN'T ANY RECORDS
RECORDS# = FALSE ! INDICATE NO RECORDS
SELECT(?PRE_POINT-1) ! SELECT THE PRIOR FIELD
.
CYCLE ! AND LOOP AGAIN
.
CASE KEYCODE() !PROCESS THE KEYSTROKE
OF INS_KEY !INS KEY
CLEAR(QSQ:RECORD) ! CLEAR RECORD AREA
ACTION = 1 ! SET ACTION TO ADD
GET(QSQLFILE,0) ! CLEAR PENDING RECORD
IF ~ACTION ! IF RECORD WAS ADDED
NEWPTR = POINTER(QSQLFILE) ! SET POINTER TO NEW RECORD
DO FIND_RECORD ! POSITION IN FILE
.
OF ENTER_KEY !ENTER KEY
OROF CTRL_ENTER !CTRL-ENTER KEY
DO GET_RECORD ! GET THE SELECTED RECORD
IF ACTION = 4 AND KEYCODE() = ENTER_KEY! IF THIS IS A LOOKUP REQUEST
ACTION = 0 ! SET ACTION TO COMPLETE
BREAK ! AND RETURN TO CALLER
.
IF ~ERROR() ! IF RECORD IS STILL THERE
ACTION = 2 ! SET ACTION TO CHANGE
IF ACTION THEN CYCLE. ! IF SUCCESSFUL RE-DISPLAY
.
NEWPTR = POINTER(QSQLFILE) ! SET POINTER TO NEW RECORD
DO FIND_RECORD ! POSITION IN FILE
OF DEL_KEY !DEL KEY
DO GET_RECORD ! READ THE SELECTED RECORD
IF ~ERROR() ! IF RECORD IS STILL THERE
ACTION = 3 ! SET ACTION TO DELETE
DO DELETEIT
IF ~ACTION ! IF SUCCESSFUL
N# = NDX ! SAVE POINT INDEX
DO SAME_PAGE ! RE-DISPLAY
NDX = N# ! RESTORE POINT INDEX
. .
OF DOWN_KEY !DOWN ARROW KEY
DO SET_NEXT ! POINT TO NEXT RECORD
DO FILL_NEXT ! FILL A TABLE ENTRY
IF FOUND ! FOUND A NEW RECORD
SCROLL(ROW,COL,ROWS,COLS,ROWS(?POINT)) ! SCROLL THE SCREEN UP
GET(TABLE,RECORDS(TABLE)) ! GET RECORD FROM TABLE
DO FILL_SCREEN ! DISPLAY ON SCREEN
.
OF PGDN_KEY !PAGE DOWN KEY
DO SET_NEXT ! POINT TO NEXT RECORD
DO NEXT_PAGE ! DISPLAY THE NEXT PAGE
OF CTRL_PGDN !CTRL-PAGE DOWN KEY
DO LAST_PAGE ! DISPLAY THE LAST PAGE
NDX = RECORDS(TABLE) ! POSITION POINT BAR
OF UP_KEY !UP ARROW KEY
DO SET_PREV ! POINT TO PREVIOUS RECORD
DO FILL_PREV ! FILL A TABLE ENTRY
IF FOUND ! FOUND A NEW RECORD
SCROLL(ROW,COL,ROWS,COLS,-(ROWS(?POINT)))! SCROLL THE SCREEN DOWN
GET(TABLE,1) ! GET RECORD FROM TABLE
DO FILL_SCREEN ! DISPLAY ON SCREEN
.
OF PGUP_KEY !PAGE UP KEY
DO SET_PREV ! POINT TO PREVIOUS RECORD
DO PREV_PAGE ! DISPLAY THE PREVIOUS PAGE
OF CTRL_PGUP !CTRL-PAGE UP
DO FIRST_PAGE ! DISPLAY THE FIRST PAGE
NDX = 1 ! POSITION POINT BAR
. . .
FREE(TABLE) !FREE MEMORY TABLE
FREE(QSQ:QSQLKEY) !FREE CACHE
RETURN !AND RETURN TO CALLER
SAME_PAGE ROUTINE !DISPLAY THE SAME PAGE
GET(TABLE,1) ! GET THE FIRST TABLE ENTRY
DO FILL_RECORD ! FILL IN THE RECORD
SET(QSQ:QSQLKEY,QSQ:QSQLKEY,TBL:PTR) ! POSITION FILE
FREE(TABLE) ! EMPTY THE TABLE
DO NEXT_PAGE ! DISPLAY A FULL PAGE
FIRST_PAGE ROUTINE !DISPLAY FIRST PAGE
FREE(TABLE) ! EMPTY THE TABLE
CLEAR(QSQ:RECORD,-1) ! CLEAR RECORD TO LOW VALUES
CLEAR(TBL:PTR) ! ZERO RECORD POINTER
SET(QSQ:QSQLKEY) ! POINT TO FIRST RECORD
LOOP NDX = 1 TO COUNT ! FILL UP THE TABLE
DO FILL_NEXT ! FILL A TABLE ENTRY
IF NOT FOUND THEN BREAK. ! GET OUT IF NO RECORD
.
NDX = 1 ! SET TO TOP OF TABLE
DO SHOW_PAGE ! DISPLAY THE PAGE
LAST_PAGE ROUTINE !DISPLAY LAST PAGE
NDX# = NDX ! SAVE SELECTOR POSITION
FREE(TABLE) ! EMPTY THE TABLE
CLEAR(QSQ:RECORD,1) ! CLEAR RECORD TO HIGH VALUES
CLEAR(TBL:PTR,1) ! CLEAR PTR TO HIGH VALUE
SET(QSQ:QSQLKEY) ! POINT TO FIRST RECORD
LOOP NDX = COUNT TO 1 BY -1 ! FILL UP THE TABLE
DO FILL_PREV ! FILL A TABLE ENTRY
IF NOT FOUND THEN BREAK. ! GET OUT IF NO RECORD
. ! END OF LOOP
NDX = NDX# ! RESTORE SELECTOR POSITION
DO SHOW_PAGE ! DISPLAY THE PAGE
FIND_RECORD ROUTINE !POSITION TO SPECIFIC RECORD
SET(QSQ:QSQLKEY,QSQ:QSQLKEY,NEWPTR) !POSITION FILE
IF NEWPTR = 0 !NEWPTR NOT SET
NEXT(QSQLFILE) ! READ NEXT RECORD
NEWPTR = POINTER(QSQLFILE) ! SET NEWPTR
SKIP(QSQLFILE,-1) ! BACK UP TO DISPLAY RECORD
.
FREE(TABLE) ! CLEAR THE RECORD
DO NEXT_PAGE ! DISPLAY A PAGE
NEXT_PAGE ROUTINE !DISPLAY NEXT PAGE
SAVECNT# = RECORDS(TABLE) ! SAVE RECORD COUNT
LOOP COUNT TIMES ! FILL UP THE TABLE
DO FILL_NEXT ! FILL A TABLE ENTRY
IF NOT FOUND ! IF NONE ARE LEFT
IF NOT SAVECNT# ! IF REBUILDING TABLE
DO LAST_PAGE ! FILL IN RECORDS
EXIT ! EXIT OUT OF ROUTINE
.
BREAK ! EXIT LOOP
. .
DO SHOW_PAGE ! DISPLAY THE PAGE
SET_NEXT ROUTINE !POINT TO THE NEXT PAGE
GET(TABLE,RECORDS(TABLE)) ! GET THE LAST TABLE ENTRY
DO FILL_RECORD ! FILL IN THE RECORD
SET(QSQ:QSQLKEY,QSQ:QSQLKEY,TBL:PTR) ! POSITION FILE
NEXT(QSQLFILE) ! READ THE CURRENT RECORD
FILL_NEXT ROUTINE !FILL NEXT TABLE ENTRY
FOUND = FALSE ! ASSUME RECORD NOT FOUND
LOOP UNTIL EOF(QSQLFILE) ! LOOP UNTIL END OF FILE
NEXT(QSQLFILE) ! READ THE NEXT RECORD
FOUND = TRUE ! SET RECORD FOUND
DO FILL_TABLE ! FILL IN THE TABLE ENTRY
ADD(TABLE) ! ADD LAST TABLE ENTRY
GET(TABLE,RECORDS(TABLE)-COUNT) ! GET ANY OVERFLOW RECORD
DELETE(TABLE) ! AND DELETE IT
EXIT ! RETURN TO CALLER
.
PREV_PAGE ROUTINE !DISPLAY PREVIOUS PAGE
LOOP COUNT TIMES ! FILL UP THE TABLE
DO FILL_PREV ! FILL A TABLE ENTRY
IF NOT FOUND THEN BREAK. ! GET OUT IF NO RECORD
.
DO SHOW_PAGE ! DISPLAY THE PAGE
SET_PREV ROUTINE !POINT TO PREVIOUS PAGE
GET(TABLE,1) ! GET THE FIRST TABLE ENTRY
DO FILL_RECORD ! FILL IN THE RECORD
SET(QSQ:QSQLKEY,QSQ:QSQLKEY,TBL:PTR) ! POSITION FILE
PREVIOUS(QSQLFILE) ! READ THE CURRENT RECORD
FILL_PREV ROUTINE !FILL PREVIOUS TABLE ENTRY
FOUND = FALSE ! ASSUME RECORD NOT FOUND
LOOP UNTIL BOF(QSQLFILE) ! LOOP UNTIL BEGINNING OF FILE
PREVIOUS(QSQLFILE) ! READ THE PREVIOUS RECORD
FOUND = TRUE ! SET RECORD FOUND
DO FILL_TABLE ! FILL IN THE TABLE ENTRY
ADD(TABLE,1) ! ADD FIRST TABLE ENTRY
GET(TABLE,COUNT+1) ! GET ANY OVERFLOW RECORD
DELETE(TABLE) ! AND DELETE IT
EXIT ! RETURN TO CALLER
.
SHOW_PAGE ROUTINE !DISPLAY THE PAGE
NDX# = NDX ! SAVE SCREEN INDEX
LOOP NDX = 1 TO RECORDS(TABLE) ! LOOP THRU THE TABLE
GET(TABLE,NDX) ! GET A TABLE ENTRY
DO FILL_SCREEN ! AND DISPLAY IT
IF TBL:PTR = NEWPTR ! SET INDEX FOR NEW RECORD
NDX# = NDX ! POINT TO CORRECT RECORD
. .
LOOP WHILE NDX <= COUNT ! FINISH BLANKING THE SCREEN
BLANK(ROW(?POINT),COL(?POINT),ROWS(?POINT),COLS(?POINT))!BLANK A LINE
NDX += 1 ! INCREMENT NDX
.
NDX = NDX# ! RESTORE SCREEN INDEX
NEWPTR = 0 ! CLEAR NEW RECORD POINTER
CLEAR(QSQ:RECORD) ! CLEAR RECORD AREA
FILL_TABLE ROUTINE !MOVE FILE TO TABLE
TBL:DESCRIPTION = QSQ:DESCRIPTION
TBL:PTR = POINTER(QSQLFILE) ! SAVE RECORD POINTER
FILL_RECORD ROUTINE !MOVE TABLE TO FILE
QSQ:DESCRIPTION = TBL:DESCRIPTION
FILL_SCREEN ROUTINE !MOVE TABLE TO SCREEN
SCR:DESCRIPTION = TBL:DESCRIPTION
GET_RECORD ROUTINE !GET SELECTED RECORD
GET(TABLE,NDX) ! GET TABLE ENTRY
GET(QSQLFILE,TBL:PTR) ! GET THE RECORD
DELETEIT ROUTINE
OPEN(DELSCR)
DESCOUT=QSQ:DESCRIPTION
DISPLAY
LOOP
ASK
IF KEYCODE() = ENTER_KEY THEN
DELETE(QSQLFILE)
ACTION=0
BREAK
.
IF KEYCODE() = ESC_KEY THEN BREAK.
IF KEYCODE() = CTRL_ESC THEN BREAK.
BEEP
.
CLOSE(DELSCR)
EXIT