; CONVERT
;
; Program for Proteus
;
; (C) 2003-2004 Simone Zanella Productions
;
; Convert the input file (binary) into an array that can be used inside a "C" program.
#!proteus -z
IF LT(ARGC, 5)
CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " [file.bin]"
CONSOLELN ""
CONSOLELN "Purpose: convert a binary file into an array of 'unsigned char';"
CONSOLELN "write result to standard output."
ABORT 0
FI
H = FOPEN(ARGV(5), 1)
CONSOLELN "unsigned char map[] = {"
WHILE NOT(FEOF(H))
L = FREAD(H, 50)
S = ""
FOR X = 1 TO STRLEN(L)
S = S IIF(GT(STRLEN(S), 0), ", ", "") " 0x" PFORMAT("X", ASC(SUBSTR(L, X, 1)))
NEXT
CONSOLELN S IIF(NOT(FEOF(H)), ",", "")
LOOP
CONSOLELN "};"
FCLOSE(H)
ABORT 0