| Appendix |
|
| Description | Embedded I/O
procedures allow the developer to intercept file Input
and Output operations on a ProvideX KEYED data file. A
user-defined program is logically PERFORMed during any
OPEN, READ, WRITE, REMOVE and CLOSE operation. The program to be PERFORMed must be specified in the Data Dictionary maintenance function in Nomads to enable this feature. The Embedded I/O program must exist and be accessible using the standard PREFIX search rules in order to open the data file. If the program does not exist, then an Error 121 (Invalid program format) is reported. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| How it works | Whenever a
keyed file is opened (VLR or EFF), its file header is
checked to see if an embedded IO program in specified. If
so, the system will then load and issue a PERFORM to
various pre-defined entry points within the program in
accordance to the file IO operation being executed. For
example when a REMOVE is executed, the system will look
for, and if found, issue a PERFORM to the label
PRE_REMOVE. The programmer only need to define those entry points they need to use, for example if the logic does not need to intercept the READ directive, then the PRE_READ and/or POST_READ entry points do not need to be defined. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Calling parameters | Most entry
points are passed four arguments that can be accessed by
an ENTER directive (no parameters are sent to
OPEN/CLOSE).
Where:
In addition to the parameters passed to the embedded IO program, the program can return values to the file system to change the normal IO behaviour by altering the record contents etc. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Entry point/parameter information | The
following is the table of pre-defined entry points that
will be logically PERFORMed, the value passed in the
fourth argument, and what return value can be sent back,
if desired:
1 There is no line label entry
point used when a file is OPENed as the program is simply
PERFORMed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | As the embedded IO program is performed, care must be taken that NO variables are changed within the code. All variables used should be declared as LOCAL or the routine can issue a CALL to insulate the mainline program from the IO routine. The advantage of the PERFORM is that other variables that may exist in the application will still be accessible to the logic. In particular, you should always LOCALize the entry parameters as shown above. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example | 0010 !
ENCRYPT - Embedded I/O Procedure to encrypt data 0100 ! ^100 0110 OPEN: 0120 LOCAL P$ 0130 IF %PASSWORD$="OK" THEN GOTO 0190 0140 PRINT 'WINDOW'(10,10,50,6,"Password?",'MODE'($000F$)+'CS'), 0150 OBTAIN (0,ERR=0160)@(0,1),"Please enter the password? ",P$ 0160 PRINT (0,ERR=*NEXT)'POP', 0170 IF UCS(P$)<>"PASSWORD" OR CTL<>0 THEN EXIT 52 0180 %PASSWORD$="OK" 0190 EXIT 0200 ! ^100 0210 POST_READ: LOCAL VALUE$,ACCESS_MODE,KEY$,INDEX,V$ 0220 ENTER ACCESS_MODE,KEY$,INDEX,V$ 0230 VALUE$=V$; GOSUB ENCRYPT_IT; RETURN VALUE$ 0240 END 0300 ! ^100 0310 PRE_WRITE: LOCAL VALUE$,ACCESS_MODE,KEY$,INDEX,V$ 0320 ENTER ACCESS_MODE,KEY$,INDEX,V$ 0330 VALUE$=V$; GOSUB ENCRYPT_IT; RETURN VALUE$ 0340 END 1000 ! ^1000 1010 ENCRYPT_IT: 1020 LOCAL ENCRYPT_STRING$ 1030 IF VALUE$="" THEN RETURN 1040 ENCRYPT_STRING$=Use this string to randomize the data" 1050 ENCRYPT_STRING$=DIM(LEN(VALUE$),ENCRYPT_STRING$) 1060 VALUE$=XOR(VALUE$,ENCRYPT_STRING$) 1070 RETURN |