3
This is a rexxscript to scan for pascal records.
5
I made this one to check my translation of
6
cheaders to fpc units. It will write two
7
files one pascalfile and one cfile.
9
The pascalfile you can almost everytime just
10
compile with fpc. In the cfile you have to
11
make some changes, just put in a line that
12
include the cheader for you testprogram.
14
So if you translate a cheader to fpc just
15
let this script check it out, if you get
16
the same result from both program you have
17
probably made the translation correct.
21
rx getrecord yourunit.pas
23
nils.sjoholm@mailbox.swipnet.se
34
say 'Input filename to scan for records'
37
say 'Error no filename'
46
if index(name,'.') > 0 then do
47
parse var name thesource '.' extension
50
pasname = thesource || 'rec1.pas'
51
cname = thesource || 'rec2.c'
53
IF ~Open('textfile',name,'READ') THEN DO
58
say 'Scanning ' || name
60
DO WHILE ~eof('textfile')
61
line.i = ReadLn('textfile')
62
line.i = Strip(line.i)
63
myproc = Word(line.i,3)
64
myproc = Upper(myproc)
65
IF myproc = "RECORD" THEN DO
66
CALL CheckLine(line.i)
67
SAY "Doing line :" || i
71
CALL Close('textfile')
77
else say 'No records found'
82
writeln('outfile','Program testrecords;')
84
writeln('outfile','uses exec,' || thesource || ';')
86
writeln('outfile','begin')
90
if ~Open('outfile',pasname,'W') then do
91
say 'Can not create file'
95
SAY "Working on " || pasname
99
towrite = 'writeln(' || "'" || thename || "',' ':30-length(" || "'" ||thename || "'),"
100
towrite = towrite || "':'"
101
towrite = towrite || ',sizeof(' || thename || '));'
103
writeln('outfile',towrite)
105
writeln('outfile','end.')
106
writeln('outfile','')
107
CALL Close('outfile')
112
writeln('outfile','');
113
writeln('outfile','#include ' || '"stdio.h"')
114
writeln('outfile','')
115
writeln('outfile','main()')
116
writeln('outfile','{')
120
if ~Open('outfile',cname,'W') then do
121
say 'Can not create file'
125
SAY "Working on " || cname
129
towrite = 'printf(' || '"%-30s:%d\n","' || thename || '",'
130
towrite = towrite || 'sizeof(struct ' || right(thename,length(thename)-1) ||'));'
132
writeln('outfile',towrite)
134
writeln('outfile','}')
135
writeln('outfile','')
137
CALL Close('outfile')
142
parse var theline thename thesep therecord therest
143
if thesep = '=' then do
144
thename = strip(thename)
154
SAY "Sorry, error line" SIGL ":" ErrorText(RC) ":-("