RE: Extracting calling structure from 4GL program
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
You can use Perl included in RedHat. Here is my sample code: if (@ARGV < 1) { die "Usage : functions.pl 4gl_file(s).\\n output file : functions\\n"; } open (OUTFILE,">functions") or die "Can not write to file functions\\n"; for ($i = 0 ; $i < @ARGV ; $i++){ open(EACHFILE,"$ARGV[$i]") or die "Can not open file $ARGV[$i]\\n"; print OUTFILE "---------------------------\\n"; print OUTFILE $i+1,":"."$ARGV[$i]"."\\n"; print OUTFILE "---------------------------\\n"; $j = 0; $line_number = 0; $found = ""; while ($line=<EACHFILE>){ $line_number ++; if ($line =~/^\\s*FUNCTION/i) { # search for string FUNCTION ,ignoring cases $j ++ ; if ($line =~/\\)/){ # if find char ) then definition ends $found = "end"; }else{ if ($line =~/\\(/) { $found = "begin"; # else multipul lines }else{ next; } } print OUTFILE $j,">",$line_number,":",$line; next; } if ($found eq "begin" ){ print OUTFILE " ",$line; if ($line =~ /\\)/) { # multiple lines end with ) $found = "end"; } } print OUTFILE " ->",$line_number,":",$1,"\\n" if $line =~ /^\\s*(update\\s+\\w+.*$)/i; print OUTFILE " ->",$line_number,":",$1,"\\n" if $line =~ /^\\s*(insert\\s+into\\s+\\w+.*$)/i; print OUTFILE " ->",$line_number,":",$1,"\\n" if $line =~ /^\\s*(delete\\s+from\\s+\\w+.*$)/i; print OUTFILE " ->",$line_number,":",$1,"\\n" if ($line =~/^\\s*(RETURN\\s+.*$)/i) ; print OUTFILE " ->",$line_number,":",$1,"\\n" if ($line =~/^\\s*(CREATE\\s+TEMP\\s+TABLE\\s+.*$)/i) ; }; print OUTFILE "\\n"; close (EACHFILE); } if (defined OUTFILE){ close (OUTFILE); } print "Please check file : functions here !\\n" HTH,Peter On Thursday, December 16, 1999 9:38 AM, Henk van der Geld [SMTP:h.van.der.geld@net.HCC.nl] wrote: > This is a multi-part message in MIME format. > --------------D00653A37D7A4461554C35EA > Content-Type: text/plain; charset=us-ascii > Content-Transfer-Encoding: 7bit > > Hi, > > Where can nawk be obtained, for instance for Linux (RedHat) or > Windows98? > > Thanks, > Henk > > Obnoxio The Clown wrote: > > > From: afalout@xtra.co.nz (Andrej Falout) > > > > >Thanks. What is nawk? > > > > New Awk. > > > > ______________________________________________________ > > Get Your Private, Free Email at http://www.hotmail.com > > --------------D00653A37D7A4461554C35EA > Content-Type: text/x-vcard; charset=us-ascii; > name="h.van.der.geld.vcf" > Content-Transfer-Encoding: 7bit > Content-Description: Card for Henk van der Geld > Content-Disposition: attachment; > filename="h.van.der.geld.vcf" > > begin:vcard > n:van der Geld;Henk > tel;home:+31 (0)73 513 01 02 > x-mozilla-html:FALSE > adr:;;;;;; > version:2.1 > email;internet:henk.van.der.geld@hccnet.nl > fn:Henk van der Geld > end:vcard > > --------------D00653A37D7A4461554C35EA-- >