scottj@ncrcae.Columbia.NCR.COM (L. Scott Johnson) (07/19/89)
Hello again. The following is another version of coordinate - the form coordinator. I added a few checks to the triggers to cut down on the beeping (the single most annoying aspect of SQL*Forms, outside of the documentation, IMO). To do that, tho', I had to know the name of the field used to coordinate the blocks. On a side note, If you have a detail block of a block that is itself a detail block of another, start at the bottom. For example: A Is the master-master block. It holds information on states. B Is the detail-master block. It holds information on counties in each state. C Is the detail-detail block. It holds information on cities in each county. $ coordinate FORM.inp Name of master block: B Name of key field: county_id # of detail blocks: 1 Name of detail block 1: C Done. Please LOAD the new input file thru SQL*Forms. $ coordinate FORM.inp Name of master block: A Name of key field: state_id # of detail blocks: 2 Name of detail block 1: B Name of detail block 2: C Done. Please LOAD the new input file thru SQL*Forms. $ sqlforms and LOAD the new form. --------- Finally, thanks to Bron@cup.portal.com for letting me know my mail feeder hadn't gone down. --------- ---------------------------------- cut here ------------------------------------ # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # README coordinate echo x - README cat > "README" << '//E*O*F README//' SQL*Forms block coordinator This shell script will coordinate any number of detail blocks with a master block in a SQL*Forms form. It modifies the FORM.inp file, so the form will need to be LOADed by SQL*Forms after running this program. The program will prompt you for the master block name, the name of the coordinating field (i.e., id_num), then the number of detail blocks and the names of the detail blocks in turn. The .inp file is entered on the command line. The process in brief is: 1. CREATE the form, complete with all blocks. Do NOT create any triggers in the master block before running coordinate! 2. SAVE and GENERATE the form 3. Execute the coordinate command, listing the .inp file on the command line. Supply data as requested. 4. In SQL*Forms, DROP the form then enter the form name again and LOAD the form. 5. SAVE the form. 6. GENERATE the new form. //E*O*F README// echo x - coordinate cat > "coordinate" << '//E*O*F coordinate//' #!/bin/sh ##################################### # # coordinate - coordinate blocks of a form in SQL*Forms # # synopsis: # # coordinate _inp_file_ # # Coordinates the actions of the following keys when pressed in the # master block: # # CLRBLK ENTQRY NXTSET # CLRREC EXEQRY PRVREC # CREREC NXTREC # # Written for SQL*Forms Version 20018.4.1 # # Should work for all SQL*Forms releases, but use at your own risk. # No guarantee of the suitability of this program for any purpose # is implied. # # Enjoy. L. Scott Johnson - scottj@ncrcae.columbia.NCR.COM ######################################################################### if [ "$#" -ne 1 ] then echo "Usage: coordinate fn.inp"; exit 1 fi if [ ! -r $1 ] then echo "$1 does not exist or is unreadble"; exit 1 fi #----------------------------------------------------------------------- echo echo 'Name of master block: \c' read master echo 'Name of key field: \c' read field echo '# of detail blocks: \c' read number i=0 while [ "$i" -ne "$number" ] do { i=`expr $i + 1` echo 'Name of detail block' $i': \c' read detail$i export detail$i list="$list $i" } done echo Working... echo #-------------------------------------------------------------------- cat - >cmd$$ <<EOF :se ic /^\*${master}\\/ :se noic /^;Field name : EOF for trg in CLRBLK CLRREC CREREC ENTQRY EXEQRY NXTREC NXTSET PRVREC do { echo o\*KEY-$trg >> cmd$$ echo "#EXEMACRO $trg;" >> cmd$$ for i in $list do { export i blk=`echo echo '$'detail$i | sh` echo "GOBLK $blk; CASE $master.$field IS" >> cmd$$ echo " WHEN "\'\'" THEN CLRBLK;" >> cmd$$ echo " WHEN OTHERS THEN EXEQRY;" >> cmd$$ echo "END CASE;" >> cmd$$ } done echo "GOBLK $master;\n\n;Message if value not found:" >> cmd$$ echo "Error coordinating detail records in KEY-$trg" >> cmd$$ echo ";Must value exist Y/N\nY" >> cmd$$ echo ";Field name :\033\c" >> cmd$$ } done echo 'ZZ' >> cmd$$ #-------------------------------------------------------------------- vi $1 < cmd$$ >/dev/null rm cmd$$ echo echo 'Done. Please LOAD the new input file thru SQL*Forms.' echo //E*O*F coordinate// exit 0