acliu@skat.usc.edu (Alex C. Liu) (12/10/89)
FILE: help unhexf.bas LAST CHANGE: Dec 8th, 1989 VERSION: UX-Maze Server V2.0c 100 REM SIMPLE UNHEXIFY PROGRAM (UNTESTED) 110 REM BY ALEX C. LIU 111 REM NOTE THIS PROGRAM IS SIMPLY INTENDED AS AN EXAMPLE 112 REM ON HOW TO DECODE HEXF FILES 113 REM NO ATTEMPT HAS BEEN MADE TO VERIFY THE CORRECTNESS OF 114 REM THE CODE 115 REM 120 INPUT "ENTER SEQ FILE TO UNHEXIFY", F$ 130 INPUT "ENTER DEFAULT OUT FILE TYPE", T$ 140 OPEN 1,8,8,F$+",S,R" 150 GOSUB 1000 160 IF LEFT$(X$,5) = "HEXF " OR LEFT$(X$,5) = "hexf " THEN 170 Z$ = MID$(X$,6):C = 0 180 OPEN 2,8,9,Z$+","+T$+",W" 190 GOSUB 1000:C = C + 1 200 IF LEFT$(X$,3) = "END" OR LEFT$(X$,3) = "end" THEN 310 205 IF(LEFT$(X$,1)<>":")THEN PRINT"NO : ON LINE "C" (INGNORING LINE)":GOTO 300 210 H$ = MID$(X$,2,2) 220 GOSUB 2000 230 L=X: SUM = 0: IF NOT(L) THEN 280 240 FOR N=1 TO L 250 H$=MID$(X$,N*2 + 2,2):GOSUB 2000 260 SUM = SUM + X: PRINT#2,CHR$(X); 270 NEXT 280 H$=MID$(X$,L*2+4,2):GOSUB 2000 290 IF (X <> (SUM AND 255)) THEN PRINT "BAD CHECKSUM ON LINE "C 300 IF (SS = 0) THEN 190 310 CLOSE 1:CLOSE 2 320 END 1000 X$="" 1010 GET#1,U$: SS = ST: IF SS <> 0 THEN RETURN 1020 IF U$=CHR$(13) THEN RETURN 1030 X$=X$+U$:GOTO 1010 2000 MH$ = LEFT$(H$,1): GOSUB 3000: X = MX 2010 MH$ = RIGHT$(H$,1):GOSUB 3000: X = X * 16 + MX 2020 RETURN 3000 IF ("0" <= MH$ AND MH$ <= "9") THEN MX=VAL(MH$):RETURN 3010 IF ("A" <= MH$ AND MH$ <= "F") THEN MX=ASC(MH$)-ASC("A") + 15:RETURN 3020 IF ("a" <= MH$ AND MH$ <= "f") THEN MX=ASC(MH$)-ASC("a") + 15:RETURN 3030 PRINT "BAD HEX DIGIT "MH$"!" 3040 MX=0:RETURN --- Alex C. Liu acliu%skat@usc.edu acliu@skat.usc.edu (Simple .signature, $CHEAP$)