BIN2AR 1.2 ****** D.N. Rassokhin 1994 ************************************** Just compare this C-style string initializer with the text that will appear on the computer screen if you run BIN2AR without parameters and decide which is easier to write! The string initializer: char szHlpString[]= "BIN2AR 1.2 ****** D.N. Rassokhin 1994 *** SHAREWARE (see BIN2AR.D" "OC) *********\nBIN2AR utility converts a binary or text file to C" "-style initializer list\nfor an array of characters or C-style ze" "ro-terminated string literal.\nUsage: bin2ar source [output] [/s:" "nn] [/e:nn] [/d] [/v:name] [/x]\nor: bin2ar source [output] /z" " [/s:nn] [/e:nn] [/d] [/v:name] [switches2...]\nIf output filenam" "e is not given, it will be produced from the source filename\nby " "changing the extension to \'.C\'.\n/z - make C-style zero-termina" "ted string literal rather than array initializer.\n/d - override " "an existing file with the same name as output filename.\n/s:nn - " "start source file offset (default -- 0). nn denotes a decimal con" "stant.\n/e:nn - end source file offset (default -- EOF).\n/v:name" " - give the name \'name\' to the array or string variable. \'name" "\' must\n be a valid C name; defaults are \'ucharArray\' and \'sz" "String\', respectively.\n/x - represent all characters with their" " hex codes (has no effect with /z).\n********** switches2 (have n" "o effect without /z) are:\n/r - exclude CR characters (\'\\r\');\n" "/n - replace each LF character (\'\\n\') with the Space character" " (\'\\x20\');\n/f - exclude Ctrl-Z characters (\'\\x1A\' -- DOS E" "OF marker);\n/t:nn -- set the Tab stop to replace TAB character w" "ith Spaces (by default,\n TABs not replaced). Do NOT use this swi" "tch if the source file contains non-\n printable characters other" " than \'\\t\', \'\\n\' and \'\\r\' in one line with \'\\t\'!"; The function call: puts(szHlpString); produces the following screen output: BIN2AR 1.2 ****** D.N. Rassokhin 1994 *** SHAREWARE (see BIN2AR.DOC) ***** BIN2AR utility converts a binary or text file to C-style initializer list for an array of characters or C-style zero-terminated string literal. Usage: bin2ar source [output] [/s:nn] [/e:nn] [/d] [/v:name] [/x] or: bin2ar source [output] /z [/s:nn] [/e:nn] [/d] [/v:name] [switches2...] If output filename is not given, it will be produced from the source filename by changing the extension to '.C'. /z - make C-style zero-terminated string literal rather than array initializer. /d - override an existing file with the same name as output filename. /s:nn - start source file offset (default -- 0). nn denotes a decimal constant. /e:nn - end source file offset (default -- EOF). /v:name - give the name 'name' to the array or string variable. 'name' must be a valid C name; defaults are 'ucharArray' and 'szString', respectively. /x - represent all characters with their hex codes (has no effect with /z). ********** switches2 (have no effect without /z) are: /r - exclude CR characters ('\r'); /n - replace each LF character ('\n') with the Space character ('\x20'); /f - exclude Ctrl-Z characters ('\x1A' -- DOS EOF marker); /t:nn -- set the Tab stop to replace TAB character with Spaces (by default, TABs not replaced). Do NOT use this switch if the source file contains non- printable characters other than '\t', '\n' and '\r' in one line with '\t'! Without a doubt writing a clear text as it is to appear onscreen is much easier than writing a C-style string that represents that text. Relax! Write your help screens or any other long text messages in your favorite text editor. Using BIN2AR utility, you can easily convert the text into C-style string to put into a program. Also, BIN2AR can convert binary or text files into C array initializers. This may be useful to put the whole binary file, or its part, into a C (or C++) program as an array. To make it easier to keep your projects up-to-date, you can simply include into the projects (by using makefiles and MAKE utility, or IDEs) the files containing the long messages, or binary information to be put into programs. BIN2AR will convert those files into *.C files with the corresponding initializers, the latter then can be either compiled with a C compiler and linked with other progect's *.OBJs, *.LIBs, etc., into executable files, or included into other C or C++ modules by the #include directive. Should you change a message, just edit a corresponding text file and run MAKE (or use IDE's Make facility). dima@aries.scs.uiuc.edu http://www.scs.uiuc.edu/~dima/