summaryrefslogtreecommitdiff
path: root/support/rnototex/basicfileops.pas
blob: 8e3f1fde4edd38689749a9a027b846af0723be55 (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
[INHERIT('UTILITYOPS','SCREENHANDLERS','ARGOPS'), environment('basicfileops')]

MODULE BASICFILEOPS;

CONST

   maxfidchars = 255;
   ndatetimechars = 11;                     
   programversion = 'CVF02B';
   inifilename = 'INIT$RNOTOTEX';
   logfilename = 'RNOTOTEX.LOG';


TYPE

fidtype = VARYING[maxfidchars] of char;

datetimetype = packed array[1..ndatetimechars] of char;

                                    
VAR
   inputcontainstexcommands : [EXTERNAL] boolean;
   totallines, totalchars    : [EXTERNAL] integer;
   LOG	                       : [EXTERNAL] text;




[GLOBAL] PROCEDURE noconversion;
begin
  writeln(log,'[no conversion performed]')
end;




[GLOBAL] PROCEDURE greetuser ( var d, t : datetimetype );
begin
   date( d );
   time( t );
   clearscreen;
   ttywritestring('RNOTOTEX ');
   ttywritestring(programversion);
   ttywritestring('    RUNOFF TO TEX CONVERSION    ');
   ttywritestring( d );
   ttywritestring( t );
   ttywriteln;
   ttywriteln;
   ttywriteln
end;
    




[GLOBAL] PROCEDURE openinputfile( fid : fidtype; var f : text; var openerror : boolean );
begin
   open( file_variable := f,
         file_name := fid,
         history := readonly,
         default := 'INPUT.RNO',
         error := continue );                                     
   if status(f) <> 0 then
      openerror := true
   else                  
   begin 
      reset( f );
      openerror := false      
   end
end;
                       




[GLOBAL] PROCEDURE openoutputfile(fid : fidtype; var f : text; var openerror:boolean);
begin
     open( file_variable := f,
           file_name := fid,
           history := new,
           default := 'OUTPUT.TEX',
           error := continue );
     if status(f) <> 0 then
        openerror := true
     else
     begin
        openerror := false;
        rewrite(f)
     end;
end; 

    

[GLOBAL] PROCEDURE openinifile ( var f : text );
begin
    open( file_variable := f,
          file_name := inifilename,
          history := readonly,
          error := message );
    reset( f );                                            
    ttywriteln;
    ttywritestring('Loading INI file ...')
end;
          
    

                                                    
[GLOBAL] PROCEDURE openlogfile; { global var LOG : text used }
begin
   open( file_variable := log,
	 file_name := logfilename,
	 history := new,
	 error := continue );
   rewrite( log )
end;



[GLOBAL] PROCEDURE closelogfile; 
begin
   close( file_variable := log, error := continue )
end; 
         
[GLOBAL] PROCEDURE closeinifile( var f : text );
begin
    close( file_variable := f, error := continue );
    ttywritestring('complete.');
    ttywriteln;
end;





[GLOBAL] PROCEDURE closefiles( var infile, outfile : text );

begin
   close(file_variable := infile, error := continue);
   close(file_variable := outfile, error := continue);
   ttywritestring('complete.');
   ttywriteln;
   ttywriteln;
   ttywriteln;
   if totallines = 1 then               
      ttywritestring(' RNOTOTEX read only one line from the input file.')
   else
     if totallines = 0 then
       ttywritestring(' No end of line was found in the input file.')
     else                                                  
     begin
       ttywritestring(' RNOTOTEX processed a total of ');
       ttywriteint( totallines );
       ttywritestring(' lines.')
     end;
   ttywriteln;
   if totalchars = 1 then
      ttywritestring(' There was only one character in the file.')
   else
      if totalchars = 0 then
        ttywritestring(' No printable characters were found in the file.')
      else
      begin
         ttywritestring(' A total of ');
         ttywriteint( totalchars );
         ttywritestring(' characters were read.')                           
      end;
   ttywriteln
end;

    




[GLOBAL] PROCEDURE putcommentstooutput( var outfile : text; infid : fidtype;
	                                d, t : datetimetype );
begin
   writeln(outfile,'% document translated from DEC RUNOFF to LaTeX format');
   writeln(outfile,'% by program RNOTOTEX version ',programversion,' at ',d,blank,t);
   writeln(outfile,'% Source file :',infid);
   writeln(log,'[RNOTOTEX.LOG for ',infid,' ]');
   writeln(log,'[Processing at ',d, blank, t,' ]')
end;               


             


[GLOBAL] PROCEDURE userinterface( var inputfid, outputfid : fidtype;
	                           var rno, tex : text );

type
    packedarray = packed array[1..255] of char;

var
   openerror : boolean;
   slashtex : integer;

   procedure getcli( var ifile, ofile : [class_s] packedarray;
                     var slashtex : integer ); fortran;
begin
      getcli( inputfid.body, outputfid.body, slashtex );
      inputfid.length := 75;
      outputfid.length := 75;
      openinputfile( inputfid, rno, openerror);
      if openerror then
        warningmessage('openinputfile','Could not open that input file.');
      openoutputfile( outputfid, TEX, openerror);
      if openerror then
         warningmessage('openoutputfile','Could not open that output file.');
      inputcontainstexcommands := slashtex <> 0
end;


END.