Using Command Lines
The Monarch Utility allows the use of command lines, specifically for the file preparation functions, which may be used on a recurring basis.
String replacement
Command: <source file> <target file> /cr <search string> <replace string>
/cr means "run string replacement".
<search string> - The string on which to perform the replacement. The string must be enclosed by quotes.
<replace string> - The string with which to replace the search string. The string must be enclosed by quotes. This argument is optional; if omitted, the search string will be deleted.
/chset - <character set> - The values of ansi or ascii indicate which character set to use for both the strings and the input file. This argument is optional; if not specified, /chset:ascii will be assumed.
Example: "c:\test\test.prn" "c:\test\test1.prn" /cr "./n/n" ".00" /chset:ansi
Note: It is possible to loop through an entire folder using batch scripting in the following way, with a batch file containing the following line executing the search and replace on every file with the extension .prn in the c:\test folder:
FOR %%f IN ("c:\test\*.prn") DO "c:\monarchu.exe" %%f %%f /cr "./n/n" ".00" /chset:ansi
Inserting line breaks into continuous stream files
Command: <source file> <target file> /nr <segmentlength>
/nr means "run insert line breaks".
<segmentlength> - The length of the new lines.
Example: "c:\test\test.prn" "c:\test\test1.prn" /nr 500
Insert line breaks into files with line lengths greater than 4000 characters
Command: <source file> <target file> /lr <linelengths>
/lr means "run long lines".
<linelengths> - Line lengths separated by spaces.
Example: "c:\test\test.prn" "c:\test\test1.prn" /lr 2000 2000 2000
EDI format preparation
Command: <source file> <target file> /edi <params>
/edi means "run edi transformation and auto detect parameters".
The following parameters can be explicitly specified:
segment delimiter - /segd:character (ex /segd:' )
element separator - /elem:character (ex /elem:: )
sub element separator - /sube:character (ex /sube:+ )
release character - /rele:character (ex /rele:? ) This argument is optional but all others must be in the list if not using the auto detect parameters syntax.
The target file argument is optional and the order of parameters is irrelevant. The characters can be wrapped in quotes if necessary, i.e., /sube:" "
Example: "c:\test\test.prn" "c:\test\test1.prn" /edi /segd:’ /elem:: /sube:+
When run in command line, Monarch Utility returns a zero if all was successful. If an error occurred, Monarch Utility returns a value of 1. When Monarch Utility is run in a batch file, the code can test for a return value of 1 and act accordingly.
Converting text/XML models or projects to the binary format
Single File
<source file> <target file> /cnv
Example: "c:\test\test.xmod" "c:\test\test.dmod" /cnv
Multiple Files
<source folder> -f:<filenames> -isf <target folder> -psf /cnv
Example: "c:\test\from" "-f:*.xmod;*.xprj;" -isf "c:\test\to" -psf /cnv
<filenames> - name of the file you want to utilize (i.e., the model or project file) or enter a wildcard and the appropriate extension (e.g., *.dmod).
-isf - include any files in all subfolders of the specified source folder (optional).
-psf - preserve folder structure of the <source folder> in <target folder> (optional).




