Include "MapBasic.def" Declare Sub TyLog(ByVal msg as String) Declare Sub Main Declare Sub ReadTextFileToArray(ByVal dumpDir as String, ByVal txtFilePath as String, myArray() as String) Sub Main Print "Starting Main" Dim myArray() as String '// create an array to store the table paths Dim dumpDir, tabName, tempName, tabPath, txtFile as String Dim newTable as String Dim i as Integer dumpDir = "E:\tyler\canadian-census\2023_03\canadian_census\2023_03\shorelined\product\TAB" txtFile = dumpDir + "\files.txt" Call ReadTextFileToArray(dumpDir, txtFile, myArray) '// populate your array with the table paths from the text file Call TyLog("Read the list of files") newTable = "temp" For i = 1 to UBound(myArray) Call TyLog("Processing file " + i + " [" + myArray(i) + "]") If FileExists(myArray(i)) Then Call TyLog(" File exists") If right$(myArray(i), 3) = "TAB" then Call TyLog(" File is a tab file") tabPath = myArray(i) Open table tabPath tabName = TableInfo(0, TAB_INFO_NAME) Call TyLog(" Altering table...") Alter table tabName ( modify code Char(10), areaname Char(100), type Char(3) ) select * from tabName into Selection Call TyLog(" Cleaning table...") Set Table tabName FastEdit On Undo Off Objects Clean From Selection Overlap Call TyLog(" Committing table...") Commit Table tabName Call TyLog(" Packing table...") Pack table tabName Graphic Data Call TyLog(" Renaming: " + tabName + " to " + newTable) '// Index last in hopes of speeding things up Create Index On tabName (code) Rename table tabName As newTable tempName = TableInfo(0, TAB_INFO_NAME) Call TyLog(" Committing final table...") Commit Table tempName As tabPath TYPE NATIVE Charset "WindowsLatin1" Call TyLog(" Dropping temp table...") Drop Table tempName Call TyLog(" Closing table...") Close Table tempName Interactive End if End If Next '// go to next element in array Call TyLog("We are so done!") End Sub Sub TyLog(ByVal msg as String) Dim logMsg as String logMsg = Time(24) + ": " + msg Print logMsg End Sub Sub ReadTextFileToArray(ByVal dumpDir as String, ByVal txtFilePath as String, myArray() as String) Dim i as Integer Dim aLine, filename as String i = 1 Print "About to read: [" + txtFilePath + "]" Open file txtFilePath for input as #1 '// open text file for input (to read) as #1 Do Until EOF(1) '// do until the end of file #1 is reached Input #1, aLine '// read value from text file filename = dumpDir + "\" + aLine '// create full path Redim myArray(i) '// resize array to i myArray(i) = filename '// read value from text file i = i + 1 '// increment i Loop '// return to Do Until... Close File #1 End Sub