Compile subroutine Copy_All_Tables_To_SQL(Backlog)

/*****************************************************************************\
	This is a utility function. It resynchronizes all tables to SQL.
	
	NOTE: You must uncomment the list of tables you wish to sync. They are
	      grouped according to size and should be run in those groups.
	
	History
	-------
	08/10/2010    KRF    Original Programmer
	07/19/2010    KRF    Updated to use hardcoded list
\*****************************************************************************/

Equ Update_Interval$ to 1000

If Assigned(Backlog) else Backlog = 0

Declare subroutine Copy_Table_To_Sql
Declare function DateTime, GetTickCount, Get.RecCount, GetASyncKeyState

Tables = ""

// Small to medium size
* Tables := "FISCAL_YR,FISCAL_QTR,TW_CODES,TOOL,REACT_STATUS,REACT_TUBE,LOSS_CODES,REACTOR,TOOL_ESC,REACT_PROB_CAT,REACT_SERV_CAT,"
* Tables := "CALIB_LIST,CALIBRATION,TUBE,REACT_PROBS,WO_MAST_SCHED,CUSTOMER,CUST_EPI_PART,RECIPE,COMPANY,REACT_SERVS,CUST_PART,EPI_PART,"
* Tables := "QUARTZ_WAND_LOG,CDM_LOG,PROD_VER,HOTH2O2_LOG,PROD_SPEC,TOOL_LOG,MEG_LOG,"

// Big
* Tables := "REACTOR_PM,REACT_ITEMS,QUARTZ_TC_LOG,WM_IN,WM_OUT,REACT_READS,WO_STEP,WO_LOG,NCR,COC,"
Tables = "PM_SPEC"
// Really big
//Tables := "TW_USE,REACTOR_LOG,REACT_RUN,REACT_UTIL,WO_MAT,RDS_LAYER,RDS_TEST,REACT_EVENT,CLEAN_INSP"

Convert "," to @FM in Tables

Errors = ""

NumTables = Count(Tables, @FM) + 1
For iTable = 1 to NumTables
    Table = Tables<iTable>
    
    // copy or backlog each table
    If Backlog EQ 1 then
        NumCopied = 0
        StartTime = GetTickCount()
        Open "SQL_BACKLOG" to hSqlBacklog then
            Open Table to hTable then
                ClearSelect
                Select hTable
                RecCount = Get.RecCount(hTable, Status, 0)
                Done = 0
                Loop
                    ReadNext Key else Done = 1
                Until Done OR (GetASyncKeyState(27) LT 0)
                    Write DateTime() to hSqlBacklog, Table:"*":Key
                    NumCopied += 1
                    If GetTickCount() - StartTime GE Update_Interval$ then
                        Call SRP_Editor_Send_Info(Table:"'s Records Processed: ":NumCopied:" / ":RecCount)
                        StartTime = GetTickCount()
                    end
                Repeat
            end
        end
    end else
        Copy_Table_To_Sql(Table, 3)
    end
    
Next iTable

Return
