home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
OPNOS2.ZIP
/
KLTLSE.ARS
< prev
next >
Wrap
Text File
|
1993-02-23
|
60KB
|
401 lines
1Data Entry Main regular read/write
31ISQH read/writeyes
32SQH read/writeyes
4QBEtitleSelect query
4Commit Commit
4DelMsg Delete the record
4Exist Record exist
4Exit Quit
4OrdTitleOrder by
4Cursor Cursor
4QrErr SQL Communication problem
4First First record
4Last Last record
4NoRec No records
4NoCur No current record to delete/update
4WriteErrFile Access Error
5Order Order by Char Lf-T-Rgh 26 1 ;
5RecCunt RecCunt Long Positive 6 10;
5Date0 Date 0 Date American 10 101/01/0001;
5Zero zero Long Positive1 1 0;
5One One Long Positive1 1 1;
5Two two Long Positive 1 1 2;
5Title title Char Lf-T-Rgh20 1 SQL data entry;
5BLANK blank Char Lf-T-Rgh1 1 ; .
5Dummy dummy Char Lf-T-Rgh10 1 1; .
5Max Long Positive 10 132767;
5Record Long Positive 10 10;
5LastRec Long Positive 10 10;
5ConList ConList Char Lf-T-Rgh2 6 >=;<=;=;<>;>;<; .
5OpList OpList Char Lf-T-Rgh3 2AND;OR; .
5OK IntegerPositive 1 10;
5OKtitle Char Lf-T-Rgh 4 1O.K.;
5CANCEL IntegerPositive 1 10;
5CAtitle Char Lf-T-Rgh 8 1Esc=Quit;
5Long22 Long Positive 21 22;
5SqErr Long Positive 6 10;
5TempFileTempFile Char Lf-T-Rgh 8 1Dummy;
5Next Char Lf-T-Rgh 4 1Next;
5First Char Lf-T-Rgh 4 1Top;
5Last Char Lf-T-Rgh 4 1Last;
5Prev Char Lf-T-Rgh 4 1Prev;
5Add Char Lf-T-Rgh 4 1Add;
5Upd Char Lf-T-Rgh 4 1Upd;
5Del Char Lf-T-Rgh 4 1Del;
5Query Char Lf-T-Rgh 4 1Qbe;
5Quit Char Lf-T-Rgh 4 1Quit;
5Action Action Char Lf-T-Rgh 4 1Qbe;
5ActLst ActLst Char Lf-T-Rgh 4 9Add;Upd;Del;Next;Prev;Top;Last;Qbe;Quit;
5Menu Menu Char Lf-T-Rgh 20 1Menu;
5SysDate SysDate Date American 10 100/00/0000;
5SysTime SysTime Time Time 8 100:00:00;
5Cursor Cursor Char Lf-T-Rgh 10 1;
5RepeatB Long Positive 1 10;
5RepeatT Char Lf-T-Rgh 7 1Repeat;
6Menu 0.667 3.316 18.667 13.895L_FRAME PINK 0Menu DEFAULT_WINDOW Nobmp 1 1 12 6
6MAIN 19.333 6.737 76.167 10.474L_FRAME DARKGRAY 0Title Data 0.5 0.5 6 8
6QBE 11.333 -0.053 85.000 17.368L_FRAME DARKGREEN !QBEtitle Query 2 0.5 6 8
7MAIN 1Key1 0Dummy 62.167 6.211 7.500 1.000S_ARISTO CYAN BLUE KEY NONE
7MAIN 0RepeatB 0RepeatT 2.000 2.000 20.000 1.000S_BUTTON GREEN BLUE Repeat NONE
7QBE !Key1 0Dummy 1.667 12.737 10.000 1.000S_ARISTO CYAN BLUE QBEtitle NONE
7QBE !OrdTitle0Dummy 15.167 3.053 12.500 1.000S_ARISTO CYAN NEUTRAL QBEtitle NONE
7QBE 0Order 0OrdList 30.000 3.053 32.500 1.000S_LIST CYAN NEUTRAL QBE1 NONE
7QBE 0OK 0OKtitle 15.167 0.579 12.667 1.474S_BUTTON GREEN NEUTRAL QBE1 NONE
7QBE 0CANCEL 0CAtitle 30.000 0.579 13.167 1.474S_BUTTON RED NEUTRAL QBE1 NONE
7Menu 0Action 0ActLst 0.667 0.053 16.000 12.053S_RADIOV GREEN BLUE Action ON_TOP 10.895
8Select SELECT 2.*
8 FROM 2.
8f1_list
8 WHERE (
8q_where
8 )
8 ORDER BY 0.Order
8Insert INSERT INTO 2. VALUES (
8f_values
8 )
8Update UPDATE 2. SET
8d_values
8 WHERE (
8k_where
8 )
8Delete DELETE FROM 2. WHERE (
8k_where
8 )
8Close CLOSE
8SG_Srvr
8Commit COMMIT
8SG_Srvr
8RollbackROLLBACK
8SG_Srvr
9Main If Root
9 New-Scr 0Title
9 Setoff Z5
9 Seton M0
9 EndIf
9 Setoff Q5
9 Setoff O5
9##########The Z5 flag indicates changes in the database.
9##########In the case of a linked task, M0 is used to indicate that the task is the root task.
9##########The O5 flag indicates that there is an open select query.
9##########The Q5 flag is the "NotQuit" loop flag.
9 Perform Clear
9 Put-Lin#MAIN 0Zero
9 Put-Lin#Menu 0Zero
9##########The following lines find and display the first record.
9 Perform FirstRut
9 Perform Next
9 Perform Display
9##########In the following loop the user is asked to select an action. This loop will continue as long as
9##########the Q5 flag is off.
9Loop
9 While NotQuit
9##########The following Accept command is executed to get the user selection.
9##########When a selection is made, the Dialog ends and a "Switch" begins to execute the selection.
9ActDlg
9 Dialog +0
9 Accept *Action Q5
9 Goto DlgEnd
9 Accept *Repeat Q5
9 Goto DlgEnd
9DlgEnd E-Dialg
9 Q5 Moves 0Quit 0Action
9##########The following switch contains cases for each selection made by the user.
9 Switch 0Action
9 Case 0First
9 Perform FirstRut
9 Perform Next
9 Perform Display
9 QtSwtch
9 Case 0Last
9 Perform Last-1
9 Perform Prev
9 Perform Display
9 QtSwtch
9 Case 0Next
9 Perform Next
9 Perform Display
9 QtSwtch
9 Case 0Prev
9 Perform Prev
9 Perform Display
9 QtSwtch
9 Case 0Add
9##########When Add is selected, an Add loop begins calling the Insert routine as long as the flag I1 is
9##########off.
9 Setoff I1
9 While AddLoop
9 Perform Insert
9 EndBlck
9 Perform FindCur
9 QtSwtch
9 Case 0Upd
9##########When Upd is selected, an Update loop begins calling the Update routine and reading another
9##########as long as there are records to read and the user does not abort the updating process.
9 Setoff U1
9 While UpdLoop
9 Perform Update
9 U1 QtLoop
9 Read 1RECORD I0
9 Perform I/O_ok
9 I0 Seton U1
9 EndBlck
9 Perform FindCur
9 QtSwtch
9 Case 0Del
9 Perform Delete
9 QtSwtch
9 Case 0Query
9 Perform QBE
9 Perform FirstRut
9 Perform Next
9 Perform Display
9 QtSwtch
9 Case 0Quit
9 Message!Exit +2 +1 E1
9 E1=Seton Q5
9 QtSwtch
9 EndSwch
9 EndBlck
9LoopEnd
9########## -------- Main loop end -----------
9 Clr-Lin#MAIN
9 Clr-Lin#Menu
9 Perform Close
9 Perform IfChange
9 Return
9##########The following Insert routine is executed when the Add operation is selected.
9Insert
9 Setoff I1
9 Perform First
9##########The "First" routine is used here to initiate fields and clear them of previous values.
9 Perform Disp*
9Ins1 Perform AccKey
9##########The key fields data are entered by the user in the "AccKey" routine. If the user aborts the data
9##########entry, the flag A1 is set to ON and the Insert routine is aborted.
9 A1 Seton I1 InsEnd
9 Perform AccData
9##########The data fields data are entered by the user in the "AccData" routine. If the user aborts the
9##########data entry, the flag A2 is set to ON and the flow is diverted to the "Ins1" label.
9 A2 Goto Ins1
9 Move +100 0SqErr
9 Ex-Sql ?Insert 0SqErr Q1
9 If NoErr
9 Seton Z5
9 Add 0Record +1 1RECORD
9 Write 1 I0
9 Perform I/O_ok
9 If I/O_ok
9 Move 1RECORD 0Record
9 Else
9 Seton I1
9 EndIf
9 Else
9 Seton I1
9 EndIf
9InsEnd Return
9########## ----- Insert routine end ---------
9##########The following Update routine is executed when the Update operation is selected.
9Update
9 Setoff U1
9 Find 1RECORD I0
9 Perform I/O_ok
9 Perform Disp*
9##########The "Disp*" routine is executed after the record has been found to display the field values.
9 Perform AccData
9 A2 Seton U1 UpdEnd
9 Move +100 0SqErr
9 Ex-Sql ?Update 0SqErr Q1
9 If NoErr
9 Seton Z5
9 Rewrite1 I0
9 Perform I/O_ok
9 EndIf
9UpdEnd Return
9########## ----- Update routine end ---------
9##########The following Delete routine is executed when the Del operation is selected.
9Delete
9 Setoff D1
9 Find 1RECORD I0
9 Perform I/O_ok
9 Message!DelMsg +2 +1 D1
9##########The record is deleted after presentation of a warning message.
9 If Delete
9 Move +100 0SqErr
9 Ex-Sql ?Delete 0SqErr Q1
9 If NoErr
9 Delete 1 I0
9 Perform I/O_ok
9 EndIf
9 EndIf
9 Perform FindCur
9DelEnd Return
9########## ----- Delete routine end ---------
9##########The Display routine is called by other routines to display the current record.
9Display Find 1RECORD I0
9 Perform I/O_ok
9 Perform Disp*
9 Return
9########## ----- Display routine end ---------
9##########The First routine is executed when necessary to intiate the field values.
9FirstRut Move +0 1RECORD
9 Perform First
9 Return
9First Moves 0BLANK 1Key1
9 Setoff F1
9 Return
9########## ----- First routine end ---------
9##########The Last routine is executed when necessary to maximize the field values.
9Last-1 Move 0Max 1RECORD
9 Setoff L1
9 Return
9########## ----- Last routine end ---------
9##########The Next routine is executed when necessary to read the next record.
9Next Setoff N1
9 Read 1RECORD I0
9 Perform I/O_ok
9 I0 Seton N1
9 If Fetch1
9 Perform Fetch1
9 I0=Setoff N1
9 EndIf
9 Return
9########## ----- Next routine end ---------
9##########The Prev routine is performed when necessary to read the previous record.
9Prev Setoff P1
9 Prev 1RECORD I0
9 Perform I/O_ok
9 I0 Seton P1
9 Return
9########## ----- Prev routine end ---------
9##########The following routine is called from other routines in order to locate and display a record.
9FindCur
9 Find 1RECORD I0
9 Perform I/O_ok
9 If Locate
9 Read 1RECORD I0
9 Perform I/O_ok
9 EndIf
9 If Locate
9 Prev 1RECORD I0
9 Perform I/O_ok
9 EndIf
9 If Locate
9 Perform First
9 EndIf
9 Perform Disp*
9 Return
9########## -------- Find Current record routine end -------
9##########The QBE routine is executed when the Query option is selected.
9QBE Put-Lin#QBE 0Zero
9 Setoff E1
9 Perform Clear
9 Perform First
9 Display#QBE
9AccQbe Accept *QBE1 Q2
9 Clr-Lin#QBE
9 If ExcQbe
9##########After a query is typed by the user, a Select Query is executed, followed by a fetching loop.
9 Perform Close
9 Get-Dat0SysDate 0SysTime
9 Encode 0SysTime 0Cursor
9 Move +100 0SqErr
9 Ex-Sql ?Select 0Cursor 0SqErr Q1
9 If NoErr
9 Seton O5
9 Move +0 0Record
9 Perform 10Fetch
9 EndIf
9 EndIf
9 Return
910Fetch Add 0Record +10 0RecCunt
9 Until 10Fetch
9 Perform Fetch1
9 Q1 QtLoop
9 EndBlck
9 Return
9Fetch1
9 Move +0 0SqErr
9 Fetch ?Select 0Cursor 0SqErr Q1
9 Q1-Message!QrErr +1 +1
9 If NoErr
9 Add 0Record +1 1RECORD
9Move2t1 Moves 2Key1 1Key1
9 Write 1 I0
9 Perform I/O_ok
9 I0=Move 1RECORD 0Record
9 EndIf
9 Return
9##########The following routine results in an I/O error message.
9I/O_ok
9 I0-Message!WriteErr+1 +1
9 I0-Seton I1
9 I0-Seton U1
9 I0-Seton D1
9 I0-Seton L1
9 I0-Seton N1
9 I0-Seton P1
9 Return
9##########All user data are entered in the Key fields here.
9AccKey Accept *KEY A1
9 Return
9##########All user data are entered in the Data fields here.
9AccData Accept *DATA A2
9 Return
9Disp* Display*KEY
9 Display*DATA
9 Return
9Close Move +100 0SqErr
9 If Close
9 Ex-Sql ?Close 0Cursor 0SqErr Q1
9 Setoff O5
9 EndIf
9 Return
9IfChange If Changed
9 Move +100 0SqErr
9 Message!Commit 0Two +1 M1
9 M1=Ex-Sql ?Commit 0SqErr Q1
9 M1 Ex-Sql ?Rollback 0SqErr Q1
9 EndIf
9 Return
9Clear Reopen 1 0TempFile
9 Move +0 0Record
9 Move +0 1RECORD
9 Return
BNotQuit ^Q5 ^= ^=
BExcQbe ^Q2 ^= ^= And
B 0CANCEL +0 +0
BClose ^O5 ^+ ^+
BFetch1 ^N1 ^+ ^+ And
B ^O5 ^+ ^+
BRoot ^Z0 ^= ^=
BChanged ^M0 ^+ ^+ And
B ^Z5 ^+ ^+
BNoErr ^Q1 ^= ^=
BI/O_ok ^I0 ^= ^=
B10Fetch 1RECORD 0RecCunt 0RecCunt
BDelete ^D1 ^= ^=
BLocate ^I0 ^+ ^+
BAddLoop ^I1 ^= ^=
BUpdLoop ^U1 ^= ^=
0