Re: Cross reference for 4GL functions?
Posted in 1995
To get cross-reference information, I prefer to let the compiler and linker do the work, rather than trying to write scripts to interpret the 4GL source code. For folks running under Unix and using the compiled version of 4GL, rather than the RDS version, I offer the following script, which I named 'compile': ----- Begin compile script ----- #!/bin/csh -f # Remove pre-existing object file. rm -f ../object/$1.o # Start cross-ref file. echo '' >$1.x echo module $1 : >>$1.x echo '' >>$1.x # Tell user compile is starting. echo \\#c4gl $1.4gl #c4gl $1.4gl >& temp.x c4gl $1.4gl >& temp.x # Alert user of errors. egrep -e '[^_]error|warning' temp.x # Finish making cross-ref file. egrep -v -e '_main|warning|Undefined' temp.x | sort >>$1.x # Kill temp files. rm -f temp.x rm -f $1.c $1.ec a.out # Move files to appropriate related directories. mv $1.x ../xref/$1.x mv $1.o ../object/$1.o # Tell user compile is done; ls $1.err file, if any. echo \\#ls $1\\* ls -l $1* echo '' ----- End compile script ----- This script assumes a directory structure something like: $PROJECT/source $PROJECT/object $PROJECT/xref All of the source, object, and cross-ref files are kept in the appropriately named directories. Compilation should be done from within the source directory. To compile module 'trc_change.4gl' the usage is: compile trc_change Note that you do not include the .4gl extension. This will compile trc_change.4gl, move the trc_change.o to the ../object directory, delete the trc_change.c and trc_change.ec files, and produce a trc_change.x file, in the ../xref directory, that looks like this: ----- Begin trc_change.x ----- module trc_change : _can_send _clear_form _clear_margins _create_report _display_menu _mail_report _review_report _start_form _tr_hdr _tr_hdr_write _tr_hist_write _trouble_report ----- End trc_change.x ----- The name.x file lists all referenced functions and global variables, all of which are prefixed with an underscore "_". Depending on your code, it will also list external window names, which will be preceded by "_W". Using the compiler and loader to find references is much more reliable than scanning the source code using a script. How would you distinguish a global variable from a local variable by syntax, without reproducing much of the functionality of the compiler? Why reinvent that wheel? Unfortunately, this technique is only available if you use compiled 4GL, not RDS. Regards, Alan +---------------------------+-----------------------------------------------+ | R. Alan Popiel | Internet: alan@den.mmc.com | | Martin Marietta, SLS | Voice: 303-977-9998 | | P.O. Box 179, M/S 3810 | Standard disclaimers apply. Cutesy ones, too. | | Denver, CO 80201-0179 USA | Your mileage may vary. Void where prohibited. | +---------------------------+-----------------------------------------------+