Re: Informix 4GL Formatter
Posted in 1994
In article <1994Dec8.195925.12365@seas.smu.edu>, rao@seas.smu.edu (Kishore C. Rao) wrote: > Could somone tell me where I can find a Informix 4GL Formatter. > Also are there any tools available for getting program flow information. ? I wrote a program flow shell last week (I was actually trying to follow the logic path through some 4GL-Monster-Code and decided that such a beast would be a Good Thing). It's not real flash, and it's not real fast, but it seems to work. Here it is, "pathfinder". EXAMPLE: pf "INSERT" *4gl Will scan all 4gl files in the current directory and output a tree showing the possible paths to any INSERT statements. Output is something like: ... MAIN ...... menu_choice ......... build_temp_tables ............ INSERT INTO TEMP mytemp ......... select_type ............ update_real_table ............... INSERT INTO live_table ............ update_budget_table ............... INSERT INTO budget_table BTW: I've got a 4GL code reformatter too, but it's got a few ugly holes in it, and I'd only recommend it if your indentation has totally gone to the pack. Regards, Kerry S ------------------------- CUT HERE (pf) --------------------------- #/bin/sh if test $1x = x then echo "pathfinder - shell to find path to a given peice of code " echo " in a 4GL function" echo echo "USAGE: pf <searchtext> <filename.4gl>" echo " EG: pf \\"INSERT.INTO.olines\\" *4gl" echo " (yes - you need the dots - how do you do that nicely?)" echo echo "Kerry Sainsbury (kerry@kcbbs.gen.nz) December 1994" exit 1 fi echo "Splitting program into composite functions..." > `tty` rm -rf pftemp mkdir pftemp 2>/dev/null search=$1 while test $2x != x do sed -e "s/^MAIN/FUNCTION MAIN()/" $2 >> pftemp/pf.4gl shift 1 done csplit -k -s pftemp/pf.4gl /FUNCTION.*\\(/ {999} 2>/dev/null rm pftemp/pf.4gl ilist=`ls xx*` for i in $ilist do newname=`grep "^FUNCTION" $i` if test $? = 1 then newname="MAIN" else newname=`echo $newname | sed -e "s/FUNCTION //" -e "s/(.*//"`"\\\\(" fi mv $i pftemp/$newname done cd pftemp echo "Building function tree..." > `tty` pfbuild $search echo "Outputing function tree..." > `tty` pfoutput MAIN 1 MAIN $search rm -rf pftemp -------------------- CUT HERE (pfbuild) --------------------- #/bin/sh # pfbuild. Shell function called by "pf" - pathfinder # - builds function linkages # Kerry Sainsbury (kerry@kcbbs.gen.nz) December 1994 if test $1x != MAINx then echo $1 | grep "(" > /dev/null if test $? = 0 then baselist=`egrep -l "=$1| $1" *` else baselist=`grep -l $1 *` fi iter=`echo 0` for bot in $baselist do if test $bot != $1 then func=`echo $bot--$1 | sed -e "s/.(//g"` cat /dev/null > $func pfbuild $bot fi done fi -------------------- CUT HERE (pfoutput) --------------------- #/bin/sh # pfoutput. Shell function called by pf - pathfinder # - Outputs function tree # # Kerry Sainsbury (kerry@kcbbs.gen.nz) December 1994 lvl=$2 spaces=`echo "............................" | cut -c1-$lvl` spaces=`echo $spaces | sed -e "s/./.../g"` if test $1 = $4 then grep $1 "$3\\\\(" | sed -e "s/^/$spaces/" else echo $spaces $1 fi outlist=`ls $1--* 2>/dev/null` for out in $outlist do new=`echo $out | cut -d"-" -f3` pfoutput $new `echo $lvl+1 | bc` $1 $4 done > > Thanx > > > --------------------------------------,------------------------------------- Kerry Sainsbury, kerry@kcbbs.gen.nz | THE INFORMIX FAQ Quanta Systems, Auckland, New Zealand | kcbbs.gen.nz:/informix/* | mathcs.emory.edu:/pub/informix/faq/* +64 9 377-4473 (work) 276-5546 (home) | quasar.ucar.edu:/?