THE LEX FILE COLUMN - No 1 Reference: "HP-71 Basic Made Easy" by Joseph Horn. INTRODUCTION For the owners of the 71 without any access to magnetic cards or HPIL magnetic media the entry of LEX or binary files may seem impossible. The reference describes a program which allows the entry of such files byte by byte with built in error checking. HPCC intends to publish LEX files in this form on a regular basis for entry via a modified version of program MAKELEX. MAKELX2 The program should be entered as shown. Run the program and input the number of bytes that is printed at the top of of the LEX file listing. Then key in the hex code of the file, starting with line 000 (do not type in the spaces). After each line of code input its checksum byte as printed to the right of the line of code. Procede thus until the last line, after which the program will automatically end. TURN THE HP-71 OFF AND BACK ON to link the new LEX file into the file chain, the new functions will now be available. 0010 ! MAKELX2 0020 CALL MLEX @ SUB MLEX @ SFLAG -1 @ PURGE AH @ BEEP 200 @ INPUT "No of bytes : ";N @ LC OFF 0030 CREATE DATA AH,1,N-4 @ A=HTD(ADDR$("AH")) @ B=A @ GOSUB 140 0040 Q=1 @ X=0 @ BEEP 200 @ INPUT "000: ",P$;A$ @ C$=A$ @ S=0 @ GOSUB 100 0050 Q=2 @ X=1 @ GOSUB 90 @ A$=A$&C$ @ A=A+37 @ N=N*2+37 @ Q=3 @ SFLAG 5 @ FOR X=2 TO N DIV 16-1 0060 GOSUB 90 @ C$=C$[5*FLAG(5)+1] @ POKE DTH$(A),C$ @ A=A+16-5*FLAG(5,0) @ NEXT X @ Q=4 0070 DISP DTH$(X)[3]; @ BEEP 283 @ INPUT ": ",P$[1,MOD(N,16)];C$ @ GOSUB 100 0080 POKE DTH$(A),C$ @ POKE DTH$(B),A$ @ CFLAG -1 @ BEEP 800 @ PUT "#43" @ END 0090 DISP DTH$(X)[3]; @ BEEP 400 @ INPUT ": ",P$;C$ 0100 DISP DTH$(X)[3]; @ BEEP 566 @ INPUT " ck ","---";D$ 0110 M=S @ FOR Z=1 TO LEN(C$) @ M=NUM(C$[Z])+M+1 @ NEXT Z 0120 IF D$=DTH$(MOD(M,4096))[3] THEN GOSUB 140 @ S=M @ RETURN 0130 BEEP 1000 @ DISP "checksum error" @ P$=C$ @ POP @ ON Q GOTO 40,50,60,70 0140 P$="----------------" @ RETURN 0150 END The program that generates the table of bytes is called DUMPLX2 and sends the bytes to a text file. 0010 ! DUMPLX2 0020 STD @ DESTROY A$,F$,P$,Q$ 0030 BEEP 200 @ INPUT "File ? ";F$ @ F$=UPRC$(F$) @ ON ERROR GOTO 30 0040 IF F$[1,1]="" THEN OFF ERROR @ GOTO 150 0050 A=HTD(ADDR$(F$)) @ OFF ERROR @ T$=PEEK$(DTH$(A+16),2) 0060 IF T$#"80" THEN BEEP 1000 @ DISP F$;" # LEXfile !" @ GOTO 30 0070 BEEP 400 @ CAT F$ @ Q$=F$[1,LEN(F$)-2]&"HD" @ CREATE TEXT Q$ @ ASSIGN#1 TO Q$ 0075 Z$=PEEK$(DTH$(A+32),5) @ CALL REV(Z$) 0080 N=HTD(Z$)+32 @ Y=MOD(N,16) @ W=CEIL((N-37)/2) @ V=W*2+37-N 0085 Z$=PEEK$(DYH$(A+37),2) @ CALL REV(Z$) 0090 P$[1]=F$ @ P$[11]="ID#"&A$ @ P$[18]=STR$(W)&" bytes" @ PRINT #1;P$ 0100 PRINT #1;"" @ P$="" @ P$[6]="0123456789ABCDEF ck" @ PRINT #1;P$ @ PRINT @ PRINT #1;"" @ S=0 0110 FOR X=0 TO N DIV 16-1 @ A$=PEEK$(DTH$(A),16) @ GOSUB 160 @ NEXT X 0120 A$=PEEK$(DTH$(A),Y)&"F"[1,V] @ GOSUB 160 @ A$=A$[17] 0130 IF LEN(A$) THEN X=X+1 @ GOSUB 160 0140 PRINT #1;"" @ CAT Q$ 0150 FIX 2 @ BEEP 800 @ PUT "#43" @ END 0160 P$[1]=DTH$(X)[3]&": " @ P$[6]=A$[1,16] @ GOSUB 180 @ P$[23]=M$ 0170 PRINT #1;P$ @ A=A+16 @ RETURN 0180 FOR Z=1 TO LEN(A$) @ S=NUM(A$[Z])+S+1 @ NEXT Z 0190 M$=DTH$(MOD(S,4096))[3] @ RETURN 0200 SUB REV(Z$) 0210 L=LEN(Z$) @ DIM Z9$[L] 0220 FOR I=L TO 1 STEP -1 @ Z9$=Z9$&Z$[I,I] @ NEXT I 0230 Z$=Z9$ 0240 END SUB LEXFILES a. CURVIEW. During text entry it is useful to know the current cursor position this file provides position value when in User mode by pressing [f][.] and does not disturb the text or display-there is no function name. b. CURLEX. Again there is no function name and operates in User mode. The cursor movement [g][>] and [g][<] moves a displays width instead of going to the extremities of the line. c. MARGELEX. When using a text editor it is useful to work within a standard line width. This file provides a new function: MARGIN(n) where n=the desired right hand margin. At character n-1 a beep will occur to warn of the right hand margin. CURVIEW ID#71 90 bytes CURLEX ID#5E 110 bytes MARGELEX ID#71 92 bytes 0123456789ABCDEF ck 0123456789ABCDEF ck 0123456789ABCDEF ck 000: 3455256594547502 357 000: 345525C454850202 359 000: D414257454C45485 375 001: 802E100100101000 68A 001: 802E103022010178 6A1 001: 802E107212010178 6C2 002: 9B00017000000000 9BD 002: 0E000E5000000000 9E0 002: DB00017D1D100000 A2A 003: FE0000000800001F D17 003: FE0000000800001F D3A 003: F710000000200000 D5A 004: F31B196140001103 06D 004: F31B19614000DB10 0B2 004: 085000DBD4142574 0CC 005: 1B09664FDBD5317F 41F 005: B317F8FC46314901 442 005: 94E4D11FF31C1961 46C 006: 8FC4631D9D75ED1F 7EB 006: 1BD70011BD71188F 7D7 006: 4000DB10B1F789F2 800 007: 7B8F2D231C28FFA0 BA8 007: B14B1DA31F9962D0 B7E 007: 14B1EE74F14F9669 BAC 008: B11FE74F2AF214F8 F66 008: 310A962C00031446 ED9 008: 08FA5CE011BD7007 F4E 009: F4BCE0B64041F7B8 322 009: 7003134AF0AEAAF2 282 009: 4000B30008F871F0 2BB 00A: F23103814908E0A6 69B 00A: 31418FB34B1ADA10 61C 00A: 8FBC6315708AC40D 668 00B: A149171AE0810A6A A2A 00B: 3078F534B1078F53 9A0 00B: 031069EA40DA1F78 A00 00C: 1491F7B8F28F7415 DC7 00C: 4B10710811B8F1C3 D20 00C: 9F2CC1498D84A808 DAE 00D: 182184001 F99 00D: 2011BA5E48010B59 09E 00D: DE6A208D39450 09E 00E: E118068FB14B1068 429 00F: FB14B10684082101 797 010: F 7DE Any queries please contact me on 01-319-1332. Note: The reference is recommended for all 71 owners and is available from Educalc or Synthetix at »18.95. John Bruce 164N