'--------------------------------
'Name: dbfcat.main
'Date: 2-23-01
'
'1. prompts the user for multiple dbf files on disk
'2. prompts the user for concatenation style:
' (1) simple record-by-record append, filename of each dbf added to
' every record to ensure record uniqueness
' (2) transpose and append, the first .DBF file is used to create
' new .DBF where the records in a user specified field become
' fieldnames and the values in a second user specifed field become
' the records under the new fieldnames
'3. prompts the user for filename of new dbf file
'
'
'Returns:
'None
'
'Called By:
'MANY
'
'Calls:
'NONE
'
'Arguments:
'None
'---------------------------------
MsgBox.Report("dbfcat.main" + NL +
"1. prompts the user for multiple dbf files on disk" + NL +
"2. prompts the user for concatenation style:" + NL +
" (1) simple record-by-record append, filename of each dbf added" + NL +
" to every record to ensure record uniqueness" + NL +
" (2) transpose and append, the first .DBF file is used to create" + NL +
" new .DBF where the records in a user specified field" + NL +
" become fieldnames and the values in a second user " + NL +
" specifed field become the records under the" + NL +
" new fieldnames" + NL +
"3. prompts the user for filename of new dbf file" , "About Script....")
'---------------------------------------------
'retrieve FileNames of .DBF files to process
'---------------------------------------------
theFileNameList = FileDialog.ReturnFiles({"*.dbf"}, {"DBF Files(*.dbf)"}, "Select.DBF Files To Concatenate", 0)
if ( theFileNameList.Count = 0 ) then
return NIL
end
'---------------------------------------------
'make list of vtabs from filenames
'---------------------------------------------
theVtabList = List.Make
for each fname in theFileNameList
if ( File.Exists(fname) and fname.IsFile ) then
if ( Vtab.CanMake(fname) = true ) then
theVtabList.Add(Vtab.Make(fname, FALSE, FALSE))
end
end
end
if ( theVtabList.Count = 0 ) then
MsgBox.Error("Unable to create vtabs from user supplied list.", "Operation Failed")
return NIL
end
'----------------------------------------------
' set concatenation style
'----------------------------------------------
theRBRAppendString = "Simple Record-By-Record Append"
theRTAppendString = "Record Transpose and Append"
theCatStyleStringList = { theRBRAppendString, theRTAppendString}
theCatStyleString = MsgBox.ChoiceAsString(theCatStyleStringList, "Select the concatenation style:", "Cat Style")
if ( theCatStyleString = NIL ) then
return NIL
end
'---------------------------------------
'retrieve name of new .DBF file
'---------------------------------------
theDBFFileNameString = MsgBox.Input("Enter the name to assign to the new .DBF file:", "Cat-ed .DBF FileName", "cat")
if ( theDBFFileNameString = NIL ) then
return NIL
end
theDBFString = theDBFFileNameString.Substitute(".dbf", "")
'----------------------------------------------
' cat the dbfs
'----------------------------------------------
if ( theCatStyleString = theRBRAppendString ) then
av.Run("dbfcat.RBRAppend", {theVtabList, theDBFString})
elseif ( theCatStyleString = theRTAppendString ) then
av.Run("dbfCat.RTAppend", {theVtabList, theDBFString})
else
'do nothing
end
av.PurgeObjects
return NIL
Last Updated: Marco Morais