summaryrefslogtreecommitdiff
path: root/macros/text1/vax_vms/texix.ch
blob: 20168b7fe414c4201f9563b9499f42ae93c024c2 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
 
@x   line 6
    \centerline{{\twelvept For IBM VM/CMS Pascal/VS}}
@y
    \centerline{{\twelvept For Vax Pascal}}
@z
 
@x   line 107
segment texix;
procedure texix(ix:char); external;
procedure texix;
@y
[inherit('sortcall')]
program texix(input,output);
@z
 
@x   line 142
@d getout == return
@d messages == sysprint
@y
@d getout == goto return
@d messages == output
@z
 
@x   line 146
@d max_lrecl = 2048
@y
@d max_lrecl = 255
@z
 
@x   line 147
in_record := dosubstr(in_record,1 + #)
@y
in_record := dosubstr(in_record,1 + #,length(in_record)-(#))
@z

@x  line 176
@d do_when_bold == begin
if length(bold_string) > 0 then add_comma(bold_string);
bold_string:=
ccat(ccat(ccat(bold_string,'{\bd '),curr_str_page),'}');
@.\bs{}bd@>
end
 
@d do_when_underscore == begin
if length(us_string) > 0 then add_comma(us_string);
us_string:=
ccat(ccat(ccat(us_string,'\us{'),curr_str_page),'}');
@.\bs{}us@>
end
 
@d do_when_italic == begin
if length(rm_string) > 0 then add_comma(rm_string);
rm_string:=
ccat(ccat(ccat(rm_string,'{\it '),curr_str_page),'}');
@.\bs{}it@>
end
@y
@d do_when_bold == begin
if length(bold_string) > 0 then add_comma(bold_string);
bold_string:=ccat(bold_string,'{\bd ');
bold_string:=ccat(bold_string,curr_str_page);
bold_string:=ccat(bold_string,'}');
@.\bs{}us@>
end
 
@d do_when_underscore == begin
if length(us_string) > 0 then add_comma(us_string);
us_string:=ccat(us_string,'\us{');
us_string:=ccat(us_string,curr_str_page);
us_string:=ccat(us_string,'}');
@.\bs{}us@>
end
 
@d do_when_italic == begin
if length(rm_string) > 0 then add_comma(rm_string);
rm_string:=ccat(rm_string,'{\it ');
rm_string:=ccat(rm_string,curr_str_page);
rm_string:=ccat(rm_string,'}');
@.\bs{}it@>
end
@z
 
@x   line 253
  ccat := x ccat_temp y;
@y
  ccat := x + y;
@z
 
@x   line 271
@^System dependent code@>
@p procedure reset_file(file_number:char);
begin
if file_number = '9' then reset(sort_file,
'NAME=TEXT1$$.OUTSORT.A,LRECL=1857,RECFM=V')
else reset(ix_file,
ccat(ccat('NAME=TEXT1$$.IX',str(file_number)),'.A'));
end;
@y
@^System dependent code@>
@p procedure reset_file(file_number:char);
begin
if file_number = '9' then begin open(sort_file,
'TEXT1$$.OUTSORT',history:=readonly); reset(sort_file); end
else begin open(ix_file,ccat('TEXT1$$.IX',file_number),history:=readonly);
reset(ix_file); end;
end;
 
function trim(object:string_pass):string_pass;
var i:integer;
new_string:string_pass;
begin
i:=length(object)+1;
repeat
  decr(i);
  until (object[i] <> ' ') or (i=1);
if (object[i] = ' ') and (i=1)
then new_string:=''
else new_string:=dosubstr(object,1,i);
trim:=new_string;
end;
@z
 
@x   line 288
rewrite(sort_file,'NAME=TEXT1$$.INSORT.A,LRECL=1857,RECFM=V')
else
rewrite(ix_file,
ccat(ccat('NAME=TEXT1$$.IX',str(file_number)),
'.A,LRECL=2048,RECFM=V'));
@y
begin open(sort_file,'TEXT1$$.INSORT');
rewrite(sort_file); end
else
begin
open(ix_file,ccat('TEXT1$$.IX',file_number),
record@=_@>@t\_@>length:=1024);
rewrite(ix_file); end;
@z
 
@x   line 444
@ The {\it get\_numeric}
function will take a packed array of length max\_pn\_alpha and convert
that array (which is really the page number) into an integer.
 
@p function get_numeric(x_string:string_type(max_pn_alpha)):integer;
var @!i:integer;
begin
readstr(x_string,i);
get_numeric:=i;
end;
@y
@ The {\it get\_numeric}
function will take a packed array of length max\_pn\_alpha and convert
that array (which is really the page number) into an integer.
 
@p function get_numeric(x_string:string_pass):integer;
var @!i:integer;
begin
readv(x_string,i);
get_numeric:=i;
end;
@z
 
@x   line 459
@p procedure strvalue(x:integer; var results:pass_pn_alpha);
var
temp:string_type(max_pn_alpha);
begin
writestr(temp,x);
results:=ltrim(temp);
end;
@y
@p function ltrim(triml_in_string:string_pass):pn_type;
var i,j:integer;
triml_out_string:pn_type;
begin
j:=0;
for i:=1 to length(triml_in_string) do begin
if triml_in_string[i] <> ' ' then begin
	incr(j);
	triml_out_string[j]:=triml_in_string[i];
	end;
end;
ltrim:=triml_out_string;
end;
	

procedure strvalue(x:integer; var results:pn_type);
var
temp:string_type(max_pn_alpha);
begin
  writev(temp,x);
  results:=trim(ltrim(temp));
  end;
@z
 
@x   line 470
@p function strconv(x:pn_alpha_type):string_type(max_pn_alpha);
var i:integer;
temp:string_type(max_pn_alpha);
begin
temp:='';i := 1;
with sort_record do begin
repeat
if x[i] <> ' ' then
temp := ccat(temp,str(x[i]));
incr(i);
until (i > max_pn_alpha) or (x[i] = ' ');
end;
strconv:=temp;
end;
@y
@p function strconv(x:pn_alpha_type):pass_pn_alpha;
var i:integer;
temp:string_type(max_pn_alpha);
begin
temp:='';i := 1;
with sort_record do begin
repeat
if x[i] <> ' ' then
temp := ccat(temp,x[i]);
incr(i);
until (i > max_pn_alpha) or (x[i] = ' ');
end;
strconv:=temp;
end;
@z
 
@x   line 626
@ The {\it plsort} procedure is written in PL/1 to call the CMS sort program
Syncsort. This was necessary since you cannot call Syncsort from PASCAL/VS.
The fields to be sorted are defined internally in the {\it plsort}
program. This should be the same as the three sort fields in {\it sort\_type}.
@:sort_type@>
@:plsort@> @^PL/1@>
@^Syncsort@>
 
@p procedure plsort(var sort_rc:integer); fortran;
@y
@ The {\it vmssort} procedure calls a VMS sort program.
You can use your favorite program here.
The three sort fields in {\it sort\_type} are to be sorted.
@:sort_type@>
@:vmssort@>
 
@z
 
@x   line 643
@ This function converts to all uppercase.
Notice that this is an EBCIDIC conversion, not an ASCII conversion
to uppercase.
 
@p function upper_case(x:char):char;
var temp:char;
begin
  if (ord(x)>=129)and(ord(x)<=169) then
      temp:=chr(ord(x)+64)
  else temp:=x;
upper_case:=temp;
end;
@y
@ This function converts to all uppercase.
Notice that this is an ASCII   conversion, not an EBCDIC  conversion
to uppercase.
 
@p function upper_case(x:char):char;
var temp:char;
begin
  if ord(x) >= "a" then
      temp:=chr(ord(x)-@'40)
  else temp:=x;
upper_case:=temp;
end;
@z
 
 
@x   line 710
@!temp_strvalue:pass_pn_alpha;
@y
@!temp_strvalue:pn_type;
@z
 
@x   line 738
if dosubstr(in_record,doindex(in_record,'=')+1) = 'no'
@y
if dosubstr(in_record,doindex(in_record,'=')+1,length(in_record)
-doindex(in_record,'=')) = 'no'
@z
 
@x   line 744
if dosubstr(in_record,doindex(in_record,'=')+1) = 'no'
@y
if dosubstr(in_record,doindex(in_record,'=')+1,length(in_record)
-doindex(in_record,'='))  = 'no'
@z
 
@x   line 862
@<Write Sort Record@>=
sort_file@@:=sort_record;
put(sort_file);
@y
@<Write Sort Record@>=
write(sort_file,sort_record);
@z
 
@x   line 890
The page number for a blind entry will always be 999999999.
 
@<Do Blind Entry@>=
begin remove_characters(6);{Throw away the `\$\{\$\}be'}@/
i := doindex(in_record,'{$}');
curr_level:=2;
write_print_chars(i-1);
curr_level:=0;
remove_characters(3);{Throw away the `\{\$\}'}
sort_record.page_number := 999999999;
@y
The page number for a blind entry will always be 9999.
 
@<Do Blind Entry@>=
begin remove_characters(6);{Throw away the `\$\{\$\}be'}@/
i := doindex(in_record,'{$}');
curr_level:=2;
write_print_chars(i-1);
curr_level:=0;
remove_characters(3);{Throw away the `\{\$\}'}
sort_record.page_number := 9999;
@z

@x   line 937
@p procedure add_page_number;
var i:integer;
@y
@p procedure add_page_number;
var i:integer;
label return;
@z
 
@x   line 955
@<Add Page Number to the String@>
@y
@<Add Page Number to the String@>
return:
@z
 
@x   line 963
@!str_build:string_type(max_lrecl);
@y
@!str_build:string_type(max_lrecl);
@!temp_build:string_type(max_lrecl);
@z
 
@x   line 976
str_blind_entry := ccat(str_blind_entry,str(field_level[i]));
@y
str_blind_entry := ccat(str_blind_entry,field_level[i]);
@z
 
@x   line 996
@ If the {\it page\_string[1]} is less than zero, its alphabetic and
roman numeral processing is necessary.
 
@<Do Sorted Non Blind Entry@>=
with sort_record do begin
if ord(page_string[1]) < ord('0')
@y
@ If the {\it page\_string[1]} is greater
 than nine, its alphabetic and
roman numeral processing is necessary.
 
@<Do Sorted Non Blind Entry@>=
with sort_record do begin
if ord(page_string[1]) > ord('9')
@z

@x line 1006
str_build := ccat(ccat(ccat(strconv(page_string),
','),temp_strvalue),str_build);
@y
temp_build:=ccat(strconv(page_string),',');
temp_build:=ccat(temp_build,temp_strvalue);
str_build:=ccat(temp_build,str_build);
@z

@x   line 1103
then curr_str_page:=dosubstr(curr_str_page,2)
@y
then curr_str_page:=dosubstr(curr_str_page,2,length(curr_str_page)-1)
@z
 
@x   line 1179
if i < 1 then begin curr_str_page:=str_build; str_build:='';end
else begin
curr_str_page:=dosubstr(str_build,1,i-1);
str_build := dosubstr(str_build,i+1);
end;
@<Get the Current Print Type of this Page Number@>;@/
if ord(curr_str_page[1]) < ord('0') {Then its alphabetic}
@y
if i < 1 then begin curr_str_page:=str_build;
str_build:='';end
else begin
curr_str_page:=dosubstr(str_build,1,i-1);
str_build := dosubstr(str_build,i+1,length(str_build)-i);
end;
@<Get the Current Print Type of this Page Number@>;@/
if ord(curr_str_page[1]) > ord('9')
@z
 
 
@x   line 1192
if i < 1 then begin temp_roman:=str_build; str_build:='';end
else begin
temp_roman:=dosubstr(str_build,1,i-1);
str_build := dosubstr(str_build,i+1);
@y
if i < 1 then begin temp_roman:=str_build;
str_build:='';end
else begin
temp_roman:=dosubstr(str_build,1,i-1);
str_build := dosubstr(str_build,i+1,length(str_build)-i);
@z

@x   line 1254
output_string := ccat(ccat('\leader{}',output_string),'\par');
@y
output_string:=ccat('\leader{}',output_string);
output_string:=ccat(output_string,'\par');
@z 
 
@x   line 1305
sort_record:=sort_file@@;
get(sort_file);
@y
read(sort_file,sort_record);
@z

@x   line 1524
@* Main Program.
Ok, here is the main program. First we initialize (all\_blanks); then
set the ix\_file for input and the sort\_file for output; read all of the
entries, processing each one; close the files; sort; read the sorted file
in and build the entries, writing them back to the ix\_file to be read in
by the index markup. WHEW!!
 
@p
begin @<Initialize Main@>@/
termout(messages);
reset_file(ix);@/
file_rewrite(s_file_number); {Should always be file 9}@/
read_all_entries;@/
close(ix_file);@/
close(sort_file);@/
@<Sort the Index@>@/
reset_file(s_file_number);@/
file_rewrite(ix);@/
build_sorted_index;@/
end;
@y
@* Main Program.
Ok, here is the main program. First we initialize (all\_blanks); then
prompt to determine which index to use (1, 2, or 3).
Next call VMS' sort routine. And thats it.
 WHEW!!
 
@p
begin @<Initialize Main@>@/
write('Which index are you processing (1, 2, or 3)? ');@/
readln(ix);@/
if (ix <> '1') and (ix <> '2') and (ix <> '3') then begin
writeln(messages,
'You can only process indexes 1, 2, or 3. Start again.');
halt; end;
writeln('');
writeln(messages,'Starting the sort routine....');
writeln(messages);
reset_file(ix);@/
file_rewrite('9');
read_all_entries;
close(ix_file);
close(sort_file);
@<Sort the Index@>@/
reset_file('9');
file_rewrite(ix);
build_sorted_index;
close(ix_file); {ix\_file now has the index to be run through \TeX}
end.
@z
 
 
@x   line 1558
sort_rc:integer;
@y
sort_rc:integer;
@!ix:char;
@z


@x   line 1565
plsort(sort_rc);
if sort_rc = 0
   then writeln(messages,'Index Successfully Completed')
   else writeln(messages,'Index Failed');
@y
vmssort(sort_rc);
if odd(sort_rc) 
   then writeln(messages,'Index Successfully Completed')
   else writeln(messages,'Index Failed');
@z