home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / bt_2k033.zip / BINTOOL.INF (.txt) < prev    next >
OS/2 Help File  |  2000-02-02  |  38KB  |  1,252 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Introduction ΓòÉΓòÉΓòÉ
  3.  
  4. Introduction 
  5.  
  6. This is binary editor (or file creator) which takes all commands via a text 
  7. file or command line. 
  8.  
  9. It can verify the contents of files before a patch is applied. The following is 
  10. an example of how a file can be created: 
  11.  
  12.    OPENNEW  L4029.PIC
  13.    WRITE   '1B'x || '[K' || '0B00 FF31 02 A0 04 00 00 0000 90'x
  14.    CLOSE
  15.  
  16. This program does not have commands such as #define & #include as its expected 
  17. that you'd add a PPWIZARD preprocessor step if you wanted the much more power 
  18. capabilities (macros with parameters, conditional inclusion etc). 
  19.  
  20. Please see my web page "http://www.ozemail.com.au/~dbareis". for the latest 
  21. copy of BINTOOL or PPWIZARD, or contact me (Dennis Bareis) via email 
  22. (db0@anz.com).  I'm open to any reasonable suggestions. 
  23.  
  24. Please have a look at the proposed changes section and after using this program 
  25. for a while tell me what you think. 
  26.  
  27. Note that I would have loved to have written this in Java, however as a 
  28. compiled language it does not have an "interpret" instruction. Apparently 
  29. something is being added to version 1.2 which might allow something similar, 
  30. I'll have a look then.  The "interpret" instruction is important as it allows 
  31. the preprocessor to be extended as well as doing a lot of work I'd otherwise 
  32. need to do myself (and I wouldn't do it as well).  I will not be rewriting the 
  33. preprocessor in Java (as it wouldn't be compatible with the rexx version), but 
  34. with any luck I'd be able to write any similar future stuff in Java.... 
  35.  
  36.  
  37. ΓòÉΓòÉΓòÉ 1.1. Proposed Changes ΓòÉΓòÉΓòÉ
  38.  
  39. If I've got the time I like to think about the best way of implementing 
  40. something (as well as questioning whether or not it should be).  If I have a 
  41. requirement I like to implement as generic a solution as possible.  This is my 
  42. "longer" term think about it list.. 
  43.  
  44. Come on, surely someone out there wishes this had an "xyz" feature or something 
  45. worked better?  I've only had one single comment about its functioning and this 
  46. prompted me to make a change, since there have been so many downloads of this 
  47. tool its either crap or perfect... I don't think its crap, but then again I 
  48. doubt its perfect either, so comments please!  Tell me what you think even if 
  49. option is already listed as without feedback on whats important I could reasign 
  50. priorities or delete an item altogether. 
  51.  
  52. Proposed Changes - Rough Priority 
  53.  
  54.        1. Command line parameters (such as /DEBUG, and /PARM). 
  55.  
  56.        2. Better output from script, get rid of commands, show again if in 
  57.           debug mode (plus normal interactive stuff) + maybe more. 
  58.  
  59.        3. DELETE command.  Deletes specified number of bytes (shrinks file). 
  60.  
  61.        4. COPY  command.  Copies  specified number of bytes to specified file. 
  62.           A CUT becomes a COPY then DELETE. 
  63.  
  64.        5. INSERT command.  Insert contents of file.  Also Insert specified 
  65.           bytes. 
  66.  
  67.        6. BOOKMARK locations.  Then "MoveTo Fred" etc. 
  68.  
  69.  
  70. ΓòÉΓòÉΓòÉ 1.2. Change History ΓòÉΓòÉΓòÉ
  71.  
  72. Change History 
  73.  
  74.        1. Version 2K.033 
  75.  
  76.               Can now make better use of rexx variables by allowing variable 
  77.                substitution into command lines. 
  78.               Fixed file open commands to die on open failure. 
  79.               4th parameter of ReplaceString() no longer exists. 
  80.  
  81.  
  82. ΓòÉΓòÉΓòÉ 1.3. Bugs ΓòÉΓòÉΓòÉ
  83.  
  84. Currently Known Bugs 
  85.  
  86.  Reporting Bugs or Suggestions 
  87.  
  88.  If reporting bugs please supply: 
  89.  
  90.        1. All files involved (input, output and any Batch files used to run the 
  91.           preprocessor).  You have hopefully trimmed out everything which is 
  92.           not required to reproduce the problem. 
  93.  
  94.        2. A detailed description of the problem. 
  95.  
  96.  The easier you make it for me the faster I will be able to come up with a fix 
  97.  or tell you what your doing wrong etc. 
  98.  
  99.  
  100. ΓòÉΓòÉΓòÉ 2. BINTOOL.CMD Command Line ΓòÉΓòÉΓòÉ
  101.  
  102. BINTOOL.CMD Command Line 
  103.  
  104.         BINTOOL[.CMD]  [whitespace]?[whitespace]         OR
  105.         BINTOOL[.CMD]  [whitespace]ScriptFile[whitespace]
  106.  
  107. This program has two main modes "INTERACTIVE" mode where the user enters all 
  108. information from a command prompt and file driven.  If "?" is specified 
  109. interactive mode is used otherwise you supply the name of the file which 
  110. contains the commands to be executed. 
  111.  
  112. In both modes blank lines and ones that begin with ";" are ignored.  If a line 
  113. contains ";;" then the last occurrance within a line and anything following is 
  114. removed (inline comment). 
  115.  
  116. Script Mode 
  117.  
  118. If a command or verification fails the script terminates. 
  119.  
  120. Interactive Mode 
  121.  
  122. If a command or verification fails an error is displayed but the program does 
  123. not terminate. 
  124.  
  125. The command prompt maintains a history of previous commands and all usual keys 
  126. work including "<F1>" or selective recall. 
  127.  
  128. In interactive mode the "RECORD" command can be used to record all the commands 
  129. typed so you can later on rerun what you have recorded to repeat if required. 
  130.  
  131. RETURN CODES 
  132.  
  133.          A return code of 0 indicates success. 
  134.  
  135.          Any other value indicates an error occurred. 
  136.  
  137.  
  138. ΓòÉΓòÉΓòÉ 2.1. /Color ΓòÉΓòÉΓòÉ
  139.  
  140. Switch /Color[:YesOrNo] 
  141.  
  142. This is a BINTOOL.CMD command line switch.  You can set up your own default 
  143. switches in the "BINTOOL_OPTIONS" environment variable. You can determine if 
  144. colors are used in displayed output.  Useful if redirecting output to log files 
  145. (or you just hate colors!). 
  146.  
  147. If the "YesOrNo" is not specified then it defaults to "Y", otherwise one of the 
  148. following values is expected: 
  149.  
  150.          Y 
  151.          N 
  152.          YES 
  153.          NO 
  154.  
  155.  For colors to work the session must support ANSI color strings. OS/2 does this 
  156.  by default.  NT does not seem to. 
  157.  
  158.  
  159. ΓòÉΓòÉΓòÉ 2.2. /Debug ΓòÉΓòÉΓòÉ
  160.  
  161. Switch /Debug 
  162.  
  163. This is a BINTOOL.CMD command line switch.  You can set up your own default 
  164. switches in the "BINTOOL_OPTIONS" environment variable. This option can be 
  165. useful in determining what is going wrong when you don't get the output you 
  166. expected. 
  167.  
  168.  
  169. ΓòÉΓòÉΓòÉ 3. Commands ΓòÉΓòÉΓòÉ
  170.  
  171. Commands 
  172.  
  173. The following commands are available to you when you use the BINTOOL.CMD: 
  174.  
  175.          CLOSE 
  176.          DECIMAL 
  177.          DUMP 
  178.          DUMPCHAR 
  179.          EXIT 
  180.          GOTO 
  181.          FIND 
  182.          FINDCS 
  183.          HEXADECIMAL 
  184.          LOCATE[!] 
  185.          MOVETO 
  186.          ONERROR 
  187.          OPEN 
  188.          OPENNEW 
  189.          OPENREAD 
  190.          QUIT 
  191.          REBUILD 
  192.          RECORD 
  193.          REXX 
  194.          SYSTEM 
  195.          VERIFY 
  196.          VERIFYFILE 
  197.          WRITE 
  198.          ? 
  199.  
  200.  Note that a lot of the commands are demonstrated further in the example 
  201.  scripts that are included in this manual.  Also note that for anything but 
  202.  trivial scripts its worth the effort to include a "PPWIZARD" step in a batch 
  203.  file rather than using BINTOOL directly.  This would allow you to use more 
  204.  powerful commands such as #define, #evaluate, #include, #if and more. 
  205.  
  206.  
  207. ΓòÉΓòÉΓòÉ 3.1. CLOSE ΓòÉΓòÉΓòÉ
  208.  
  209. CLOSE 
  210.  
  211. This will close the currently open file.  It does not take parameters. 
  212.  
  213.  
  214. ΓòÉΓòÉΓòÉ 3.2. DECIMAL ΓòÉΓòÉΓòÉ
  215.  
  216. DECIMAL 
  217.  
  218. If you do not specifically indicate that a number is in either hex or decimal 
  219. then by default the number is assumed to be hexadecimal. To indicate a number 
  220. is in base 10 preceed the number with '$', for hexadecimal use 'x'. 
  221.  
  222. This commands purpose is to change the default to decimal.  To restore it use 
  223. the "HEXADECIMAL" command. 
  224.  
  225.  
  226. ΓòÉΓòÉΓòÉ 3.3. DUMP ΓòÉΓòÉΓòÉ
  227.  
  228. DUMP 
  229.  
  230. This command will dump all or part of the current file in both hex and 
  231. character modes.  The default character set used is ASCII with dots used for 
  232. unusual characters, if this is unsuitable you could create your own character 
  233. tables and load them with the "DUMPCHAR" command. 
  234.  
  235. A second dump command immediately following a previous one will always continue 
  236. from where the previous one left off.  Commands which affect the current 
  237. position (such as WRITE) will reset the position from which following dumps 
  238. take place. 
  239.  
  240. A dump command does not move the read/write position. 
  241.  
  242. Syntax 
  243.  
  244.    [whitespace]DUMP [whitespace][NumBytesToDump][whitespace]
  245.  
  246. The "NumBytesToDump" specifies the number of bytes to dump.  If not specified a 
  247. default is used. 
  248.  
  249. EXAMPLE OF DUMP OUTPUT 
  250.  
  251.    40: 0E1F BA0E 00B4 09CD 21B8 014C CD21 5468   | ........!..L.!Th |
  252.    50: 6973 2070 726F 6772 616D 2063 616E 6E6F   | is program canno |
  253.    60: 7420 6265 2072 756E 2069 6E20 6120 444F   | t be run in a DO |
  254.    70: 5320 7365 7373 696F 6E2E 0D0D 0A24 0000   | S session....$.. |
  255.  
  256.  
  257. ΓòÉΓòÉΓòÉ 3.4. DUMPCHAR ΓòÉΓòÉΓòÉ
  258.  
  259. DUMPCHAR 
  260.  
  261. This command allows you to redefine the character set used in the character 
  262. portion of a dump.  This could be as simple as changing the ASCII character set 
  263. so that blanks are used instead of dot for unusual chacters.  See EBCDIC.BIN 
  264. for an example for how to create a new character set. 
  265.  
  266. Syntax 
  267.  
  268.    [whitespace]DUMPCHAR [whitespace][["]CharacterSetFile["]][whitespace]
  269.  
  270. The "CharacterSetFile" specifies the name of the file to be loaded.  If not 
  271. specified then the character set is restored to the default. 
  272.  
  273. FORMAT OF FILE 
  274.  
  275. The following describes the contents of the file (all bytes in ASCII): 
  276.  
  277.        1. It must begin with the string "DUMPCHAR". 
  278.  
  279.        2. The character "|". 
  280.  
  281.        3. A description of the file, displayed when loaded. 
  282.  
  283.        4. The character "|". 
  284.  
  285.        5. There must be exactly 256 characters which are mapped to the hex 
  286.           value. 
  287.  
  288.  
  289. ΓòÉΓòÉΓòÉ 3.5. EXIT ΓòÉΓòÉΓòÉ
  290.  
  291. EXIT 
  292.  
  293. In interactive mode this will exit the program.  Opened files will be closed. 
  294.  
  295.  
  296. ΓòÉΓòÉΓòÉ 3.6. FIND ΓòÉΓòÉΓòÉ
  297.  
  298. FIND 
  299.  
  300. This command will FIND a number of bytes in the file from the current location 
  301. onwards.  If we don't find the string then the current file position is 
  302. restored. 
  303.  
  304. This command is used to perform a case insensitive search.  If you require a 
  305. case sensitive search you should use "FINDCS" instead.  Note for performance a 
  306. case sensitive search will be performed anyway if your search string does not 
  307. contain any letters. 
  308.  
  309. Syntax 
  310.  
  311.    [whitespace]FIND [whitespace]RexStringExpression[whitespace]
  312.  
  313. The "RexStringExpression" is a rexx expression which will be executed.  The 
  314. result should be a string which is to be verified. 
  315.  
  316. EXAMPLES 
  317.  
  318.    FIND    '0000'x || copies('*', 8) || '0B00'x   ;;Look for these 12 bytes
  319.    WRITE   'FFFF'x                                ;;Patch the first 2 bytes
  320.  
  321.  
  322. ΓòÉΓòÉΓòÉ 3.7. FINDCS ΓòÉΓòÉΓòÉ
  323.  
  324. FINDCS 
  325.  
  326. This command is the same as the "FIND" command except that a case sensitive 
  327. search is performed. 
  328.  
  329.  
  330. ΓòÉΓòÉΓòÉ 3.8. GOTO ΓòÉΓòÉΓòÉ
  331.  
  332. GOTO 
  333.  
  334. This command will transfer control to the line with the label specified. 
  335.  
  336. Syntax 
  337.  
  338.    [whitespace]GOTO [whitespace]Label[whitespace]
  339.  
  340. The "Label" is the name of a label that should be defined somewhere in the 
  341. source script (either before or after the current location). 
  342.  
  343. EXAMPLES 
  344.  
  345.    ;--- Transfer control to the "END" label ---
  346.    GOTO    END
  347.    ...
  348.    ...
  349.  
  350.    ;--- Define the "END" label ----------------
  351.    :End
  352.  
  353.  
  354. ΓòÉΓòÉΓòÉ 3.9. HEXADECIMAL ΓòÉΓòÉΓòÉ
  355.  
  356. HEXADECIMAL 
  357.  
  358. If you do not specifically indicate that a number is in either hex or decimal 
  359. then by default the number is assumed to be hexadecimal. To indicate a number 
  360. is in base 10 preceed the number with '$', for hexadecimal use 'x'. 
  361.  
  362. This commands purpose is to change the back to hexadecimal in situations where 
  363. you have probably changed the default number base. For example you could have 
  364. previously used the "DECIMAL" command to make base 10 the default number base. 
  365.  
  366.  
  367. ΓòÉΓòÉΓòÉ 3.10. LOCATE[!] ΓòÉΓòÉΓòÉ
  368.  
  369. LOCATE[!] 
  370.  
  371. These commands will find the first character that is in or not in a list of 
  372. characters you supply.  You could use this to verify that a file contains no 
  373. null bytes ('00x') etc. 
  374.  
  375. Syntax 
  376.  
  377.    [whitespace]LOCATE[!] [whitespace]RexStringExpression[whitespace]
  378.  
  379. If the command used is "LOCATE" then the search will be for the first character 
  380. that is also in the list you supply. If LOCATE! is used then it will try to 
  381. find a character that is not in the list. 
  382.  
  383. The "RexStringExpression" is a rexx expression which will be executed.  The 
  384. result is a sequence of characters. 
  385.  
  386. EXAMPLES 
  387.  
  388. See if there are any null bytes in the file: 
  389.  
  390.    LOCATE  '00'x
  391.  
  392. Find the first non numeric byte: 
  393.  
  394.    LOCATE!  xrange('0', '9')
  395.  
  396.  
  397. ΓòÉΓòÉΓòÉ 3.11. MOVETO ΓòÉΓòÉΓòÉ
  398.  
  399. MOVETO 
  400.  
  401. This command is used to move the current read, write or dump location to a new 
  402. position within the file. 
  403.  
  404. Note that all seeks will fail unless the file contains at least one byte (rexx 
  405. feature).  If you try to move outside of the valid range the command will fail. 
  406.  
  407. Syntax 
  408.  
  409.    [whitespace]MOVETO [whitespace]START|END[whitespace]    OR
  410.    [whitespace]MOVETO [whitespace]+|-  Offset[whitespace]  OR
  411.    [whitespace]MOVETO [whitespace]Offset[whitespace]
  412.  
  413. The "Offset" parameter is a decimal or hex value which specifies how much to 
  414. move or where to move to. to be opened. 
  415.  
  416. EXAMPLES 
  417.  
  418.    MoveTo  Start
  419.    MoveTo  End
  420.    MOVETO  + x1                            ;;Move forwards  1 byte  (number supplied as hex)
  421.    MOVETO  - $2                            ;;Move backwards 2 bytes (number supplied as decimal)
  422.    HEXADECIMAL                             ;;Ensure default is hex
  423.    MoveTo  B                               ;;Move to offset B hex (0 = 1st byte)
  424.  
  425.  
  426. ΓòÉΓòÉΓòÉ 3.12. ONERROR ΓòÉΓòÉΓòÉ
  427.  
  428. ONERROR 
  429.  
  430. This command can be used to specify a label where processing will be 
  431. transferred if the next command fails. 
  432.  
  433. Syntax 
  434.  
  435.    [whitespace]ONERROR [whitespace]Label[whitespace]
  436.  
  437. The "Label" is the name of a label that should be defined somewhere in the 
  438. source script (either before or after the current location). 
  439.  
  440. EXAMPLES 
  441.  
  442.    ;--- Patch all Nulls -------------------------
  443.    rexx   NullCounter = 0
  444.    :PatchLoop
  445.        ;--- Look for null bytes -----------------
  446.        OnError NoMoreNulls
  447.        FIND  "00"x
  448.  
  449.        ;--- Overwrite null byte -----------------
  450.        WRITE 'FF';
  451.        rexx   NullCounter = NullCounter + 1
  452.    goto PatchLoop
  453.    :NoMoreNulls
  454.    rexx   say AddCommasToDecimalNumber(NullCounter) || ' null byte(s) converted.'
  455.  
  456.  
  457. ΓòÉΓòÉΓòÉ 3.13. OPEN ΓòÉΓòÉΓòÉ
  458.  
  459. OPEN 
  460.  
  461. This command is used to open a file for read and write.  If you wish to start 
  462. with a clean file then use "OPENNEW" instead.  If you don't intend to update 
  463. the file then you should use "OPENREAD". 
  464.  
  465. Syntax 
  466.  
  467.    [whitespace]OPEN [whitespace]["]FileName["][whitespace]
  468.  
  469. The "FileName" parameter is the name of the file to be opened. 
  470.  
  471. EXAMPLES 
  472.  
  473.    OPEN  "MEMORY.BIN"
  474.    DUMP
  475.    CLOSE
  476.  
  477.  
  478. ΓòÉΓòÉΓòÉ 3.14. OPENNEW ΓòÉΓòÉΓòÉ
  479.  
  480. OPENNEW 
  481.  
  482. This command is the same as "OPEN" except that any existing file is first 
  483. deleted so that you are starting with a "clean" file. 
  484.  
  485.  
  486. ΓòÉΓòÉΓòÉ 3.15. OPENREAD ΓòÉΓòÉΓòÉ
  487.  
  488. OPENREAD 
  489.  
  490. This command is the same as "OPEN" except that the file must exists and is 
  491. opened for read only.  You will not be able to perform any commands that modify 
  492. the file (such as "WRITE"). 
  493.  
  494.  
  495. ΓòÉΓòÉΓòÉ 3.16. QUIT ΓòÉΓòÉΓòÉ
  496.  
  497. QUIT 
  498.  
  499. An alias for "EXIT". 
  500.  
  501.  
  502. ΓòÉΓòÉΓòÉ 3.17. REBUILD ΓòÉΓòÉΓòÉ
  503.  
  504. REBUILD 
  505.  
  506. This command allows you to open any binary file and create a script which could 
  507. be used to recreate it from scratch. 
  508.  
  509. One possible use of this command is to binary edit the file with a text editor. 
  510. Might be slower but its certainly easier.  Once in text form you can use 
  511. commands such as PVCS to track source changes. Difference programs can also be 
  512. used. 
  513.  
  514. As the command only rebuilds the file from the current location onwards to 
  515. capture the whole file ensure that you are at the start of the file (Use 
  516. "MOVETO" if required). 
  517.  
  518. Syntax 
  519.  
  520.    [whitespace]REBUILD [whitespace]["]NewScriptFile["][whitespace]
  521.  
  522. The "NewScriptFile" parameter if supplied is the name of a file to which 
  523. information is to be written. 
  524.  
  525. EXAMPLES 
  526.  
  527.    OPENREAD "XCOPY.EXE"
  528.    REBUILD  "XCOPY.BIN"
  529.    CLOSE
  530.  
  531.  
  532. ΓòÉΓòÉΓòÉ 3.18. RECORD ΓòÉΓòÉΓòÉ
  533.  
  534. RECORD 
  535.  
  536. This command can only be used in interactive mode and is used to record the 
  537. commands you enter, on the theory that you will want to use these later to 
  538. polish up an automated script. 
  539.  
  540. It allows you to experiment to produce the correct result, then with minor 
  541. editing of the produced file (to remove your mistakes) you have a script which 
  542. is very likely to work. 
  543.  
  544. Syntax 
  545.  
  546.    [whitespace]RECORD [whitespace][["]RecordFileName["]][whitespace]
  547.  
  548. The "RecordFileName" parameter if supplied is the name of a file to which 
  549. information is to be written.  If no filename is supplied then recording is 
  550. turned off. 
  551.  
  552. EXAMPLES 
  553.  
  554.    RECORD  "MEMORY.BIN"
  555.    RECORD
  556.  
  557.  
  558. ΓòÉΓòÉΓòÉ 3.19. REXX ΓòÉΓòÉΓòÉ
  559.  
  560. REXX 
  561.  
  562. This command will let you execute any rexx statement.  This is a specialised 
  563. command which you may never have need for. 
  564.  
  565. Syntax 
  566.  
  567.    [whitespace]REXX [whitespace]RexxCommand[whitespace]
  568.  
  569. The "RexxCommand" parameter is any valid rexx command (or commands).  Any 
  570. variables you set will remain until the end of the program or modified. 
  571.  
  572. EXAMPLES 
  573.  
  574.    ;--- Calculator ----------------------------------------------------------------
  575.    rexx   say 40 * 3 + 11
  576.  
  577.    ;--- Output a status message ---------------------------------------------------
  578.    REXX   say 'About to patch the file'
  579.  
  580.    ;--- Perform a simple validation that the "PATH" environment variable exists ---
  581.    rexx   if GetEnv("PATH") = '' then do; call CommandFailure '"PATH" Envvar missing!'; end
  582.  
  583.    ;--- Make sure exactly 256 bytes are written to the file -----------------------
  584.    rexx   StartTable = CurrentOffset();
  585.    WRITE   copies('.', 256);
  586.    rexx   NumberOfBytes = CurrentOffset() - StartTable;
  587.    rexx   if NumberOfBytes <> 256 then do; call CommandFailure 'Wrote ' || NumberOfBytes || ' bytes, expected exactly 256!'; end
  588.  
  589.  
  590. ΓòÉΓòÉΓòÉ 3.20. SYSTEM ΓòÉΓòÉΓòÉ
  591.  
  592. SYSTEM 
  593.  
  594. This command allows you to execute system commands.  The system command does 
  595. not fail if a non-zero return code is returned by the command processor however 
  596. the rexx variable "SystemRc" is set and can be verified with the "REXX" command 
  597. if required. 
  598.  
  599. Syntax 
  600.  
  601.    [whitespace]REXX [whitespace][SystemCommand][whitespace]
  602.  
  603. The "SystemCommand" parameter (if supplied) is anything you could type from an 
  604. operating system command prompt.  If not supplied a command prompt is started 
  605. (use "EXIT" to leave this command prompt). 
  606.  
  607. EXAMPLES 
  608.  
  609.    SYSTEM
  610.    SYSTEM  dir *.exe
  611.  
  612.  
  613. ΓòÉΓòÉΓòÉ 3.21. VERIFY ΓòÉΓòÉΓòÉ
  614.  
  615. VERIFY 
  616.  
  617. This command will VERIFY a number of bytes in the file at the current position. 
  618. The current position is not modified so a subsequent WRITE will overwrite the 
  619. verified bytes. 
  620.  
  621. You may wish a more global file level check, if so have a look at the 
  622. "VERIFYFILE" command. 
  623.  
  624. Syntax 
  625.  
  626.    [whitespace]VERIFY [whitespace]RexStringExpression[whitespace]
  627.  
  628. The "RexStringExpression" is a rexx expression which will be executed.  The 
  629. result should be a string which is to be verified. 
  630.  
  631. EXAMPLES 
  632.  
  633.    MOVETO + x1                            ;;Move forwards 1 decimal
  634.    VERIFY '[K' || '0B00'x                 ;;Verify 4 of the bytes
  635.    WRITE  '0000 0000'x                    ;;Overwrite the 4 verified bytes
  636.  
  637.  
  638. ΓòÉΓòÉΓòÉ 3.22. VERIFYFILE ΓòÉΓòÉΓòÉ
  639.  
  640. VERIFYFILE 
  641.  
  642. This command will verify a files: 
  643.  
  644.        1. Existance 
  645.        2. Length 
  646.        3. CRC32 
  647.  
  648.  If you can't verify the files contents at this level the "VERIFY" command may 
  649.  be more suitable for your needs. 
  650.  
  651.  Syntax 
  652.  
  653.      [whitespace]VERIFYFILE [whitespace]"FileName" [whitespace][FileLength [whitespace][FileCrc32]][whitespace]
  654.  
  655.  The "FileName" parameter specifies the name of a file.  Its expected to exist. 
  656.  This is the only required parameter. 
  657.  
  658.  The "FileLength" parameter specifies the length of the file.  As well as 
  659.  existing it is expected to have this file size.  The length is supplied in 
  660.  decimal. 
  661.  
  662.  The "FileCrc32" parameter specifies the CRC32 of the file.  As well as 
  663.  existing and having the correct length it is expected to have the correct CRC. 
  664.  A CRC is unlikely to be the same if a files contents are not as expected.  The 
  665.  CRC used by this program is the same as that used by PKZIP.  Note that the CRC 
  666.  routine is written in pure rexx and is not that fast so you may not wish to 
  667.  check the CRC or a really large file. The CRC is supplied in exactly 8 
  668.  hexadecimal characters. 
  669.  
  670.  EXAMPLES 
  671.  
  672.  The following demonstrates the 3 different file level verifications that can 
  673.  be performed: 
  674.  
  675.      VerifyFile "L4029.PIC"                 ;;Ensure File exists
  676.      VerifyFile "L4029.PIC" 15              ;;Ensure File exists + correct length (15 decimal)
  677.      VerifyFile "L4029.PIC" 15  B8BD46E4    ;;Ensure File exists + correct length (15 decimal) + CRC32 is correct
  678.  
  679.  
  680. ΓòÉΓòÉΓòÉ 3.23. WRITE ΓòÉΓòÉΓòÉ
  681.  
  682. WRITE 
  683.  
  684. This command will WRITE a number of bytes to the output file to the current 
  685. location.  A subsequent write's characters will be written immediately after 
  686. the previous ones. 
  687.  
  688. Syntax 
  689.  
  690.    [whitespace]WRITE [whitespace]RexStringExpression[whitespace]
  691.  
  692. The "RexStringExpression" is a rexx expression which will be executed.  The 
  693. result should be a string which is to be written to the file. 
  694.  
  695. EXAMPLES 
  696.  
  697.    WRITE  '1B'x || '[K' || '0B00 FF31 02 A0 04 00 00 0000 90'x
  698.    WRITE  copies('*', 10)
  699.    WRITE  '0D0A'x                         ;;Output CR + LF
  700.    WRITE  binary('0100 0001');            ;;Ascii 'A'
  701.  
  702.  
  703. ΓòÉΓòÉΓòÉ 3.24. ? ΓòÉΓòÉΓòÉ
  704.  
  705.  
  706. This command will display the online manual. 
  707.  
  708. Syntax 
  709.  
  710.    [whitespace]? [whitespace][HelpOnWhat][whitespace]
  711.  
  712. The "HelpOnWhat" parameter is optional.  If not specified then the maunal is 
  713. opened at the table of contents, otherwise the manual will be opened at the 
  714. first heading that matches what you typed. 
  715.  
  716. EXAMPLES 
  717.  
  718.    ?
  719.    ?  dump
  720.    ?  write
  721.  
  722.  
  723. ΓòÉΓòÉΓòÉ 4. Procedures ΓòÉΓòÉΓòÉ
  724.  
  725. Procedures 
  726.  
  727. The following Procedures are available to you whenever you execute a rexx 
  728. expression (for example in REXX & WRITE commands).: 
  729.  
  730.          AddCommasToDecimalNumber 
  731.          Binary 
  732.          B2C 
  733.          CommandFailure 
  734.          CurrentOffset 
  735.          EOL 
  736.          GetEnv 
  737.          GotoLabel 
  738.          ReplaceString 
  739.  
  740.  
  741. ΓòÉΓòÉΓòÉ 4.1. AddCommasToDecimalNumber() ΓòÉΓòÉΓòÉ
  742.  
  743. AddCommasToDecimalNumber() 
  744.  
  745. This function takes a single parameter (a decimal integer) and returns the 
  746. number with commas as required. 
  747.  
  748.  
  749. ΓòÉΓòÉΓòÉ 4.2. Binary() ΓòÉΓòÉΓòÉ
  750.  
  751. Binary() 
  752.  
  753. This routine takes a single parameter (a binary string) and returns a string of 
  754. characters that represent the passed string.  Note that "B2C()" is an alias for 
  755. this command. 
  756.  
  757. Sometimes a value is more meaningful in binary.  If using a PPWIZARD front end 
  758. it would also provide the option of programatically building different bit 
  759. strings based on conditions. 
  760.  
  761. EXAMPLES 
  762.  
  763.    WRITE  binary('0100 0001')              ;;Ascii 'A'
  764.    WRITE  binary('0100 0010   0100 0011')  ;;Ascii 'BC'
  765.    WRITE  binary('01000100 01000101')      ;;Ascii 'DE'
  766.    WRITE  binary('0000 0000')              ;;x00
  767.  
  768.  
  769. ΓòÉΓòÉΓòÉ 4.3. CommandFailure() ΓòÉΓòÉΓòÉ
  770.  
  771. CommandFailure() 
  772.  
  773. This routine requires a single parameter (a string to display). The error 
  774. message will be displayed and then clean up processing will take place and the 
  775. program exited with a non-zero return code. 
  776.  
  777. Its major use if in validations such as that shown in the example below. 
  778.  
  779. Do not call exit() directly. 
  780.  
  781. EXAMPLES 
  782.  
  783. ;--- Perform a simple validation that the "PATH" environment variable exists -
  784. rexx  if GetEnv("PATH") = '' then do; call CommandFailure '"PATH" Envvar missing!'; end
  785.  
  786.  
  787. ΓòÉΓòÉΓòÉ 4.4. CurrentOffset() ΓòÉΓòÉΓòÉ
  788.  
  789. CurrentOffset() 
  790.  
  791. This routine takes no parameters and returns the current offset in the file 
  792. ('!' is returned on error).  You must of course only try calling this routine 
  793. when a file is open! 
  794.  
  795. EXAMPLES 
  796.  
  797.    ;--- Make sure exactly 256 bytes are written to the file -----------------------
  798.    rexx   StartTable = CurrentOffset();
  799.    WRITE   copies('.', 256);
  800.    rexx   NumberOfBytes = CurrentOffset() - StartTable;
  801.    rexx   if NumberOfBytes <> 256 then do; call CommandFailure 'Wrote ' || NumberOfBytes || ' bytes, expected exactly 256!'; end
  802.  
  803.  
  804. ΓòÉΓòÉΓòÉ 4.5. EOL() ΓòÉΓòÉΓòÉ
  805.  
  806. EOL() 
  807.  
  808. This routine takes no parameters and returns the character or characters 
  809. required to terminate a text line.  On PC systems it would return a Carriage 
  810. Return followed by a Line Feed.  On Unix systems only a Line Feed would be 
  811. returned. 
  812.  
  813. This routine should be called rather than hardcoding the CR + LF etc to make 
  814. your script platform independant. 
  815.  
  816. EXAMPLES 
  817.  
  818.    WRITE  '0D0A'x                         ;;Output CR + LF (Hardcoded - not recommended)
  819.    WRITE  EOL()                           ;;Same as '0D0A'x on PC systems
  820.  
  821.  
  822. ΓòÉΓòÉΓòÉ 4.6. GetEnv() ΓòÉΓòÉΓòÉ
  823.  
  824. GetEnv() 
  825.  
  826. This routine takes a single parameter (the name of an environment variable) and 
  827. returns its contents. 
  828.  
  829. EXAMPLES 
  830.  
  831.    ;--- Make sure "PATH" exists -------------------------------------
  832.    rexx  if GetEnv("PATH") = '' then do; call CommandFailure '"PATH" Envvar missing!'; end
  833.  
  834.    ;--- Write the contents of the "path" to the file ----------------
  835.    WRITE  GetEnv("PATH");
  836.  
  837.  
  838. ΓòÉΓòÉΓòÉ 4.7. GotoLabel() ΓòÉΓòÉΓòÉ
  839.  
  840. GotoLabel() 
  841.  
  842. This routine takes a single parameter (the name of a label).  The next command 
  843. to be executed will be from the line following the label in the script file. 
  844.  
  845. The command would be useful in "REXX" commands to make inteligent decisions. 
  846.  
  847.  
  848. ΓòÉΓòÉΓòÉ 4.8. ReplaceString() ΓòÉΓòÉΓòÉ
  849.  
  850. ReplaceString() 
  851.  
  852. This function will convert all occurances of a substring as you specify. 
  853.  
  854. The function takes 4 parameters although only the first 3 are required, the 
  855. parameters are: 
  856.  
  857.        1. The string which is to be translated. 
  858.  
  859.        2. The FROM string. 
  860.  
  861.        3. The TO string. 
  862.  
  863.  
  864. ΓòÉΓòÉΓòÉ 5. Rexx Variable Substitution ΓòÉΓòÉΓòÉ
  865.  
  866. The rexx command allows you to create rexx variables, possibly by getting a 
  867. value from an environment variable, it is possible to have these substituted 
  868. into a command line. 
  869.  
  870. To have one or more rexx variables substituted into a line simply preceed each 
  871. rexx variable name by "<@" and add ">" after the variable name. 
  872.  
  873. EXAMPLE OF DUMP OUTPUT 
  874.  
  875.    ;--- Open file (name specified by batch file) ----
  876.    rexx WantedCmd = "OpenNew " || GetEnv('FILENAME')
  877.    <@WantedCmd>
  878.  
  879.  
  880. ΓòÉΓòÉΓòÉ 6. Example Scripts ΓòÉΓòÉΓòÉ
  881.  
  882. Example Scripts 
  883.  
  884.          EBCDIC.BIN 
  885.          EXAMPLE.BIN 
  886.          PATCHALL.BIN 
  887.          PPWIZARD.BIN 
  888.  
  889.  
  890. ΓòÉΓòÉΓòÉ 6.1. EBCDIC.BIN ΓòÉΓòÉΓòÉ
  891.  
  892. EBCDIC.BIN 
  893.  
  894. This script creates "EBCDIC.TBL" which can then be loaded via a "DUMPCHAR" 
  895. command so that subsequent "DUMP" commands display the characters in EBCDIC. 
  896.  
  897. ;----------------------------------------------------------------------------
  898. ;------------------------------[ EBCDIC.BIN ]--------------------------------
  899. ;----------------------------------------------------------------------------
  900. ;
  901. ; Used to create "EBCDIC.TBL" which can then be loaded via the "DUMPCHAR"
  902. ; command to control the characters displayed by the "DUMP" command.
  903. ;
  904. ;----------------------------------------------------------------------------
  905.  
  906.  
  907. ;*** $Header:   E:/DB/PVCS.IT/OS2/BINTOOL/EBCDIC.BIV   1.2   11 Jun 1998 18:48:10   Dennis_Bareis  $
  908.  
  909.  
  910. ;--- Open a NEW file --------------------------------------------------------
  911. OpenNew  "EBCDIC.TBL"
  912.  
  913. ;--- Output header ----------------------------------------------------------
  914. write    'DUMPCHAR'
  915. write    '|'
  916. write    'To EBCDIC'
  917. write    '|'
  918.  
  919. ;--- Remember Current Offset ------------------------------------------------
  920. rexx   StartTable = CurrentOffset();
  921.  
  922. ;--- Output 256 char translation set ----------------------------------------
  923. WRITE   '................................'
  924. WRITE   '................................'
  925. WRITE   ' '
  926. WRITE   '...........'
  927. WRITE   '<(+.&'
  928. WRITE   '.........'
  929. WRITE   '!$*);.-/'
  930. WRITE   '........'
  931. WRITE   '|,%_>?'
  932. WRITE   '..........'
  933. WRITE   ":#@'"
  934. WRITE   '="'
  935. WRITE   '.'
  936. WRITE   'abcdefghi'
  937. WRITE   '.{..+..'
  938. WRITE   'jklmnopqr'
  939. WRITE   '.}.....~'
  940. WRITE   'stuvwxyz'
  941. WRITE   '...'
  942. WRITE   '['
  943. WRITE   '...............'
  944. WRITE   ']'
  945. WRITE   '...'
  946. WRITE   'ABCDEFGHI'
  947. WRITE   '.......'
  948. WRITE   'JKLMNOPQR'
  949. WRITE   '......\.'
  950. WRITE   'STUVWXYZ'
  951. WRITE   '......'
  952. WRITE   '0123456789'
  953. WRITE   '......'
  954.  
  955. ;--- Verify that exactly 256 bytes were written -----------------------------
  956. rexx   NumberOfBytes = CurrentOffset() - StartTable;
  957. rexx   if NumberOfBytes <> 256 then do; call CommandFailure 'EBCDIC character table has ' || NumberOfBytes || ' bytes, expected exactly 256!'; end
  958.  
  959. ;--- Close the file ---------------------------------------------------------
  960. close
  961.  
  962.  
  963. ΓòÉΓòÉΓòÉ 6.2. EXAMPLE.BIN ΓòÉΓòÉΓòÉ
  964.  
  965. EXAMPLE.BIN 
  966.  
  967. This is a simple example with no real purpose. 
  968.  
  969. ;----------------------------------------------------------------------------
  970. ;------------------------------[ EXAMPLE.BIN ]-------------------------------
  971. ;----------------------------------------------------------------------------
  972. ;
  973. ;  This is an example file which shows most of the commands available.
  974. ;  It is not a realistic example but it does function.
  975. ;
  976. ;  Also have a look at my PPWIZARD tool.  If this was run as a step prior
  977. ;  to this one then you could have much more powerful commands such as
  978. ;  #if, #evaluate, #define.  You could define macros with parameters and
  979. ;  conditional inclusion.  These features were left out of this tool on the
  980. ;  assumption that you'd use PPWIZARD. In a line below the contents of the
  981. ;  "PATH" evironment variable is written, no validation of its existance
  982. ;  is or can be performed without using PPWIZARD.
  983. ;
  984. ;
  985. ;  This tool:
  986. ;
  987. ;         (a) Easily verify file contents then perform patches.
  988. ;         (b) Run difference & source management programs over the source.
  989. ;         (c) Comment changes.
  990. ;         (d) Allows you to binary edit files with a text editor!
  991. ;
  992. ;
  993. ;  To Execute this file:
  994. ;
  995. ;         BINTOOL.CMD EXAMPLE.BIN
  996. ;
  997. ;
  998. ;  To try command interactively (Type "QUIT" to exit):
  999. ;
  1000. ;         BINTOOL.CMD ?
  1001. ;
  1002. ;----------------------------------------------------------------------------
  1003.  
  1004. ;*** $Header:   E:/DB/PVCS.IT/OS2/BINTOOL/EXAMPLE.BIV   1.8   11 Jun 1998 18:48:10   Dennis_Bareis  $
  1005.  
  1006.  
  1007. ;--- Open a NEW file --------------------------------------------------------
  1008. OPENNEW  L4029.PIC
  1009.  
  1010. ;--- Write out the Lexmark 4029 Initialization Codes ------------------------
  1011. WRITE   '1B'x || '[K' || '0B00 FF31 02 A0 04 00 00 0000 90'x
  1012.  
  1013. ;--- Close the file ---------------------------------------------------------
  1014. CLOSE
  1015.  
  1016.  
  1017. ;--- Open a binary file -----------------------------------------------------
  1018. OPENREAD  'L4029.PIC'
  1019.  
  1020. ;--- DUMP "BINTOOL" Commands required to rebuild this file ------------------
  1021. REBUILD   L4029.TXT
  1022.  
  1023. ;--- Close the file ---------------------------------------------------------
  1024. CLOSE
  1025.  
  1026.  
  1027. ;--- Perform some "FILE LEVEL" verifications before patching ----------------
  1028. VerifyFile "L4029.PIC"                 ;;Ensure File exists
  1029. VerifyFile "L4029.PIC" 15              ;;Ensure File exists + correct length (15 decimal)
  1030. VerifyFile "L4029.PIC" 15  B8BD46E4    ;;Ensure File exists + correct length (15 decimal) + CRC32 is correct
  1031.  
  1032.  
  1033. ;--- Perform a simple validation that the "PATH" environment variable exists -
  1034. rexx  if GetEnv("PATH") = '' then do; call CommandFailure 'ERROR: "PATH" Envvar missing!'; end
  1035.  
  1036. ;--- Open  file (don't delete it!) ------------------------------------------
  1037. OPEN  "L4029.PIC"
  1038.  
  1039. ;--- Move around a bit ------------------------------------------------------
  1040. ;DUMPCHAR EBCDIC                       ;;Dump character information in EBCDIC (used EBCDIC.TBL)
  1041. DUMP                                   ;;Dump first part of file
  1042. MOVETO START
  1043. MOVETO + x1                            ;;Move forwards 1 decimal
  1044. VERIFY '[K' || '0B00'x                 ;;Verify 4 of the bytes
  1045. MOVETO + xA                            ;;Move backwards 1 decimal
  1046. MOVETO - $2                            ;;Move backwards 2 decimal
  1047. MOVETO + 5                             ;;Move forwards 5 HEX
  1048. DECIMAL                                ;;Default now decimal
  1049. MOVETO - 1
  1050. MOVETO - $1
  1051. HEXADECIMAL                            ;;Default now hex (again)
  1052. MoveTo B                               ;;Move to offset B hex (0 = 1st byte)
  1053. MOVETO END
  1054.  
  1055.  
  1056. ;--- Jump forwards a bit (small!) -------------------------------------------
  1057. goto NextLine
  1058. :NextLine
  1059.  
  1060. ;--- Write some stuff to end ------------------------------------------------
  1061. WRITE  '0D0A'x                         ;;Output CR + LF
  1062. WRITE  copies('~', 70)
  1063. WRITE  EOL()                           ;;Same as '0D0A'x on PC systems
  1064. WRITE  GetEnv("PATH");
  1065. WRITE  EOL()
  1066. WRITE  binary('0100 0001')              ;;Ascii 'A'
  1067. WRITE  binary('0100 0010   0100 0011')  ;;Ascii 'BC'
  1068. WRITE  binary('01000100 01000101')      ;;Ascii 'DE'
  1069.  
  1070. ;--- Write the current offset to the file -----------------------------------
  1071. write  CurrentOffset();
  1072.  
  1073. ;--- Close the file ---------------------------------------------------------
  1074. CLOSE
  1075.  
  1076.  
  1077. ;--- Handy Commands in INTERACTIVE Command ----------------------------------
  1078. ;QUIT                                  ;;Exit Interactive mode
  1079. ;SYSTEM dir                            ;;Run the DIR command
  1080. ;SYSTEM                                ;;Go to OS/2 command prompt
  1081. ;RECORD  "1.LOG"                       ;;Remember commands and logs some results as comments
  1082. ;RECORD                                ;;Turn off recording.
  1083.  
  1084.  
  1085. ΓòÉΓòÉΓòÉ 6.3. PATCHALL.BIN ΓòÉΓòÉΓòÉ
  1086.  
  1087. PATCHALL.BIN 
  1088.  
  1089. ;----------------------------------------------------------------------------
  1090. ;------------------------------[ EBCDIC.BIN ]--------------------------------
  1091. ;----------------------------------------------------------------------------
  1092. ;
  1093. ; Simplistic example where everythings hardcoded.  Main things demonstrated
  1094. ; are labels, the GOTO command and ONERROR command.
  1095. ;
  1096. ; Note that the only command handled by an error handler is the
  1097. ; FIND command.  If any other command (such as the WRITE command) fails the
  1098. ; program will fatally terminate.  If this was not desired an
  1099. ; ONERROR command would need to be placed at each line which might fail.
  1100. ;
  1101. ;----------------------------------------------------------------------------
  1102.  
  1103. ;*** $Header:   E:/DB/PVCS.IT/OS2/BINTOOL/PATCHALL.BIV   1.0   11 Jun 1998 18:48:10   Dennis_Bareis  $
  1104.  
  1105.  
  1106.  
  1107. ;--- Open the file to be patched --------------------------------------------
  1108. OPEN  "AFTER.EXE"
  1109.  
  1110. ;--- Patch all Nulls --------------------------------------------------------
  1111. rexx   NullCounter = 0
  1112. :PatchLoop
  1113.  
  1114.    ;--- Look for null bytes -------------------------------------------------
  1115.    OnError  NoMoreNulls
  1116.    FINDCS   "00"x
  1117.  
  1118.    ;--- Replace Null byte with "FF" hex -------------------------------------
  1119.    WRITE    'FF';
  1120.    rexx     NullCounter = NullCounter + 1
  1121. goto PatchLoop
  1122. :NoMoreNulls
  1123. rexx   say AddCommasToDecimalNumber(NullCounter) || ' null byte(s) converted.'
  1124.  
  1125. ;--- Close the file ---------------------------------------------------------
  1126. close
  1127.  
  1128.  
  1129. ΓòÉΓòÉΓòÉ 6.4. PPWIZARD.BIN ΓòÉΓòÉΓòÉ
  1130.  
  1131. PBINTOOL.CMD 
  1132.  
  1133. This batch file could be used to process "PPWIZARD.BIN": 
  1134.  
  1135. /**********************************/
  1136. /* BINTOOL.CMD with PPWIZARD STEP */
  1137. /**********************************/
  1138.  
  1139. /*--- Initialization --------------------------------------------------------*/
  1140. address cmd '@echo off'
  1141. DebugSwitches = '';
  1142. /*DebugSwitches = '/debug';*/
  1143.  
  1144. /*--- Check thate the user supplied a filename and that it exists -----------*/
  1145. UsersScriptFile = strip(arg(1));
  1146. if UsersScriptFile = '' then
  1147.    Abort("You did not supply the name of a script file!");
  1148. if stream(UsersScriptFile, 'c', 'query exists') = '' then
  1149.    Abort('The file "' || UsersScriptFile || '" does not exist!');
  1150.  
  1151. /*--- Get name of temp file (not best way but portable) ---------------------*/
  1152. TmpFile = GetEnv("TMP") || '\PBT' || right(time('S'), 5, '0') || ".TMP";
  1153.  
  1154. /*--- Run the PPWIZARD step -------------------------------------------------*/
  1155. address cmd 'cmd.exe /c PPWIZARD.CMD ' || UsersScriptFile || ' /crlf /output:' || TmpFile || ' ' || DebugSwitches;
  1156. if Rc <> 0 then
  1157.    Abort("PPWIZARD step failed (Rc = " || Rc || ')');
  1158.  
  1159. /*--- Run the BINTOOL step --------------------------------------------------*/
  1160. address cmd 'cmd.exe /c BINTOOL.CMD ' || TmpFile;
  1161. if Rc <> 0 then
  1162.    Abort("BINTOOL step failed (Rc = " || Rc || ')');
  1163.  
  1164. /*--- Command worked so delete the temporary file ---------------------------*/
  1165. address cmd 'del ' || TmpFile || ' >nul 2>&1';
  1166.  
  1167. /*--- Thats all Folks -------------------------------------------------------*/
  1168. exit(0);
  1169.  
  1170.  
  1171. /*===========================================================================*/
  1172. Abort:
  1173. /*===========================================================================*/
  1174.    CallersLine = SIGL;
  1175.    say arg(1) || '';
  1176.    exit(CallersLine);
  1177.  
  1178.  
  1179. /*===========================================================================*/
  1180. GetEnv:
  1181. /*                                                                           */
  1182. /* arg(1) : Name of environment variable.                                    */
  1183. /*===========================================================================*/
  1184.    return( value(arg(1),,'OS2ENVIRONMENT') );
  1185.  
  1186. PPWIZARD.BIN 
  1187.  
  1188. ;----------------------------------------------------------------------------
  1189. ;------------------------------[ PPWIZARD.BIN ]------------------------------
  1190. ;----------------------------------------------------------------------------
  1191. ;
  1192. ; Simplistic example of using PPWIZARD.
  1193. ;
  1194. ; Note that it would be smarter to validate both addresses first and then
  1195. ; write the new value.  As it currently stands this example could fail
  1196. ; at the second validation after we've already patched the file.
  1197. ;
  1198. ; It would be smarter yet to be woring on a copy and only update the original
  1199. ; as the last step (maybe using "SYSTEM copy ......").
  1200. ;
  1201. ;----------------------------------------------------------------------------
  1202.  
  1203.  
  1204. ;*** $Header:   E:/DB/PVCS.IT/OS2/BINTOOL/PPWIZARD.BIV   1.0   11 Jun 1998 18:48:12   Dennis_Bareis  $
  1205.  
  1206. ;--- Set up some constants --------------------------------------------------
  1207. #define  FileToPatch       "XYZ.CMD"
  1208. #define  ExpectToFind      "97.123"
  1209. #define  FirstPosn         x1001
  1210. #define  SecondPosn        x3415
  1211.  
  1212. ;--- Create YY.DDD Version # (example "98.107") -----------------------------
  1213. #evaluate YYDDD    ~substr(date('Sorted'),3,2) || '.' || right(date('Days'), 3, '0')~
  1214.  
  1215.  
  1216.  
  1217. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1218. ;;;;;;;;;;;;;;;;;;;;;;;;;[ One Way ];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1219. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1220.  
  1221.  
  1222.  
  1223. ;--- Open the file and update the version numbers ---------------------------
  1224. Open   <$FileToPatch>
  1225. MoveTo <$FirstPosn>
  1226. verify <$ExpectToFind>
  1227. write  <$YYDDD>
  1228. MoveTo <$SecondPosn>
  1229. verify <$ExpectToFind>
  1230. write  <$YYDDD>
  1231. close
  1232.  
  1233.  
  1234.  
  1235. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1236. ;;;;;;;;;;;;;;;;;;;;;;;;;[ Another Way ];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1237. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1238.  
  1239.  
  1240. ;--- Create macro to perform a patch (takes OFFSET as parameter) ------------
  1241. #define PatchVer                                       \
  1242.         MoveTo  {$Offset}<?NewLine>                    \
  1243.         verify  <$ExpectToFind><?NewLine>              \
  1244.         write   <$YYDDD><?NewLine>
  1245.  
  1246. ;--- Repeat the above in a slightly better way ------------------------------
  1247. Open   <$FileToPatch>
  1248. <$PatchVer Offset='<$FirstPosn>'>
  1249. <$PatchVer Offset='<$SecondPosn>'>
  1250. close
  1251.