multiple globals
Posted in 1996
Those of you still stuck with single globals declaration may find usefull the attached nawk script. It works by creating a temporary globals file that contains all the globals declarations found in all the globals "filename" statements encountered while scanning the 4gl source file. It also produces a modified 4gl source file that references the newly created temporary globals file. Line numbers are preserved. ---- cut here mg4gl ---- BEGIN { FS="\\"" gdone=0 } /^[^#]*globals *\\".*\\"/ { sub(/#.*$/,"") if (gdone) print "{" $0 "}" else { print "{" $0 "} globals \\"" gf "\\"" } while (getline v<$2>0) { sub("^[^#]*end *globals", "", v) if (gdone) sub("^[^#]*globals", "", v) if (gdone) sub("^[^#]*database *[^ ]*", "", v) print v > gf } gdone=1 next } { print } END {print "end globals" > gf} ---- end cut ---- (the mg in mg4gl stands for multiple globals and not marco greco :) pattern matching is probably oversimplified, but the code above works nicely and has almost no impact in compilation times (2 secs for a 1500 lines file in my slowest box). I've embended it in c4gl but I'm not giving this away for fear of stupidly breaching the license agreement or some copyright. marco. Oh, yes... Usage nawk -f mg4gl gf=temporary_globals source.4gl > newsource.4gl ____________________________________________________________________________ rem radioterapia, which I immeritately manage, seldom agrees with what I say marco greco (Catania, Italy) Work: marcog@ctonline.it rem radioterapia 39 95 447828 fax 446558 (was mar.greco@agora.stm.it) Achea 39 95 503117