[2] | 1 | /*
|
---|
| 2 | *************************************************************************************
|
---|
| 3 | *
|
---|
| 4 | * DocBook Framework for OS/2 and eComStation
|
---|
| 5 | * Convert Formatting Objects to WordprocessingML using XFC
|
---|
| 6 | *
|
---|
| 7 | * More info on the web:
|
---|
| 8 | * http://www.kacer.biz/os2/docbook-framework/
|
---|
| 9 | *
|
---|
| 10 | * Author:
|
---|
| 11 | * Jarda Kacer <mailto:jarda@kacer.biz>
|
---|
| 12 | *
|
---|
| 13 | *************************************************************************************
|
---|
| 14 | *
|
---|
| 15 | * This script converts an FO file to an WML file using XFC.
|
---|
| 16 | *
|
---|
| 17 | *************************************************************************************
|
---|
| 18 | *
|
---|
| 19 | * $Author: jkacer $
|
---|
| 20 | * $Revision: 2 $
|
---|
| 21 | * $Date: 2007-09-05 20:07:46 +0000 (Wed, 05 Sep 2007) $
|
---|
| 22 | * $HeadURL: trunk/Distribution/Scripts/FO2WML-UsingXFC.CMD $
|
---|
| 23 | *
|
---|
| 24 | *************************************************************************************
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | OuterEnv = SetLocal()
|
---|
| 28 |
|
---|
| 29 | CALL RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
|
---|
| 30 | CALL SysLoadFuncs
|
---|
| 31 |
|
---|
| 32 | Arguments = ARG(1)
|
---|
| 33 |
|
---|
| 34 | IF WORDS(Arguments) = 1
|
---|
| 35 | THEN DO
|
---|
| 36 | InputFile = WORD(Arguments, 1)
|
---|
| 37 | OutputFile = SUBSTR(InputFile, 1, LASTPOS(".", InputFile)-1) || ".WML"
|
---|
| 38 | CALL XFC "-outputFormat=WML " || InputFile || " " || OutputFile
|
---|
| 39 | END
|
---|
| 40 | ELSE DO
|
---|
| 41 | CALL PrintUsage
|
---|
| 42 | END
|
---|
| 43 |
|
---|
| 44 | CALL EndLocal
|
---|
| 45 | EXIT
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | /***********************************************************************************************/
|
---|
| 49 | /* Procedures and functions */
|
---|
| 50 | /***********************************************************************************************/
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | /*
|
---|
| 54 | * Sets an environment variable or appends a value to it.
|
---|
| 55 | */
|
---|
| 56 | AddEnvironment: PROCEDURE
|
---|
| 57 | PARSE ARG VarName, VarValue
|
---|
| 58 | IF (Value(VarName, , "OS2ENVIRONMENT")="")
|
---|
| 59 | THEN CALL SetEnvironment VarName, VarValue
|
---|
| 60 | ELSE CALL Value VarName, GetEnvironment(VarName) || ";" || VarValue, "OS2ENVIRONMENT"
|
---|
| 61 | RETURN
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | /*
|
---|
| 65 | * Sets an environment variable, overwriting its previous value.
|
---|
| 66 | */
|
---|
| 67 | SetEnvironment: PROCEDURE
|
---|
| 68 | PARSE ARG VarName, VarValue
|
---|
| 69 | CALL Value VarName, VarValue, "OS2ENVIRONMENT"
|
---|
| 70 | RETURN
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * Returns the value of an environment variable.
|
---|
| 75 | */
|
---|
| 76 | GetEnvironment: PROCEDURE
|
---|
| 77 | PARSE ARG VarName
|
---|
| 78 | RETURN Value(VarName, , "OS2ENVIRONMENT")
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | /*
|
---|
| 82 | * Returns the current script name.
|
---|
| 83 | */
|
---|
| 84 | GetScriptName: PROCEDURE
|
---|
| 85 | PARSE SOURCE Result
|
---|
| 86 | RETURN WORD(Result, 3)
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | /*
|
---|
| 90 | * Returns the current script path, without "\" at the end.
|
---|
| 91 | */
|
---|
| 92 | GetScriptPath: PROCEDURE
|
---|
| 93 | ScriptName = GetScriptName()
|
---|
| 94 | RETURN SUBSTR(ScriptName, 1, LASTPOS("\", ScriptName)-1)
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | /*
|
---|
| 98 | * Returns True if the given file exists.
|
---|
| 99 | */
|
---|
| 100 | FileExists: PROCEDURE
|
---|
| 101 | PARSE ARG FileName
|
---|
| 102 | CALL SysFileTree FileName, Result
|
---|
| 103 | RETURN Result.0 > 0
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | /*
|
---|
| 107 | * Returns the current directory, without "\" at the end.
|
---|
| 108 | */
|
---|
| 109 | GetCurrentDir: PROCEDURE
|
---|
| 110 | RETURN DIRECTORY()
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | /*
|
---|
| 114 | * Returns the parent directory of the directory passed as argument, without "\" at the end.
|
---|
| 115 | */
|
---|
| 116 | GetParentDirectory: PROCEDURE
|
---|
| 117 | PARSE ARG DirName
|
---|
| 118 | RETURN SUBSTR(DirName, 1, LASTPOS("\", DirName)-1)
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | /*
|
---|
| 122 | * Prints out a short help on how to call this script.
|
---|
| 123 | */
|
---|
| 124 | PrintUsage: PROCEDURE
|
---|
| 125 | SAY "DocBook Framework for OS/2, Formatting Objects --> Wordprocessing Markup Language"
|
---|
| 126 | SAY "Usage: FO2WML <Formatting Objects>"
|
---|
| 127 | SAY ""
|
---|
| 128 | SAY "This script uses XFC for conversion."
|
---|
| 129 | SAY "XFC must be installed separately by the user due to its license."
|
---|
| 130 | RETURN
|
---|
| 131 |
|
---|