home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ppwizard.zip / bin2ppw.cmd next >
OS/2 REXX Batch file  |  2000-02-09  |  3KB  |  78 lines

  1. /*
  2.  * Generator   : PPWIZARD version 2K.020
  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        : Wednesday, 9 Feb 2000 8:01:43pm
  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="2K.039"
  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. end
  47. say Indent||RexxVarName|| ' = B'
  48. say DefineRexxE
  49. CloseRc=stream(InputFile, 'c', 'close')
  50. exit(0)
  51.  
  52. SyntaxError:
  53. ExitRc=SIGL
  54. say '[]---------------------------------------------------------------[]'
  55. say '| BIN2PPW.CMD: Version ' || PgmVersion || ' (C)opyright Dennis Bareis 1998      |'
  56. say '|              http://www.labyrinth.net.au/~dbareis (db0@anz.com) |'
  57. say '[]---------------------------------------------------------------[]'
  58. say ''
  59. say 'This is a simple command to convert a binary file into a PPWIZARD "#evaluate"'
  60. say 'command which creates a rexx variable.  You can regenerate the file using'
  61. say 'simple rexx commands within PPWIZARD (see end of OL_DOC.DH for an example).'
  62. say ''
  63. say 'CORRECT SYNTAX'
  64. say '~~~~~~~~~~~~~~'
  65. say '   BIN2PPW[.CMD]  InputFile  [Longest  [Indent  [RexxVarName]]] [>OutputFile]'
  66. say ''
  67. say 'WHERE'
  68. say '~~~~~'
  69. say '   InputFile   = Name of Input File (all other parameters optional)'
  70. say '   Longest     = Maximum number of bytes to dump in one line'
  71. say '   Indent      = Number of spaces for indenting (0 = none)'
  72. say '   RexxVarName = Name of rexx variable to hold result'
  73. say ''
  74. say 'THE PROBLEM'
  75. say '~~~~~~~~~~~'
  76. say '   ' || arg(1) || ''
  77. exit(ExitRc)
  78.