1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 pic: picture: proc;
81
82 testing = "0"b;
83 me = "picture";
84 goto start;
85
86 valid_pictured_data: vpd: entry;
87
88 testing = "1"b;
89 me = "valid_pictured_data";
90 goto start;
91
92 start:
93 strip_sw = "0"b;
94 call cu_$af_arg_count (argct, code);
95 if (code ^= 0)
96 then do;
97 retval_p = null ();
98 error = com_err_;
99 arg_ptr = cu_$arg_ptr;
100 end;
101 else do;
102 call cu_$af_return_arg (argct, retval_p, retval_l, code);
103
104 retval = "";
105 error = active_fnc_err_;
106 arg_ptr = cu_$af_arg_ptr;
107 end;
108 if (argct < 2)
109 then do;
110 if (me = "picture")
111 then call error (error_table_$noarg, me,
112 "Usage:^-pic pic_str {-strip} value ...");
113 else call error (error_table_$noarg, me,
114 "Usage:^-vpd pic_str value ...");
115 return;
116 end;
117 call arg_ptr (1, argp, argl, code);
118 if (argl = 0)
119 then do;
120 the_picture = default;
121 picp = addr (default);
122 picl = length (default);
123 strip_sw = "1"b;
124 dcl default char (13) int static options (constant)
125 init ("(15)-9v.(15)9");
126 end;
127 else do;
128 the_picture = arg;
129 picp = argp;
130 picl = argl;
131 end;
132
133 call picture_info_ ((picv), addr (buff), code);
134
135 if (code ^= 0)
136 then do;
137 call error (0, me,
138 "^[Normalized picture > 64 char" ||
139 "^;Scale factor not in range -128:+127" ||
140 "^;Syntax error^]. ^a",
141 sign (code - 434) + 2,
142 the_picture);
143 return;
144 end;
145 do argno = 2 to argct while (^strip_sw);
146 call arg_ptr (argno, argp, argl, code);
147 if (arg = "-strip")
148 then strip_sw = "1"b;
149 end;
150
151 on condition (conversion)
152 begin;
153 Cond = "Conversion";
154 goto err_exit;
155 end;
156 on condition (size)
157 begin;
158 Cond = "Size";
159 goto err_exit;
160 end;
161 do argno = 2 to argct;
162 call arg_ptr (argno, argp, argl, code);
163 if (arg ^= "-strip")
164 then do;
165
166
167 temp_length = addr (buff) -> picture_image.prec
168 + 262144 * (addr (buff) -> picture_image.scale
169 - addr (buff) -> picture_image.scalefactor);
170
171 call assign_ (addr (temp),
172 map_type (addr (buff) -> picture_image.type),
173 temp_length, argp, 42, (argl));
174 call pack_picture_ (addr (target) -> bit1, buff, temp);
175
176 if ^testing
177 then do;
178 pictured
179 = substr (target, 1, addr (buff) -> picture_image.varlength);
180 if strip_sw
181 then do;
182 pictured = ltrim (pictured);
183 if (index (pictured, ".") ^= 0)
184 then do;
185 pictured = rtrim (pictured, "0");
186 if (substr (pictured, length (pictured), 1) = ".")
187 then pictured
188 = substr (pictured, 1, length (pictured) - 1);
189 end;
190 end;
191 if (retval_p = null ())
192 then call ioa_ ("^a", pictured);
193 else do;
194 j = index (pictured, " ");
195 if (length (retval) > 0)
196 then retval = retval || " ";
197 if (j > 0)
198 then retval = retval || """";
199 retval = retval || pictured;
200 if (j > 0)
201 then retval = retval || """";
202 end;
203 end;
204 end;
205 end;
206 if testing
207 then do;
208 if (retval_p = null ())
209 then call ioa_ ("true");
210 else retval = "true";
211 end;
212
213 return;
214
215 err_exit:
216 if testing
217 then do;
218 if (retval_p = null ())
219 then call ioa_ ("false");
220 else retval = "false";
221 end;
222 else call error (0, me,
223 "^a condition occurred while editing ""^a"" thru ""^a""",
224 Cond, arg, the_picture);
225 return;
226
227 dcl active_fnc_err_ entry options (variable);
228 dcl arg char (argl) based (argp);
229 dcl argct fixed bin;
230 dcl argl fixed bin (21);
231 dcl argno fixed bin;
232 dcl argp ptr;
233 dcl assign_ entry (ptr, fixed bin, fixed bin (35), ptr, fixed bin,
234 fixed bin (35));
235 dcl bit1 bit (1) unaligned based;
236 dcl buff (20) fixed binary;
237 dcl code fixed bin (35);
238 dcl Cond char (12);
239 dcl com_err_ entry options (variable);
240 dcl conversion condition;
241 dcl cu_$af_arg_count entry (fixed bin, fixed bin (35));
242 dcl cu_$af_return_arg entry (fixed bin, ptr, fixed bin (21), fixed bin (35));
243 dcl arg_ptr entry (fixed bin, ptr, fixed bin (21), fixed bin (35))
244 automatic;
245 dcl cu_$arg_ptr entry (fixed bin, ptr, fixed bin (21), fixed bin (35));
246 dcl cu_$af_arg_ptr entry (fixed bin, ptr, fixed bin (21), fixed bin (35));
247 dcl error entry options (variable) automatic;
248 dcl error_table_$noarg fixed bin (35) ext static;
249 dcl ioa_ entry options (variable);
250 dcl j fixed bin;
251 dcl me char (32);
252 dcl pack_picture_ options (variable);
253 dcl picl fixed bin;
254 dcl picp ptr;
255 dcl picture_info_ entry (char (*) aligned, ptr, fixed bin (35));
256 dcl pictured char (256) var;
257 dcl picv char (picl) based (picp);
258 dcl retval char (retval_l) var based (retval_p);
259 dcl retval_l fixed bin (21);
260 dcl retval_p ptr;
261 dcl size condition;
262 dcl strip_sw bit (1);
263 dcl target char (128);
264 dcl temp (128) char (1) unaligned;
265 dcl temp_length fixed bin (35);
266 dcl testing bit (1);
267 dcl the_picture char (100) var;
268
269 dcl (addr, index, length, ltrim, null, rtrim, sign, substr) builtin;
270
271 %include picture_image;
272 dcl map_type (24:28) fixed bin int static init (
273 42,
274 18,
275 22,
276 20,
277 24);
278 end picture;