1 | /*
|
---|
2 | *************************************************************************************
|
---|
3 | *
|
---|
4 | * DocBook Framework for OS/2 and eComStation
|
---|
5 | * Sends Formatting Objects to printer
|
---|
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 sends a FO file to the printer.
|
---|
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/FO2Printer.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 | CALL FOP "-fo " || InputFile || " -print"
|
---|
38 | END
|
---|
39 | ELSE DO
|
---|
40 | CALL PrintUsage
|
---|
41 | END
|
---|
42 |
|
---|
43 | CALL EndLocal
|
---|
44 | EXIT
|
---|
45 |
|
---|
46 |
|
---|
47 | /***********************************************************************************************/
|
---|
48 | /* Procedures and functions */
|
---|
49 | /***********************************************************************************************/
|
---|
50 |
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Sets an environment variable or appends a value to it.
|
---|
54 | */
|
---|
55 | AddEnvironment: PROCEDURE
|
---|
56 | PARSE ARG VarName, VarValue
|
---|
57 | IF (Value(VarName, , "OS2ENVIRONMENT")="")
|
---|
58 | THEN CALL SetEnvironment VarName, VarValue
|
---|
59 | ELSE CALL Value VarName, GetEnvironment(VarName) || ";" || VarValue, "OS2ENVIRONMENT"
|
---|
60 | RETURN
|
---|
61 |
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * Sets an environment variable, overwriting its previous value.
|
---|
65 | */
|
---|
66 | SetEnvironment: PROCEDURE
|
---|
67 | PARSE ARG VarName, VarValue
|
---|
68 | CALL Value VarName, VarValue, "OS2ENVIRONMENT"
|
---|
69 | RETURN
|
---|
70 |
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * Returns the value of an environment variable.
|
---|
74 | */
|
---|
75 | GetEnvironment: PROCEDURE
|
---|
76 | PARSE ARG VarName
|
---|
77 | RETURN Value(VarName, , "OS2ENVIRONMENT")
|
---|
78 |
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * Returns the current script name.
|
---|
82 | */
|
---|
83 | GetScriptName: PROCEDURE
|
---|
84 | PARSE SOURCE Result
|
---|
85 | RETURN WORD(Result, 3)
|
---|
86 |
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * Returns the current script path, without "\" at the end.
|
---|
90 | */
|
---|
91 | GetScriptPath: PROCEDURE
|
---|
92 | ScriptName = GetScriptName()
|
---|
93 | RETURN SUBSTR(ScriptName, 1, LASTPOS("\", ScriptName)-1)
|
---|
94 |
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * Returns True if the given file exists.
|
---|
98 | */
|
---|
99 | FileExists: PROCEDURE
|
---|
100 | PARSE ARG FileName
|
---|
101 | CALL SysFileTree FileName, Result
|
---|
102 | RETURN Result.0 > 0
|
---|
103 |
|
---|
104 |
|
---|
105 | /*
|
---|
106 | * Returns the current directory, without "\" at the end.
|
---|
107 | */
|
---|
108 | GetCurrentDir: PROCEDURE
|
---|
109 | RETURN DIRECTORY()
|
---|
110 |
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * Returns the parent directory of the directory passed as argument, without "\" at the end.
|
---|
114 | */
|
---|
115 | GetParentDirectory: PROCEDURE
|
---|
116 | PARSE ARG DirName
|
---|
117 | RETURN SUBSTR(DirName, 1, LASTPOS("\", DirName)-1)
|
---|
118 |
|
---|
119 |
|
---|
120 | /*
|
---|
121 | * Prints out a short help on how to call this script.
|
---|
122 | */
|
---|
123 | PrintUsage: PROCEDURE
|
---|
124 | SAY "DocBook Framework for OS/2, Prints Formatting Objects directly on a printer"
|
---|
125 | SAY "Usage: FO2Printer <Formatting Objects>"
|
---|
126 | RETURN
|
---|
127 |
|
---|