REQ.BAS - A demo requester program 100 ! REQ.BAS - simple program to request CD/ROM server data 110 ! first cut - very simplistic. Needs following things for production: 120 ! 1. OPENING TRM1: needs to have error trapping routine trap device is busy 130 ! condition, wait a second or so, and try again. 140 ! 2. retry if server request fails. If the comm to the server gets bungled, 150 ! or the server drops a byte receiving a request, or AUTLOG drops a byte 160 ! coming back from server, the job needs to detect the lack of the 170 ! returned data file (INFILE), or a message that tells the request to 180 ! re-submit, and resend the request. Up to five or ten retries should give 190 ! good reliability. 200 ! 210 MAP1 OVERLAYS 220 map2 TEXT'AREA,X,150 230 map3 AS'ARRAY(150),b,1,@TEXT'AREA 240 map3 PACKET,s,150,@TEXT'AREA 250 MAP1 STX,s,1,chr(2) 260 MAP1 ETX,s,1,chr(3) 270 MAP1 ID,S,3 280 MAP1 INFILE,s,40 290 MAP1 BUFF,s,512 300 310 XCALL JOBNO,ID ! ID gets jobtbl slot number as 3 ascii digits (tag field) 320 INFILE = "CAT"+ID+".DAT" 330 340 LOOP: 350 KILL INFILE 360 INPUT LINE "Enter REQUEST type 1-5 ", TYPE 370 CALL BUILD'REQUEST 380 TRIES = 0 390 AGAIN: 400 TRIES = TRIES + 1 410 IF TRIES > 10 GOTO SERVER'DEAD 420 ! note that TRM1 is defined with DEVTBL as NON-SHAREABLE 430 ! PCV0001 is the hard coded name of the TRMDEF the server is attached to. 440 OPEN #1,"TRM1:PCSERV",OUTPUT 450 PRINT #1,PACKET; 460 CLOSE #1 470 ! wit for reply - AUTLOG job will WAKE our job when response is done 480 XCALL SLEEP,60 490 LOOKUP INFILE, SIZE 500 IF SIZE = 0 GOTO AGAIN 510 OPEN #2, INFILE, INPUT 520 INPUT LINE #2,BUFF 530 ? BUFF 540 CLOSE #2 550 GOTO LOOP 560 570 SERVER'DEAD: 580 PRINT "The catalog server is offline." 590 END 600 610 ! This routine builds the server request packet 620 BUILD'REQUEST: 630 PACKET = SPACE(150) 640 PACKET[1,1] = STX 650 PACKET[2,4] = TYPE USING "#ZZ" 660 PACKET[5,7] = ID ! this is the tag field 670 PACKET[8,15] = 150 USING "#ZZZZZZZ" 680 IF TYPE = 3 PACKET[16,17]="52" !makes for '52 690 IF TYPE = 4 PACKET[16,20]="52NAS" !models for '52 NASH 700 IF TYPE = 5 PACKET[16,23]="52NASCOU" !models for '52 NASH COUPE 710 PACKET[150,150] = ETX 720 CALL CALC'CHECKSUM 730 RETURN 740 750 ! Calculate checksum as ls 8 bits of of sum of all bytes in packet 760 CALC'CHECKSUM: 770 CSUM = 0 780 FOR I= 1 to 146 790 CSUM = CSUM + AS'ARRAY(I) 800 NEXT I 810 CSUM = (CSUM AND 255) 820 PACKET[147,149] = CSUM USING "#ZZ" 830 RETURN 840 850 ! end of REQ.BAS