home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / bin2ppw.zip / bin2ppw.cmd
OS/2 REXX Batch file  |  1999-11-14  |  3KB  |  84 lines

  1. /*
  2.  * Generator   : PPWIZARD version 99.313
  3.  *             : FREE tool for OS/2, Windows, DOS and UNIX by Dennis Bareis (dbareis@labyrinth.net.au)
  4.  *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5.  * Time        : Sunday, 14 Nov 1999 2:15:17pm
  6.  * Input File  : E:\DB\PROJECTS\OS2\ppwizard\bin2ppw.x
  7.  * Output File : .\OUT\bin2ppw.cmd
  8.  */
  9.  
  10. if arg(1)="!CheckSyntax!" then exit(21924)
  11.  
  12. PgmVersion="99.318"
  13. Parameters=arg(1)
  14. if Parameters='' then
  15. SyntaxError('No parameters passed')
  16. parse var Parameters InputFile Longest Indent RexxVarName
  17. InputFile=strip(InputFile)
  18. if stream(InputFile, 'c', 'query exists') = '' then
  19. SyntaxError('The input file "' || InputFile || '" does not exist.')
  20. if Longest='' then
  21. Longest=16*4
  22. if Indent<> '' then
  23. Indent=copies(' ',Indent)
  24. if RexxVarName='' then
  25. RexxVarName='BinaryData'
  26. DefineRexxS=Indent|| "#DefineRexx ''"
  27. DefineRexxE=Indent|| "#DefineRexx"
  28. say ''
  29. say Indent|| ';---[ ' || InputFile || ' ]----------------------------'
  30. Indent=Indent||copies(' ',7)
  31. say DefineRexxS
  32. say Indent|| 'B = ""'
  33. CharsEachLine=length(Indent)+9+(Longest*2)+3
  34. MaxLines=(1024%CharsEachLine)-1
  35. if MaxLines<1 then
  36. MaxLines=1
  37. TotalRead=0
  38. LinesThisBlock=0
  39. CloseRc=stream(InputFile, 'c', 'close')
  40. do until DataLength<>Longest
  41. Data=charin(InputFile,,Longest)
  42. DataLength=length(Data)
  43. say Indent|| 'B = B || "' || c2x(Data) || '"x'
  44. TotalRead=TotalRead+DataLength
  45. LinesThisBlock=LinesThisBlock+1
  46. if LinesThisBlock>=MaxLines then
  47. do
  48. say DefineRexxE
  49. say DefineRexxS
  50. LinesThisBlock=0
  51. end
  52. end
  53. say Indent||RexxVarName|| ' = B'
  54. say DefineRexxE
  55. CloseRc=stream(InputFile, 'c', 'close')
  56. exit(0)
  57.  
  58. SyntaxError:
  59. ExitRc=SIGL
  60. say '[]---------------------------------------------------------------[]'
  61. say '| BIN2PPW.CMD: Version ' || PgmVersion || ' (C)opyright Dennis Bareis 1998      |'
  62. say '|              http://www.labyrinth.net.au/~dbareis (db0@anz.com) |'
  63. say '[]---------------------------------------------------------------[]'
  64. say ''
  65. say 'This is a simple command to convert a binary file into a PPWIZARD "#evaluate"'
  66. say 'command which creates a rexx variable.  You can regenerate the file using'
  67. say 'simple rexx commands within PPWIZARD (see end of OL_DOC.DH for an example).'
  68. say ''
  69. say 'CORRECT SYNTAX'
  70. say '~~~~~~~~~~~~~~'
  71. say '   BIN2PPW[.CMD]  InputFile  [Longest  [Indent  [RexxVarName]]] [>OutputFile]'
  72. say ''
  73. say 'WHERE'
  74. say '~~~~~'
  75. say '   InputFile   = Name of Input File (all other parameters optional)'
  76. say '   Longest     = Maximum number of bytes to dump in one line'
  77. say '   Indent      = Number of spaces for indenting (0 = none)'
  78. say '   RexxVarName = Name of rexx variable to hold result'
  79. say ''
  80. say 'THE PROBLEM'
  81. say '~~~~~~~~~~~'
  82. say '   ' || arg(1) || ''
  83. exit(ExitRc)
  84.