Cynthia,
The command file that I submitted earlier will NOT work correctly if your
forms file has more than 50 forms (The ones that I've been working with do
not). The revised attached version will work correctly with files
containing any number of forms.
Regards
Paul H. Christidis
-------------------------------<Start Cut *+1 for VFORMCLN
parm infile="?"; outfile="newvform"; entry='MaIn'
#
# Command file: vformcln 1998/05/06
# Author: Paul H. Christidis : [log in to unmask]
# Remarks: Will generate the 'spec' file needed and 'clean'
# a 'VPLUS' forms file.
#------------------------------------------------------------
# ReadFormList section. Reads the output of the 'forms' command
# of formspec and generates the needed 'copy' and 'relate' commands.
#
if "!entry" = "ReadFormList" then
setvar _vp_relate_count 0
while (POS("$eod$",(SETVAR(_vp_text,INPUT()))) = 0) do
if LEN(_vp_text) > 60 AND NUMERIC(STR(_vp_text,58,1)) then
setvar _vp_form STR(_vp_text,1,16)
echo COPY !_vp_form IN !infile >> cleanspc
#
if LEN(SETVAR(_vp_parent,RTRIM(STR(_vp_text,62,16)))) <> 0 then
echo RELATE !_vp_form TO !_vp_parent >> rlatspec
setvar _vp_relate_count _vp_relate_count + 1
endif
endif
endwhile
if _vp_relate_count <> 0 then
print rlatspec;page=0 >> cleanspc
purge rlatspec,temp
endif
echo COMPILE >> cleanspc
echo EXIT >> cleanspc
return
#
# Main Section:
# Display banner and/or usage, validate parameters, build files.
#
else
setvar _vp_bell CHR(7)
echo (PHC) FORMSPEC forms 'clean up' V98.05.06 !hpdatef, !hptimef
setvar _vp_infile UPS("!infile")
if "!_vp_infile" = "?" then
echo Usage: !_vp_bell
echo ![FINFO(hpfile,"fname")] Infile [Outfile]
echo
echo Infile - VLPUS forms file, qualified to the extent needed,
echo that will be 'cleaned up'.
echo
echo Outfile - Name of new forms file. The new forms file must
echo NOT already exist. [Default: NewVform]
echo
echo NOTE: This command file cannot transfer 'save' fields and
echo GLOBAL settings (terminals, languages, default enhancement,
echo Data Type Conversions, etc..). The user MUST perform that
echo task manually, run this command file and reply 'NO' to the
echo prompt about purging the 'Outfile'.
return
endif
setvar mpexfinfoany 1
setvar _vp_error 0
if NOT finfo(_vp_infile,"exists") then
echo !_vp_bell ** File !_vp_infile does NOT exist...
setvar _vp_error _vp_error + 1
else
if finfo(_vp_infile,"fmtfcode") <> "VFORM" then
echo !_vp_bell ** File !_vp_infile is NOT a VPLUS forms file...
setvar _vp_error _vp_error + 1
endif
endif
if _vp_error <> 0 then
return
endif
echo !_vp_bell
echo Warning** Not default GLOBAL settings and any 'SAVE' fields
echo contained in !_vp_infile MUST be created in the newfile
echo !_vp_outfile before this command file is executed.
echo !_vp_bell
setvar _vp_outfile UPS("!outfile")
if FINFO(_vp_outfile,"exists") then
if finfo(_vp_outfile,"fmtfcode") = "VFORM" then
echo *** File '!_vp_outfile' already exists *** !_vp_bell
setvar _vp_yn "Y"
input _vp_yn;prompt="Purge !_vp_outfile [Y/n] ?!_vp_bell";wait=60
if UPS(LFT(LTRIM(RTRIM(_vp_yn)),1)) = "Y" then
echo !_vp_bell Purging OLD version of !_vp_outfile file ....
purge !outfile
else
echo !_vp_bell Cleaning of !_vp_infile is being canceled...
return
endif
else
echo !_vp_bell
echo Output file already exists. Cleaning being canceled...
return
endif
endif
#
# Parameters were validated. Generate batch command to invoke formspec
# and generate list of fomrs. XEQ command to process list and finally
# invoke formspec again to compile the new form.
#
echo FILE !_vp_infile > gpstdin
echo FORMS >> gpstdin
echo EXIT >> gpstdin
echo !_vp_bell Generating list of forms in file !_vp_infile
formspec.pub.sys gpstdin > fspeclst
echo $eod$ >> fspeclst
echo FILE !_vp_outfile > cleanspc
xeq !hpfile !_vp_infile, !_vp_outfile ;entry="ReadFormList" <fspeclst
echo !_vp_bell Compiling new (!_vp_outfile) forms file...
formspec.pub.sys cleanspc
echo !_vp_bell
echo ************************************************* !_vp_bell
echo * The newform !_vp_outfile was compiled. Use 'online'
echo * FORMSPEC to create the 'Fast Form File' if needed and
echo * manually rename !_vp_outfile to !_vp_infile when ready.
echo ************************************************* !_vp_bell
endif
# Clean Up
#
deletevar mpexfinfoany
if bound(traceon) then
showvar _vp_@
else
purge gpstdin,temp
purge cleanspc,temp
deletevar _vp_@
endif
-------------------------------<End Cut *-1 for VFORMCLN
|