jim@bilpin.UUCP (JimG) (11/10/89)
#{v_databases.9}
A while ago I posted an awk script of mine for formatting Oracle
SQL*Forms definitions into a readable layout. There were a few
imperfections which I pointed out at the time, which have now been
tidied up, so herewith is the updated version.
# Start of fmtinp.sh ---------------------------------------------
# Author: Jim Grimwood, Hatfield, England
# Script to format an Oracle SQL*Forms .inp file into a more useful layout
# Syntax : fmtinp.sh formname # (omit the .inp suffix)
echo "
fmtinp.sh(v2): Form definition formatter for ORACLE SQLForms Version 2 :
\nForm header ..."
if sed -n 1p $1.inp | fgrep '; Generated by SQL*Forms Version 2'
then
echo "1st pass on $1"
else
echo "
ERROR: Incorrect file format / Compressed .inp file / Wrong version
Run abandoned"
exit 1
fi
awk '
{ if( substr( $0, length ) == ":" )
{ FLAG = 1
LINE = $0
}
else
{ if( FLAG == 1 )
{ FLAG = 0
if( length > 0 )
print LINE, $0
}
else
{ if( $1 == ";SQL>" )
SQL = 1
else
{ if( SQL == 1 )
{ if( length > 1 )
print
else
SQL = 0
}
else
if( length > 0 && $0 != "/" )
print
}
}
}
}
' $1.inp > $1.tmp
echo "2nd pass on $1"
awk '
BEGIN { print "Formatted form definition for ORACLE SQLForms Version 2"
print "Generated by fmtinp.sh(v2): "
print ""
print "Form header ..."
}
/^;Block name/ { if( NEWLINE == 0 )
print ""
if( LOWEST != "" || HIGHEST != "" || DEFAULT != "" )
printf( "Lowest[%s]\tHighest[%s]\tDefault[%s]\n", \
LOWEST, HIGHEST, DEFAULT )
LOWEST = ""; HIGHEST = ""; DEFAULT = ""
if( $6 ~ /^\*\*/ )
$1 = ";Form trigger"
print ""
print "******************************************************"
print; NEWLINE = 1; PRN = 1
print "******************************************************"
}
/^;Field name/ { if( NEWLINE == 0 )
print ""
if( LOWEST != "" || HIGHEST != "" || DEFAULT != "" )
printf( "Lowest[%s]\tHighest[%s]\tDefault[%s]\n", \
LOWEST, HIGHEST, DEFAULT )
LOWEST = ""; HIGHEST = ""; DEFAULT = ""
if( $4 ~ /^\*/ )
$1 = ";Block trigger"
print "----------", $0
NEWLINE = 1; PRN = 1
}
/^;Must value/ { printf( "Must exist[%s]\t", $6 ); NEWLINE = 0; PRN = 1 }
/^;Type of/ { printf( "Type[%s]\t", $5 ); NEWLINE = 0; PRN = 1 }
/^;Is ..*base/ { printf( "In base table[%s]\t", $10 ); NEWLINE = 0; PRN = 1 }
/^;Is ..*key/ { printf( "In prim key[%s]\t", $11 ); NEWLINE = 0; PRN = 1 }
/^;Allow ..*ent/{ printf( "Enter[%s]\t", $8 ); NEWLINE = 0; PRN = 1 }
/^;Allow ..*upd/{ printf( "Update[%s]\t", $8 ); NEWLINE = 0; PRN = 1 }
/^;Allow ..*que/{ printf( "Query[%s]\t", $8 ); NEWLINE = 0; PRN = 1 }
/^;Hide value/ { printf( "Hide[%s]\n", $7 ); NEWLINE = 1; PRN = 1 }
/^;Is ..*mand/ { printf( "Mandatory[%s]\t", $6 ); NEWLINE = 0; PRN = 1 }
/^;Is ..*fixed/ { printf( "Fixed len[%s]\t", $7 ); NEWLINE = 0; PRN = 1 }
/^;Auto jump/ { printf( "Auto-jump[%s]\t", $8 ); NEWLINE = 0; PRN = 1 }
/^;Convert/ { printf( "Uppercase[%s]\t", $8 ); NEWLINE = 0; PRN = 1 }
/^;Length/ { printf( "\tLengths: Field[%s] / Display[%s] / Query[%s]\n", \
$11, $13, $15 )
NEWLINE = 1; PRN = 1
}
/^;Lowest/ { LOWEST = $4; PRN = 1 }
/^;Highest/ { HIGHEST = $4; PRN = 1 }
/^;Default/ { DEFAULT = $4; PRN = 1 }
/^;Page/ { PAGE = $3; PRN = 1 }
/^;Line/ { LINE = $3; PRN = 1 }
/^;Column/ { if( NEWLINE == 0 )
print ""
printf( "Page[%s]\tLine[%s]\tColumn[%s]\n", PAGE, LINE, $3 )
NEWLINE = 1; PRN = 1
}
/^;Enter defau/ { print substr( $0, 1, index( $0, ":" ) )
print substr( $0, index( $0, ":" )+1 )
NEWLINE = 1; PRN = 1
}
{ if( PRN == 0 )
{ if( NEWLINE == 0 )
print ""
print; NEWLINE = 1
}
PRN = 0
}
' $1.tmp > $1.fmt
if [ $? = 0 ]
then
echo "File $1.fmt created"
else
echo "Run abandoned"
fi
rm $1.tmp
# End of fmtinp.sh ---------------------------------------------
--
Another Fine Product from <mcvax!ukc!icdoc!bilpin!jim> <jim@bilpin.uucp>
{JimG : Hatfield, England}
This line has been intentionally left blank