Function Test_Daniel2(Param1)
#pragma precomp SRP_PreCompiler
* 
* Declare subroutine Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Send_Message, Logging_Services
* Declare subroutine Btree.Extract, Send_Event, Security_Err_Msg, Forward_Event, End_Window, Start_Window, FTP_Services
* Declare subroutine EditCell, obj_NCR, obj_Notes, Post_Event, obj_WO_Mat, obj_WO_Mat_Log, obj_WO_Wfr, obj_Tables, obj_RDS
* Declare subroutine Error_Services, RDS_Services, Dialog_Box, Insert, Unlock, QA_Services, Validate, Development_Services
* Declare subroutine Update_Index, Database_Services, Obj_WO_Mat_QA, Fmt, Yield, WinYield, Sleepery, Qa_Services, 
* Declare subroutine Obj_Post_Log, GaN_Services, Excel_Services, obj_WO_React, Activate_Save_Select, Reduce, FSMsg
* Declare subroutine SRP_Stopwatch, Copy_Record_To_SQL, SQL_Services, Material_Services, Messaging_Services
* Declare subroutine Reactor_Services, Reactor_Services_Dev, SRP_Stopwatch, Btree.Extract, Set_Env, Test_Daniel3
* Declare subroutine obj_WO_Log, SAP_Services, PSN_Services
Declare subroutine set_env, Get_Env
* Declare function Get_Property, Get_Status, Popup, Send_Message, Msg, Security_Check, Dialog_Box, RowExists, Utility
* Declare function Dialog_Box, obj_WO_Log, obj_NCR, Check_Notes, obj_MUWafers, obj_WO_Mat, Error_Services, RDS_Services
* Declare function MemberOf, obj_Tables, obj_RDS, Environment_Services, Logging_Services, Material_Services, ErrMsg
* Declare function Work_Order_Services, RetStack, Min, Max, Obj_Prod_Spec, Insert, SRP_Trim, Xlate, Obj_Wo_Mat
* Declare function Security_Services, QA_Services, Database_Services, RowExists, Rti_Lh_Info, UNICODE_ANSI, UNICODE_UTF8
* Declare function index, Httpclient_Services, SRP_Encode, SRP_Decode, DirList, Obj_Rds_Test, Tool_Parms_Services
* Declare function SQL_Services, RDS_Services, Obj_WM_out, Schedule_Services, Obj_Tool, SRP_Sort_Array, ICONV
* Declare function Development_Services, Obj_WO_Mat_QA, SRP_Join_Arrays, NextKey, Obj_Prod_Spec, FTP_Services, SQL_Format
* Declare function DateTime, GaN_Services, SRP_Array, Excel_Services, EpiPro_Services, Repository, RTI_Task_Submit
* Declare function RTI_Task_Status, Rds_Services, StartDotNet, Reactor_Services, SRP_Get_FileVersion, Epi_Part_Services
* Declare function Schedule_Services, List_Users, rti_lh_info_DEBUG, RTI_Lock_Owner, Popup_Services
Declare function GetCurrentProcessID, GetTickCount, Get_Env
* 
$INSERT ENVIRON_CONSTANTS
* $INSERT POPUP_EQUATES
* $INSERT MSG_EQUATES
* $INSERT APPCOLORS
* $INSERT WM_IN_EQUATES
* $Insert WM_OUT_EQUATES
* $INSERT WO_LOG_EQU
* $INSERT WO_STEP_EQU
* $INSERT WO_MAT_EQUATES
* $INSERT ORDER_EQU
* $INSERT RDS_EQUATES
* $INSERT PROD_SPEC_EQUATES
* $INSERT NOTIFICATION_EQU
* $INSERT LSL_USERS_EQU
* $INSERT SECURITY_RIGHTS_EQU
* $INSERT LOGICAL
* $INSERT RTI_LH_INFO_EQUATES
* $INSERT WO_MAT_QA_EQUATES
* $INSERT CUST_EPI_PART_EQUATES
* $INSERT PRS_STAGE_EQUATES
* $Insert RLIST_EQUATES
* $Insert CLEAN_INSP_EQUATES
* $Insert TOOL_PARMS_EQUATES
* $Insert SCHEDULE_EQU
* $Insert SCHED_DET_EQUATES
* $Insert SCHEDULER_EQUATES
* $Insert NCR_EQUATES
* $Insert REACT_RUN_EQUATES
* $Insert TOOL_EQUATES
* $Insert TOOL_LOG_EQUATES
* $Insert PM_EQUATES
* $Insert WO_WFR_EQUATES
* $Insert REVDOTNETEQUATES
* $Insert REACTOR_EQUATES
* $Insert RDS_TEST_EQUATES
* $Insert RUN_STAGE_WFR_EQUATES
* 
* // Reduce modes (for Select statement)
* Equ NEW_EXIST$ To 0 
* Equ NEXT_CUR$  To 1
* Equ ADD_EXIST$ To 2   
* 
* EQU COL$QA_MET_PHASE_MIN TO 17
* 
* Equ Tab$                    to \09\
* Equ CRLF$                   to \0D0A\
* Equ LF$                     to \0A\
* Equ Comma$                  to ','
* 
* $INSERT PRINTSETUP_EQUATES

Testing:
    
*    RTI_Set_Debugger(1, '')
*    on_off        = 1
*    t_flag        = 1
*    set_env(ENV_DEBUGGER_ENABLED$, on_off, t_flag)
*    debug
*    AttributeList = ENV_DEBUGGER_ENABLED$
*    DebuggerOn    = Get_Env(AttributeList)
*    DebuggerOn    = AttributeList

*    TickCount = GetTickCount()
*    Response  = 'Hello World2! Ticks: ':TickCount:' Debugger is off'
*    OSWrite Response on 'D:\tmp\HelloWorld2.txt'
*    
*    Response = Param1
    
return 

* Testing:
*    
*    TickCount = GetTickCount()
*    Response  = 'Hello World2! Ticks: ':TickCount
*    OSWrite Response on 'D:\tmp\HelloWorld2.txt'
*    
* return Response


* 
* LHInfo:
*    
*    Start_Window('MANAGE_REVLH_SERVER_DEBUG', '', '', '', '')
*    rslt  = rti_lh_info(CMD_SESSION_INFO$)
*    Stack = Retstack()
*    Yield()
*    WinYield()
*    
* return
* 
* SpecType:
*    
*    Messaging_Services('SendMessage', 'RunProcedure', 'Request', '', 'All', 'RTP27,COPY_RECORD_TO_SQL', '', '', '')
*    debug
*    Copy_Record_To_Sql('RDS_LAYER', '575735*L1', 1, 'RDS_LAYER*575735*L1*WRITE*20128*51623')
*    debug
*    Table = 'WO_LOG'
*    ID    = 171828
*    
*    Open 'DICT.SQL_PENDING' to pDict then
*        Query       = 'TABLE':@VM:Table:@FM:'RECORD':@VM:ID
*        PendingKeys = ''
*        Option      = ''
*        Flag        = ''
*        Btree.Extract(Query, 'SQL_PENDING', pDict, PendingKeys, Option, Flag)
*        If Flag EQ 0 then
*            If PendingKeys NE '' then
*                debug
*                Skip = True$
*            end
*        end
*    end
*    
*    Encoded = SRP_Encode('616735*L1', 'BASE64')
*    Key     = SRP_Decode(Encoded, 'BASE64')
*    Open 'DICT.SQL_PENDING' to Dictionary then
*        Keys = ''
*        Flag = ''
*        Btree.Extract('TABLE':@VM:'WO_LOG':@FM:'RECORD':@VM:171887, 'SQL_PENDING', Dictionary, Keys, '', Flag)
*        
*    end
*    
*    WaferSize		= XLATE( 'PROD_SPEC', 3511, 'SUB_WAFER_SIZE', 'X' )
*    SubOrientation	= XLATE('PROD_SPEC',3511,'SUB_ORIENTATION','X')
*    hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
*    Unlock hSysLists, 'Copy_Pending_Records_To_SQL' else Null
*    
*    Lock hSysLists, 'Copy_Pending_Records_To_SQL' then
*        Unlock hSysLists, 'Copy_Pending_Records_To_SQL' else Null
*    end
* 
*    
* return
* 
* 
* Wait:
*    
*        debug
*    KeyList = Xlate('SYSLISTS', 'TEST_DANIEL2', '', 'X')
*    
*    Counter          = 0
*    Def              = ""
*    Def<MCAPTION$>   = "Pushing WM_OUT data..."
*    Def<MTYPE$   >   = "GC"
*    Def<MEXTENT$ >   = DCount(KeyList, @FM)
*    Def<MTEXTWIDTH$> = 800
*    MsgUp            = Msg(@window, Def)
*    
*    For each Key in KeyList using @FM
*        Counter += 1
*        Msg(@window, MsgUp, Counter, MSGINSTUPDATE$)
*        WMOKeys  = Xlate('RDS', Key, 'WM_OUT_KEY', 'X')
*        If WMOKeys NE '' then
*            For each WMOKey in WMOKeys using @VM
*                Copy_Record_To_Sql('WM_OUT', WMOKey, 1)
*            Next WMOKey
*        end
*    Next Key
*    Msg(@window, MsgUp)         ;* take down the gauge
*    
* return
* 
* 
* FixRDSTestLimits:
* 
*    WONo = 171301
*    For CassNo = 41 to 70
*        WOMatKey = WONo:'*':CassNo
*        RDSNo    = Xlate('WO_MAT', WONo:'*':CassNo, 'RDS_NO', 'X')
*        If RDSNo NE '' then
*            PSN_Services('UpdateRDSMetrologyLimits', RDSNo)
*        end else
*            Msg(@Window, '', 'OK', '', 'Process Error':@FM:'Null RDSNo returned for WO_MAT record ':WOMatKey)
*        end
*        
*    Next CassNo
*    
* Return
* 
* 
* FixGaNRDS:
*    debug
*    // Fix REACT_RUN records
*    RDSList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL_BAD')
*    
*    Def              = ""
*    Def<MCAPTION$>   = "Fixing RDS records..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = DCount(RDSList, @FM)
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message    
*        
*    For each RDSNo in RDSList using @FM setting fPos
*        WriteRow  = False$
*        RRRec     = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
*        WfrStages = RRRec<REACT_RUN_WFR_STAGE$>
*        Locate 'PLATO' in WfrStages using @VM setting PlatoPos then
*            Locate 'CAN_PRE' in WfrStages using @VM setting CanPrePos then
*                If PlatoPos LT CanPrePos then
*                    // Move PLATO after CAN_PRE
*                    WfrStages                   = Insert(WfrStages, 0, CanPrePos + 1, 0, 'PLATO')
*                    WfrStages                   = Delete(WfrStages, 0, PlatoPos, 0)
*                    RRRec<REACT_RUN_WFR_STAGE$> = WfrStages
*                    WriteRow                    = True$
*                end
*            end
*        end
*        GaNStageRoute = RRRec<REACT_RUN_GAN_STAGE_ROUTE$>
*        Locate 'PLATO' in GaNStageRoute using @VM setting PlatoPos then
*            Locate 'CAN_PRE' in GaNStageRoute using @VM setting CanPrePos then
*                If PlatoPos LT CanPrePos then
*                    // Move PLATO after CAN_PRE
*                    GaNStageRoute                     = Insert(GaNStageRoute, 0, CanPrePos + 1, 0, 'PLATO')
*                    GaNStageRoute                     = Delete(GaNStageRoute, 0, PlatoPos, 0)
*                    RRRec<REACT_RUN_GAN_STAGE_ROUTE$> = GaNStageRoute
*                    WriteRow                          = True$
*                end
*            end
*        end
*        If WriteRow EQ True$ then Database_Services('WriteDataRow', 'REACT_RUN', RDSNo, RRRec, True$, False$, True$)
*        Running  = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
*    Next RDSNo
*    
*    Msg(@WINDOW,MsgUp)
*    
* return
* 
* FixGaNPSNs:
*    
*    debug
*    // Fix PROD_SPEC records
*    PSNList = Database_Services('ReadDataRow', 'SYSLISTS', 'GAN_PSNS')
*    
*    Def              = ""
*    Def<MCAPTION$>   = "Fixing PROD_SPEC records..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = DCount(PSNList, @FM)
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message    
*        
*    For each PSNo in PSNList using @FM setting fPos
*        PSNRec   = Database_Services('ReadDataRow', 'PROD_SPEC', PSNo)
*        PRSRoute = PSNRec<PROD_SPEC_PRS_STAGE_ROUTE$>
*        Locate 'PLATO' in PRSRoute using @VM setting PlatoPos then
*            Locate 'CAN_PRE' in PRSRoute using @VM setting CanPrePos then
*                If PlatoPos LT CanPrePos then
*                    // Move PLATO after CAN_PRE
*                    PRSRoute                           = Insert(PRSRoute, 0, CanPrePos + 1, 0, 'PLATO')
*                    PRSRoute                           = Delete(PRSRoute, 0, PlatoPos, 0)
*                    PSNRec<PROD_SPEC_PRS_STAGE_ROUTE$> = PRSRoute
*                    Database_Services('WriteDataRow', 'PROD_SPEC', PSNo, PSNRec, True$, False$, True$)
*                end
*            end
*        end
*        Running  = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
*    Next PSNo
*    
*    Msg(@WINDOW,MsgUp)
*    
* return
* 
* 
* CleanRepMan:
*    
*    Open 'REPLICATION_QUEUE_GLOBAL_PUBLIC' to TableHandle then
*        Select TableHandle
*        EOF = False$
*        Loop
*            ReadNext @ID else EOF = True$
*        Until EOF
*            If Not(Num(@ID)) and Not(Index(@ID, '%', 1)) then
*                Delete TableHandle, @ID then Null
*            end
*        Repeat
*    end
*    
*    
* return
* 
* Process:
*    
*    TableName    = 'RDS_QUEUE'
*    CursorVar    = ''
*    Flag         = ''
*    SortList     = '#RDS_NO'
*    ReduceScript = 'WITH {RDS_NO} FROM 460000 TO 479999'
*    Mode         = 1 ; // Use next cursor available
*    EOF          = False$
*    
*    Reduce(ReduceScript, SortList, Mode, TableName, CursorVar, Flag)
*    If Flag then
*        Select TableName By SortList Using CursorVar then
*            Loop 
*                Readnext KeyID using CursorVar by AT else EOF = True$
*            Until EOF
*                Material_Services('UpdateRDSStatus', KeyID)
*                If Error_Services('NoError') then
*                    // Successfully updated the current status, so delete the request from the queue.
*                    Database_Services('DeleteDataRow', 'RDS_QUEUE', KeyID, True$, True$)
*                end
*            Repeat
*        End else
*            status = Set_FSError()
*        end
*    end
*    
* return
* 
* 
* ScratchPad:
*    
*    
*    BadList     = ''
*    StartRDSKey = 400000
*    StopRDSKey  = Xlate('DICT.RDS', '%SK%', '', 'X') - 1
*    NumKeys     = StopRDSKey - StartRDSKey
*    Counter     = 0
*    
*    Def              = ""
*    Def<MCAPTION$>   = "Scanning RDS records..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = NumKeys
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
*    
*    For RDSNo = StartRDSKey to StopRDSKey
*        Counter       += 1
*        WOMatKey       = Xlate('RDS', RDSNo, 'WO_MAT_KEY', 'X')
*        MakeupBox      = Xlate('WO_MAT', WOMatKey, 'MAKEUP_BOX', 'X')
*        ReactorType    = Xlate('RDS', RDSNo, 'REACTOR_TYPE', 'X')
*        SAPBatchNo     = Xlate('WO_MAT', WOMatKey, 'SAP_BATCH_NO', 'X')
*        FullBoxReject  = (SAPBatchNo[-2, 2] EQ '.R')
*        If ( (MakeupBox NE True$) and (ReactorType NE 'EPP') and (ReactorType NE 'GAN') and (FullBoxReject EQ False$) ) then
*            InvLocs    = Xlate('WO_MAT', WOMatKey, 'INV_LOCATION', 'X')
*            InvActions = Xlate('WO_MAT', WOMatKey, 'INV_ACTION', 'X')
*            Locate 'PTO' in InvLocs using @VM setting vPos else
*                QASig     = Xlate('RDS', RDSNo, 'SUP_VER_SIG', 'X')
*                If QASig NE '' then
*                    BadList<-1> = RDSNo
*                end
*            end
*        end
*        Running = Msg(@WINDOW, MsgUp, Counter, MSGINSTUPDATE$) ;* Update message
*    Next RDSNo
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL5', BadList)
*    
*    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return
*    
*    
*    debug
*    WOMatQAKey             = '170194*1'
*    TypeOver               = ''
* 	TypeOver<PDISPLAY$, 1> = WOMatQAKey
* 	TypeOver<PDISPLAY$, 2> = WO_MAT_QA_SLOT$
* 	TypeOver<PMODE$>       = 'F'
*    SelKey                 = Popup(@Window, TypeOver, 'WO_MAT_QA_QUERY')
*    
** Code Generated from UI Workspace **
* 
*    Popup_Rec                 = ''
*    Popup_Rec<PCOL$>          = -1
*    Popup_Rec<PROW$>          = -1
*    Popup_Rec<PWIDTH$>        = -1
*    Popup_Rec<PHEIGHT$>       = -1
*    Popup_Rec<PBKCOLOR$>      = 16777215
*    Popup_Rec<PFONT$>         = 'Tahoma':@Svm:'-11':@Svm:'400':@Svm:'0':@Svm:'0':@Svm:'5':@Svm:'0':@Svm:'39':@Svm:'0':@Svm:'0':@Svm:'0':@Svm:'0':@Svm:'11':@Svm:'2':@Svm:'0':@Svm:'21'
*    Popup_Rec<PFILE$>         = ''
*    DisplayText               = ''
*    DisplayText              := '1':@Vm:'L'
*    Popup_Rec<PDISPLAY$>      = DisplayText
*    Popup_Rec<PFORMAT$>       = '1':@Svm:'5':@Svm:'C':@Svm:'C':@Svm:'':@Svm:'Slot':@Vm:'':@Svm:'':@Svm:'':@Svm:'':@Svm:'':@Svm:''
*    Popup_Rec<PMODE$>         = 'L'
*    Popup_Rec<PSELECT$>       = 1
*    Popup_Rec<PTITLE$>        = 'QA Metrology Lookup'
*    Popup_Rec<PFIELD$>        = ''
*    Popup_Rec<PTYPE$>         = "F"
*    Popup_Rec<PCOLHDR$>       = 1
*    Popup_Rec<PROWNUM$>       = 1
*    Popup_Rec<PROWBTN$>       = 1
*    Popup_Rec<PHGRID$>        = 1
*    Popup_Rec<PVGRID$>        = 1
*    Popup_Rec<PRESIZE$>       = 1
*    Popup_Rec<PBORDER$>       = 1
*    Popup_Rec<PBTNSBELOW$>    = 0
*    Popup_Rec<PSEARCH$>       = 0
*    Popup_Rec<PSORT$>         = 0
*    Popup_Rec<PLOCK$>         = 0
*    Popup_Rec<PSHOWMISSING$>  = 0
*    Popup_Rec<PPRINTABLE$>    = 0
*    Popup_Rec<PSHOWGAUGE$>    = 1
*    Popup_Rec<PCAPTUREESC$>   = 0
*    Popup_Rec<PGREENBAR$>     = 0
* 
*    x = Popup(@Window, Popup_Rec, '')
*    RetVal = Popup_Services('DisplayPopupLiteral', 'Select QA Met Slot', 'Slot', '1':@VM:'L', 1)
*    debug
* return
* 
* 
* CleanSched:
*    
*    For ReactNo = 40 to 52 Step 2
*        debug
*        ReactRec  = Database_Services('ReadDataRow', 'REACTOR', ReactNo)
*        SchedList = ReactRec<REACTOR_SCHED_EVENTS$>
*        For each SchedKey in SchedList using @VM setting vPos
*            Database_Services('DeleteDataRow', 'SCHED_DET_NG', SchedKey)
*        Next SchedKey
*        SchedList                       = ''
*        ReactRec<REACTOR_SCHED_EVENTS$> = SchedList
*        Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactRec)
*    Next ReactNo
*    
*    
*    
* return
* 
* 
* Compare:
*    
*    Headers          = 'Reactor Type':@VM:'PSN#':@VM:'Prod Ver No':@VM:'PSN MPW':@VM:'Epi Part No':@VM:'Epi Part MPW'
*    ReportList       = Headers
*    KeyList          = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL2')
*    Def              = ""
*    Def<MCAPTION$>   = "Building Report..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = DCount(KeyList, @FM)
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
*    KeyCounter       = 0
*    RowIndex         = 1
*    For each PSNo in KeyList using @FM setting KeyCounter
*        ReactType  = '' 
*        ProdVerNo  = ''
*        PSNMPW     = ''
*        EpiPartNo  = ''
*        EpiPartMPW = ''
*        Running    = Msg(@WINDOW, MsgUp, KeyCounter, MSGINSTUPDATE$) ;* Update message
*        ReactType  = Xlate('PROD_SPEC', PSNo, 'REACTOR_TYPE', 'X')
*        Locate ReactType in 'ASM,ASM+,HTR,EPP,GAN' using ',' setting vPos else
*            vPos = 0
*        end
*        PSNMPW      = OConv(Xlate('PROD_SPEC', PSNo, 'MINUTES_PER_WAFER', 'X'), 'MD3')
*        ProdVerNos  = Xlate('PROD_SPEC', PSNo, 'PROD_VER_NO', 'X')
*        If ProdVerNos NE '' then
*            For each ProdVerNo in ProdVerNos using @VM setting Dummy
*                EpiPartNo  = Xlate('PROD_VER', ProdVerNo, 'EPI_PART_NO', 'X')
*                EpiPartMPW = OConv(Xlate('EPI_PART', EpiPartNo, 'MINUTES_PER_WAFER_SCHEDULER', 'X'), 'MD3')
*                If vPos GT 0 then
*                    EpiPartMPW = EpiPartMPW<0, vPos>
*                end else
*                    EpiPartMPW = ''
*                end
*                RowIndex                += 1
*                ReportList<RowIndex, 1>  = ReactType
*                ReportList<RowIndex, 2>  = PSNo
*                ReportList<RowIndex, 3>  = ProdVerNo
*                ReportList<RowIndex, 4>  = PSNMPW
*                ReportList<RowIndex, 5>  = EpiPartNo
*                ReportList<RowIndex, 6>  = EpiPartMPW
*            Next ProdVerNo
*        end else
*            RowIndex                += 1
*            ReportList<RowIndex, 1>  = ReactType
*            ReportList<RowIndex, 2>  = PSNo
*            ReportList<RowIndex, 3>  = ProdVerNo
*            ReportList<RowIndex, 4>  = PSNMPW
*            ReportList<RowIndex, 5>  = EpiPartNo
*            ReportList<RowIndex, 6>  = EpiPartMPW
*        end
*    Next PSNo
*    
*    Swap @VM with ',' in ReportList
*    Swap @FM with CRLF$ in ReportList
*    Filepath = 'C:\Users\StieberD\Desktop\report.csv'
*    OSWrite ReportList on Filepath
*    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return
* 
* 
* Script:
*    
*    Headers           = 'Reactor':@VM:'Work Order':@VM:'Start':@VM:'Stop':@VM:'Cassettes':@VM:'Wafer Size':@VM
*    Headers          := 'PSN Target Thickness':@VM:'PSN#':@VM:'PSN MPW':@VM:'Epi Part MPW':@VM:'Epi WPD':@VM:'Epi WPDA':@VM:'Availablility'
*    ReportList        = Headers
*    BadKeyList        = ''
*    Query             = 'SELECT SCHED_DET_NG WITH STOP_DTM GT "11/03/2021"'
*    Set_Status(0)
*    RList(Query, TARGET_ACTIVELIST$, '', '', '')
*    NumKeys           = @RecCount
*    EOF               = False$
*    RowIndex          = 1
*    Def               = ""
*    Def<MCAPTION$>    = "Building Report..."
*    Def<MTYPE$>       = "GC"
*    Def<MEXTENT$>     = NumKeys
*    Def<MTEXTWIDTH$>  = 600
*    MsgUp             = Msg(@WINDOW, Def) ;* Start gas guage message
*    KeyCounter        = 0
*    If Not(Get_Status(ErrCode)) then
*        Loop
*            ReadNext KeyID else EOF = True$
*        Until EOF
*            KeyCounter += 1
*            Running     = Msg(@WINDOW, MsgUp, KeyCounter, MSGINSTUPDATE$) ;* Update message
*            Database_Services('ActivateRecord', 'SCHED_DET_NG', KeyID)
*            ReactNo     = {REACT_NO}
*            WONo        = {WO_NO}
*            If WONo NE '' then
*                ReactType      = Xlate('REACTOR', ReactNo, 'REACT_TYPE', 'X')
*                If ReactType EQ 'HTR' then
*                    RowIndex       += 1
*                    StartDTM        = OConv({START_DTM}, 'DT2/^H')
*                    StopDTM         = OConv({STOP_DTM}, 'DT2/^H')
*                    Cassettes       = ((Xlate('WO_LOG', WONo, 'QTY', 'X'))/25)
*                    WaferSize       = Xlate('WO_LOG', WONo, 'WAFER_SIZE', 'X')
*                    PSNo            = Xlate('WO_STEP', WONo:'*1', 'PROD_SPEC_ID', 'X')
*                    PSNTargetThick  = OConv(Sum(Xlate('PROD_SPEC', PSNo, 'THICK_TARGET_ALL', 'X')), 'MD3')
*                    PSNMPW          = OConv(Xlate('PROD_SPEC', PSNo, 'MINUTES_PER_WAFER', 'X'), 'MD3')
*                    EpiPartNo       = Xlate('PROD_SPEC', PSNo, 'EPI_PART_NO', 'X')
*                    EpiPartMPW      = OConv(Xlate('EPI_PART', EpiPartNo, 'MINUTES_PER_WAFER_SCHEDULER', 'X'), 'MD3')
*                    EpiPartMPW      = EpiPartMPW<0, 3>
*                    If EpiPartMPW NE '' then
*                        EpiWPD  = Epi_Part_Services('GetIdealWafersPerDayScheduler', EpiPartNo, ReactType, EpiPartMPW)
*                        EpiWPDA = Epi_Part_Services('GetAdjustedWafersPerDayScheduler', EpiPartNo, ReactType, EpiPartMPW)
*                    end else
*                        EpiWPD  = ''
*                        EpiWPDA = ''
*                    end
*                    Availability             = Epi_Part_Services('GetReactorUtilization', 'HTR')
*                    ReportList<RowIndex, -1> = 'R':ReactNo
*                    ReportList<RowIndex, -1> = WONo
*                    ReportList<RowIndex, -1> = StartDTM
*                    ReportList<RowIndex, -1> = StopDTM
*                    ReportList<RowIndex, -1> = Cassettes
*                    ReportList<RowIndex, -1> = WaferSize
*                    ReportList<RowIndex, -1> = PSNTargetThick
*                    ReportList<RowIndex, -1> = PSNo
*                    ReportList<RowIndex, -1> = PSNMPW
*                    ReportList<RowIndex, -1> = EpiPartMPW
*                    ReportList<RowIndex, -1> = EpiWPD
*                    ReportList<RowIndex, -1> = EpiWPDA
*                    ReportList<RowIndex, -1> = Availability
*                end
*            end else
*                BadKeyList<-1> = KeyID
*            end
*        Repeat
*    end
*    
*    Swap @VM with ',' in ReportList
*    Swap @FM with CRLF$ in ReportList
*    Filepath = 'C:\Users\StieberD\Desktop\report.csv'
*    OSWrite ReportList on Filepath
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL3', BadKeyList)
*    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return 
*    
*    Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$, 'TEST_DANIEL3', 1)
*    Set_Env(ENV_DEBUGGER_ENABLED$, 2, 1)
*    Result = 4/0
*    
*    
*    // cleanup
*    Set_Env(ENV_DEBUGGER_ENABLED$, 1, 1)
*    
* return
*    
*    
*    Open 'REPLICATION_QUEUE_LSL2_WO_MAT' to TableHandle then
*        Select TableHandle
*        EOF = False$
*        Loop
*            ReadNext @ID else EOF = True$
*        Until EOF
*            TransType = Field(@ID, '*', 1)
*            If TransType EQ 'WRITE' then
*                Delete TableHandle, @ID then Null
*            end
*        Repeat
*    end
*    
*    
*    
*    
*    
*    
*    
* return
* 
*    WONo     = 170528
*    CassNo   = 29
*    WOMatKey = WONo:'*':CassNo
*    WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*    GRProps  = obj_WO_Mat('GetGRProps', WOMatKey:@RM:WOMatRec)
*    GRWfrQty
*    ScrapQty
*    ProdTWQty
*    AvailMUWfrQty
*    MUCassIDs
*    MUCassQtys
*    
* return
* 
*    
*    483953
*    BadList     = ''
*    NextRDSKey  = 475000
*    StartRDSKey = 400000
*    StopRDSKey  = Xlate('DICT.RDS', '%SK%', '', 'X') - 1
*    NumKeys     = StopRDSKey - StartRDSKey
*    Counter     = 0
*    
*    Def              = ""
*    Def<MCAPTION$>   = "Scanning RDS records..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = NumKeys
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
*    
*    For RDSNo = StartRDSKey to StopRDSKey
*        Counter   += 1
*        WOMatKey   = Xlate('RDS', RDSNo, 'WO_MAT_KEY', 'X')
*        MakeupBox  = Xlate('WO_MAT', WOMatKey, 'MAKEUP_BOX', 'X')
*        If MakeupBox NE True$ then
*            InvLocs    = Xlate('WO_MAT', WOMatKey, 'INV_LOCATION', 'X')
*            InvActions = Xlate('WO_MAT', WOMatKey, 'INV_ACTION', 'X')
*            Locate 'PTO' in InvLocs using @VM setting vPos else
*                QASig     = Xlate('RDS', RDSNo, 'SUP_VER_SIG', 'X')
*                If QASig NE '' then
*                    BadList<-1> = RDSNo
*                end
*            end
*        end
*        Running = Msg(@WINDOW, MsgUp, Counter, MSGINSTUPDATE$) ;* Update message
*    Next RDSNo
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL5', BadList)
*    
*    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return
* 
* 
* Fixit:
*    debug
*    Timestamp = Datetime()
*    ErrorList = ''
*    KeyList   = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL4')
*    NumKeys   = DCount(KeyList, @FM)
*    
*    Def              = ""
*    Def<MCAPTION$>   = "Fixing Material Log Entries..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = NumKeys
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
*    
*    For each RDSNo in KeyList using @FM setting fPos
*        RDSNo    = Xlate('WO_MAT', WOMatKey, 'RDS_NO', 'X')
*        WOMatKey = Xlate('RDS', RDSNo, 'WO_MAT_KEY', 'X')
*        If WOMatKey NE '' then
*            WOMatRec   = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*            InvActions = WOMatRec<WO_MAT_INV_ACTION$>
*            Locate '1QA' in InvActions using @VM setting vPos else
*                Locate 'LBLCHK' in InvActions using @VM setting vPos then
*                    QASig                          = Xlate('RDS', RDSNo, 'SUP_VER_SIG', 'X')
*                    QASigTime                      = Xlate('RDS', RDSNo, 'SUP_VER_SIG_TIME', 'X')
*                    QASigDate                      = Xlate('RDS', RDSNo, 'SUP_VER_SIG_DATE', 'X')
*                    QASigDTM                       = QASigDate + (QASigTime/86400)
*                    WOMatRec<WO_MAT_INV_ACTION$>   = Insert(WOMatRec<WO_MAT_INV_ACTION$>, 0, vPos, 0, '1QA')
*                    WOMatRec<WO_MAT_INV_WH$>       = Insert(WOMatRec<WO_MAT_INV_WH$>, 0, vPos, 0, 'CR')
*                    WOMatRec<WO_MAT_INV_LOCATION$> = Insert(WOMatRec<WO_MAT_INV_LOCATION$>, 0, vPos, 0, 'QA')
*                    WOMatRec<WO_MAT_INV_USER$>     = Insert(WOMatRec<WO_MAT_INV_USER$>, 0, vPos, 0, 'OI ADMIN')
*                    WOMatRec<WO_MAT_INV_DTM$>      = Insert(WOMatRec<WO_MAT_INV_DTM$>, 0, vPos, 0, Timestamp)
*                    WOMatRec<WO_MAT_INV_TAG$>      = Insert(WOMatRec<WO_MAT_INV_TAG$>, 0, vPos, 0, '')
*                    WOMatRec<WO_MAT_INV_TOOL_ID$>  = Insert(WOMatRec<WO_MAT_INV_TOOL_ID$>, 0, vPos, 0, '')
*                    
*    *                WOMatRec<WO_MAT_INV_ACTION$, -1>   = 'PLACE'
*    *                WOMatRec<WO_MAT_INV_WH$, -1>       = '1K'
*    *                WOMatRec<WO_MAT_INV_LOCATION$, -1> = 'PTI'
*    *                WOMatRec<WO_MAT_INV_USER$, -1>     = 'OI_ADMIN'
*    *                WOMatRec<WO_MAT_INV_DTM$, -1>      = Timestamp
*    *                WOMatRec<WO_MAT_INV_TAG$, -1>      = RDSNo
*    *                WOMatRec<WO_MAT_INV_TOOL_ID$, -1>  = ''
*                    
*                    Database_Services('WriteDataRow', 'WO_MAT', WOMatKey, WOMatRec, True$, False$, True$)
*                    If Error_Services('HasError') then
*                        ErrorList<-1> = RDSNo
*                    end
*                end
*            end
*        end else
*            ErrorList<-1> = RDSNo
*        end
*        Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
*    Next WOMatKey
*    
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL_ERROR', ErrorList)
*    
*    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return
* 
*    debug
*    WOMatKey = '170542*30'
*    // Write success packaging
*    LogFile  = 'WO_MAT'               
*    Action   = 'PACK'                
*    WhCd     = 'CR'
*    LocCd    = 'PACK'
*    UserID   = @User4
*    Tag      = 'Packaging complete'
*    ToolID   = ''
*        
*    WONo    = Field(WOMatKey, '*', 1, 1)
*    CassNo  = Field(WOMatKey, '*', 2, 1)
*        
*    InvDTM		= OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')	        
*    Set_Status(0)
*    aiParms	= 'WO_MAT':@RM:WONo:@RM:CassNo:@RM:WhCd:'*':LocCd:@RM:Action:@RM:InvDTM:@RM:UserID:@RM:Tag:@RM:ToolID
*    obj_WO_Mat('AddInvTrans', aiParms)
*    If Get_Status(errCode) then
*        debug
*        Null
*    end
*    
* return
* 
* Script:
*    
*    WOMatKey = '170599*2'
*    LogFile  = 'WO_MAT'               
*    Action   = 'PLACE'                
*    WhCd     = 'CR'
*    LocCd    = 'QA'
*    UserID   = @User4
*    Tag      = '170599.2'
*    ToolID   = ''
*    errCode  = ''
*    WONo     = Field(WOMatKey, '*', 1, 1)
*    CassNo   = Field(WOMatKey, '*', 2, 1)       
*    InvDTM   = OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')
*    
*    WOMLParms  = LogFile:@RM
*    WOMLParms := InvDTM:@RM
*    WOMLParms := Action:@RM
*    WOMLParms := WhCd:@RM
*    WOMLParms := LocCd:@RM
*    WOMLParms := WONo:@RM
*    WOMLParms := CassNo:@RM
*    WOMLParms := UserID:@RM
*    WOMLParms := Tag:@RM
*    WOMLParms := ToolID 
*    
*    Set_Status(0)
*    obj_WO_Mat_Log('Create',WOMLParms)
*    
*    aiParms	= 'WO_MAT':@RM:WONo:@RM:CassNo:@RM:WhCd:'*':LocCd:@RM:Action:@RM:InvDTM:@RM:UserID:@RM:Tag:@RM:ToolID
*    obj_WO_Mat('AddInvTrans', aiParms)
*    
*    errCode = ''                   
* 
*    IF Get_Status(errCode) THEN
*        debug
*    end
*    
* return
* 
* Script:
* debug
*    BadList = ''
*    RDSNos  = 482815:@FM ; //Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL_LIST')
*    For each RDSNo in RDSNos using @FM setting fPos
*        WfrIDs = Xlate('REACT_RUN', RDSNo, 'IN_WFR_ID', 'X')
*        For each WfrID in WfrIDs using @VM setting vPos
*            GaN_Services('WithdrawWfr', RDSNo, WfrID)
*        Next WfrID
*        GaN_Services('SplitSelection', RDSNo)
*        ReactRunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
*        If Error_Services('NoError') then
*            ReactRunRec<REACT_RUN_DISP_COMPLETE$> = ''
*            Database_Services('WriteDataRow', 'REACT_RUN', RDSNo, ReactRunRec, True$, False$, True$)
*            If Error_Services('HasError') then
*                BadList<-1> = RDSNo
*            end
*        end else
*            BadList<-1> = RDSNo
*        end
*    Next RDSNo
* 
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL_ERROR', BadList)
*    
*    
* return
*    
* 
* 
* return
* 
*    OPEN 'SCHED_DET_NG' TO SchedDetTable then
*        OPEN 'DICT.SCHED_DET_NG' TO @DICT then
*            Today        = Datetime()
*            SchedDetKeys = ''
*            SelectSent   = 'SELECT SCHED_DET_NG WITH STOP_DTM GE ':Today:' BY REACT_NO'
* 
*            RList(SelectSent,TARGET_ACTIVELIST$,'','','')
*            IF Get_Status(errCode) THEN
*                ErrMsg(errCode)
*                RETURN
*            END
* 
*            Done = 0
*            @ID  = ''
*            LOOP
*                PrevSchedDetKey = @ID
*                READNEXT @ID ELSE Done = 1
*            UNTIL Done
*                SchedDetKeys<-1> = @ID
*            REPEAT
*            Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL2', SchedDetKeys)
*        end
*    end
*    
*    
* return
* 
*    WONo    = 170326
*    For CassNo = 1 to 76 step 1
*        WOMatKey                  = WONo:'*':CassNo
*        WOMatRec                  = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*        WOMatRec<WO_MAT_WMI_KEY$> = WONo:'*1*':CassNo
*        WOMatRec<WO_MAT_WMO_KEY$> = WONo:'*1*':CassNo
*        Database_Services('WriteDataRow', 'WO_MAT', WOMatKey, WOMatRec, True$, False$, True$)
*    Next CassNo
*    
*    
*    KeyList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL4')
*    For each RDSNo in KeyList using @FM
*        
*        RDSTestKeys = Xlate('RDS', RDSNo, 'RDS_TEST_KEYS', 'X')
*        If RDSTestKeys NE '' then
*            For each RDSTestKey in RDSTestKeys using @VM
*                RDSTestRec                             = Database_Services('ReadDataRow', 'RDS_TEST', RDSTestKey)
*                RDSTestRec<RDS_TEST_SPEC_RES_MRECIPE$> = 'LSL_8IN'
*                Database_Services('WriteDataRow', 'RDS_TEST', RDSTestKey, RDSTestRec)
*            Next RDSTestKey
*        end
*        
*    Next RDSNo
*    
*    CtrlVer = 1.2
*    Msg(@Window, '', 'OK', '', 'Control Version':@FM:CtrlVer)
*    *Version = SRP_Get_FileVersion("D:\apps\OICurrent\SRPControls.ocx")
*    Version = SRP_Get_FileVersion("C:\Program Files (x86)\RevSoft\OIClient\SRPControls.ocx")
*    
* return 
*    
*    CutoffDate = Date() - 912 ; // 2.5 years
*    RemoveList = ''
*    KeyList    = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
*    For each WOMatKey in KeyList using @FM setting fPos
*        
*        WONo      = Field(WOMatKey, '*', 1)
*        WOEntryDt = Xlate('WO_LOG', WONo, 'ENTRY_DATE', 'X')
*        If WOEntryDt LT CutoffDate then
*            RemoveList<-1> = WOMatKey
*        end
*        
*        ReactType = Xlate('WO_MAT', WOMatKey, 'REACTOR_TYPE', 'X')
*        If ReactType EQ 'EPP' then
*            
*        end else
*            RDSNo      = Xlate('WO_MAT', WOMatKey, 'RDS_NO', 'X')
*            DateOut    = Xlate('RDS', RDSNo, 'DATE_OUT', 'X')
*            CutoffDate = Date() - 730
*            If ( (DateOut LT CutoffDate) or (DateOut EQ '') ) then
*                // Old makeup cassette 
*            end
*        end
*        
*    Next WOMatKey
*    
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL2', RemoveList)
*    
* return
* 
*    
*    WOMatKey = '170484*9'
*    WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*    debug
*    GRProps  = obj_WO_Mat('GetGRProps',WOMatKey:@RM:WOMatRec)
*    
*    WMOKey     = '170328*1*62'
*    WMORec     = Database_Services('ReadDataRow', 'WM_OUT', WMOKey)
*    CurrStatus = obj_WM_Out('CurrStatus', WMOKey:@RM:WMORec)
*    RepStatus  = Xlate('WM_OUT', WMOKey, 'REP_STATUS', 'X')
*    
*    
*    WOMatKey  = '170328*62'
*    WOMatRec  = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*    RepStatus = obj_WO_Mat('ReportStatus', WOMatKey:@RM:WOMatRec)
* 
*    WOStepKey = '170422*1'
*    LoadCount = Sum(Xlate('WO_STEP', WOStepKey, 'ALL_RDS_WFRS_EPI_LOAD', 'X'))
*    WONo      = 170328
*    EventWfrs = 444
*    WOQty     = Xlate('WO_LOG', WONo, 'QTY', 'X')
*    FirstWfr  = (WOQty - EventWfrs) / 25
*    FirstWfr  = FirstWfr[-1, 'B.']
*    FirstWfr  = (FirstWfr * .25) + 1
*    
* return
* 
* 
*    StartDate = Date() - 1
*    EndDate   = Date() - 1
* 
*    For Date = StartDate to EndDate Step 1
*        
*        Reactor_Services('ClearWafersExpected', OConv(Date, 'D'))
*        Reactor_Services('ClearWafersProcessed', OConv(Date, 'D'))
*        Reactor_Services('CreatePerformanceTrackers', OConv(Date, 'D'), True$)
*        Reactor_Services('UpdatePerformanceTrackers', OConv(Date, 'D'), True$)
*        
*    Next Date
*    
*    
*    For Date = StartDate to EndDate Step 1
*        
*        Reactor_Services_Dev('ClearWafersExpectedDev', OConv(Date, 'D'))
*        Reactor_Services_Dev('ClearWafersProcessedDev', OConv(Date, 'D'))
*        Reactor_Services_Dev('CreatePerformanceTrackersDev', OConv(Date, 'D'), True$)
*        Reactor_Services_Dev('UpdatePerformanceTrackersDev', OConv(Date, 'D'), True$)
*        
*    Next Date
* 
*    ZombieList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
*    For each EventID in ZombieList using @FM setting fPos
*        Database_Services('DeleteDataRow', 'SCHED_DET_NG', EventID, True$, False$)
*    Next EventID
* 
* 
*    
*    RDSList     = ''
*    RDSList<-1> = 469318
*    RDSList<-1> = 469320
*    RDSKey      = Dialog_Box('NDW_RDS_QUERY', @Window, RDSList)
*    Debug
*    Messaging_Services('SendMessage', 'RefreshSchedule', 'Response', '', 'All', '', 'EventHandler', 'SCHEDULER_DEV' : ',OMNIEVENT,@MESSAGE,@ARGUMENTS')
*    EOF   = False$
*    Query = 'SELECT WO_SCHEDULE_NG WITH UNSCHED_QTY EQ 0'
*    RList(Query, TARGET_ACTIVELIST$, '', '', '')
*    Loop
*        Readnext WOLogKeyID else EOF = True$
*    Until EOF = True$
*        Database_Services('DeleteDataRow', 'WO_SCHEDULE_NG', WOLogKeyID)
*    Repeat 
*    
*    
*    WOMatKey = Xlate('RDS', 469320, 'WO_MAT_KEY', 'X')
*    WOMatKey = Xlate('RDS', 469318, 'WO_MAT_KEY', 'X')
*    
*    RType = Xlate('RDS', 469320, 'REACTOR_TYPE', 'X')
*    RType = Xlate('RDS', 469318, 'REACTOR_TYPE', 'X')
*    
*    RxList = Reactor_Services('GetReactorNumbers')
*    For each Reactor in RxList using @FM setting vPos
*        
*        ReactRec = Database_Services('ReadDataRow', 'REACTOR', Reactor)
*        If ReactRec NE '' then
*            ReactRec<REACTOR_SCHED_EVENTS$> = ''
*            Database_Services('WriteDataRow', 'REACTOR', Reactor, ReactRec, True$, False$, True$)
*        end
*        
*    Next Reactor
*    
* return
*    
*    KeyList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
*    
*    Def              = ""
*    Def<MCAPTION$>   = "Populating Test Wafer Data..."
*    Def<MTYPE$>      = "GC"
*    Def<MEXTENT$>    = Dcount(KeyList, @FM)
*    Def<MTEXTWIDTH$> = 600
*    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
*    
*    For each RDSNo in KeyList using @FM setting fPos
*        
*        ReactRunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
*        Database_Services('WriteDataRow', 'REACT_RUN', RDSNo, ReactRunRec, True$, False$, True$)
*        Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
*    Next RDSNo
*        
*    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return
* 
* 
* TestRevDotNetCommon:
*   
*    //Define the dotNet version
*    RevDotNetCommon  = ''
*    DotNetHandle = StartDotNet("", '', RevDotNetCommon)
*    
*    DotNetDir = CheckDotNet('4.0'):'\'
*    SqlClientDLLPath = DotNetDir:'System.Data.dll'
*    ConnectionString = 'Password=mesa@1234@IQSDMS1!0987;Persist Security Info=True;User ID=IQSDMS1;Initial Catalog=G4Wafers_01;Data Source=messv01ec.ec.local\PROD1,53959'
*    //Specify the DLL
*    rv = Set_Property.NET(DotNetHandle, "AssemblyName", SqlClientDLLPath, RevDotNetCommon)
*    //Define the classes
*    SqlConnectionObj = Create_Class.NET(DotNetHandle, "System.Data.SqlClient.SqlConnection", 0, ConnectionString, 'System.String', RevDotNetCommon)
*    IF Get_Status(errCode) THEN
*        ErrMsg(errCode)
*    END else
*        mthds = Get_Info.Net(SqlConnectionObj, REVDOTNET_INFO_METHODS, RevDotNetCommon)
*        Set_Status(0)
*        rv = Send_Message.Net(SqlConnectionObj, "Open", RevDotNetCommon)
* 
*        IF Not(Get_Status(errCode)) THEN
*            ConnectionState = Get_Property.Net(SqlConnectionObj, "State", RevDotNetCommon)
*            
*            If ConnectionState EQ 'Open' then
*                SQLStatement  = "select [Probe_Key] from [G4Wafers_01].[dbo].[Probe3]"
*                Params        = SQLStatement:@FM:SqlConnectionObj
*                ParamTypes    = 'System.String':@FM:'RevDotNet'
*                Set_Status(0)
*                SqlCommandObj = Create_Class.NET(DotNetHandle, "System.Data.SqlClient.SqlCommand", 0, Params, ParamTypes, RevDotNetCommon)
*                If Not(Get_Status(errCode)) then
*                    SqlCommandMethods = Get_Info.Net(SqlCommandObj, REVDOTNET_INFO_METHODS)
*                    Set_Status(0)
*                    ProbeKey = Send_Message.Net(SqlCommandObj, "ExecuteScalar", RevDotNetCommon)
*                    If Not(Get_Status(errCode)) then
*                        If ( (ProbeKey NE 0) and (ProbeKey NE '') ) then
*                            NewProbeKey = ProbeKey + 1
*                            SQLStatement = 'update [G4Wafers_01].[dbo].[Probe3] set [Probe_Key] = ':NewProbeKey:' where [Probe_Key] = ':ProbeKey
*                            Set_Status(0)
*                            rv = Set_Property.NET(SqlCommandObj, "CommandText", SQLStatement, RevDotNetCommon)
*                            If Not(Get_Status(errCode)) then
*                                Set_Status(0)
*                                rv = Send_Message.Net(SqlCommandObj, "ExecuteNonQuery", RevDotNetCommon)
*                                If Not(Get_Status(errCode)) then
*                                    // Verify Probe Key was updated
*                                    SQLStatement = "select [Probe_Key] from [G4Wafers_01].[dbo].[Probe3]"
*                                    Set_Status(0)
*                                    rv = Set_Property.NET(SqlCommandObj, "CommandText", SQLStatement, RevDotNetCommon)
*                                    If Not(Get_Status(errCode)) then
*                                        Set_Status(0)
*                                        VerifyProbeKey = Send_Message.Net(SqlCommandObj, "ExecuteScalar", RevDotNetCommon)
*                                        If Not(Get_Status(errCode)) then
*                                            If VerifyProbeKey NE NewProbeKey then
*                                                // Log error 
*                                            end
*                                        end
*                                    end
*                                end
*                            end
*                        end else
*                            // Log error
*                        end
*                    end
*                end
*                rv = Send_Message.Net(SqlConnectionObj, 'Close', RevDotNetCommon)
*                ConnectionState = Get_Property.Net(SqlConnectionObj, "State", RevDotNetCommon)
*            end
*        end
*    end
*    Free_Class.Net('', RevDotNetCommon)
*    
* return
* 
* 
* Main:
* 
*    
*    objConnection = SQL_Services('GetConnectionObject', 'SPC')
*    
*    If objConnection then
*        
*        Query = "select [Probe_Key] from [G4Wafers_01].[dbo].[Probe2]"
*        SQL_Services('ExecuteQuery', objConnection, Query, True$)
*        
*        SQL_Services('DestroyConnectionObject', objConnection)
*    end
*    
*    
*    
* return
* 
* 
* 
* 
* Test5:
* 
*    ConnString = Database_Services('ReadDataRow', 'SERVERS', 'SPC')
*    ConnString = Delete(ConnString, 2, 0, 0)
*    ProviderIdx = IndexC(ConnString, 'Provider', 1)
*    ConnString = ConnString[(ProviderIdx + 1), 999]
*    ProviderEndIdx = Index(ConnString, ';', 1)
*    ConnString = ConnString[(ProviderEndIdx + 1), 999]
*    CIKey = 2409742
*    InspReq = Xlate('CLEAN_INSP', CIKey, 'SPEC_INSP_REQ', 'X')
*    If InspReq EQ '' then InspReq = Xlate('CLEAN_INSP', CIKey, 'INSP_REQ', 'X')
* 
*    InspFreq = Xlate('CLEAN_INSP', CIKey, 'INSP_INTERVAL', 'X')
*    If InspFreq NE '' then
*        // Use the stored interval
*        RDSNo        = Xlate('CLEAN_INSP', CIKey, 'RDS_NO', 'X')
*        PSNo         = Xlate('CLEAN_INSP', CIKey, 'PS_NO', 'X')
*        WONo         = Xlate('CLEAN_INSP', CIKey, 'WO_NO', 'X')
*        WOQty        = Xlate('WO_LOG', WONo, 'QTY', 'X')
*        RunNo        = Xlate('RDS', RDSNo, 'RUN_ORDER_NUM', 'X')
*        StageKey     = PSNo:'*LWI'
*        InspInterval = Xlate('PRS_STAGE', StageKey, 'INSP_INTERVAL', 'X')
*        LastRun      = ( (RunNo * 25) EQ WOQty )
*        InspReq      = ( (Mod((RunNo - 1), InspInterval) EQ 0) or LastRun )
*    end else
*        // Use the current PRS_STAGE interval
*        InspReq = Xlate('CLEAN_INSP', CIKey, 'INSP_REQ', 'X')
*    end
*    
* return
* 
* 
* Export:
*    
*    NonEppList = ''
*    WOMatList  = Database_Services('ReadDataRow', 'SYSLISTS', 'NULL_RDS_NON_EPP')
*    
*    For each WOMatKey in WOMatList using @FM setting fPos
*        
*        ReactorType = Xlate('WO_MAT', WOMatKey, 'REACTOR_TYPE', 'X')
*        If ReactorType NE 'EPP' and ReactorType NE 'GAN' then
*            NonEppList<-1> = WOMatKey
*        end
*    Next WOMatKey
*    
*    Database_Services('WriteDataRow', 'SYSLISTS', 'NULL_RDS_NON_EPP', NonEppList)
*    
*    NonEppList = Database_Services('ReadDataRow', 'SYSLISTS', 'NULL_RDS_NON_EPP')
*    Swap @FM with CRLF$ in NonEppList
*    OSWrite NonEppList on 'C:\Users\StieberD\Desktop\null-rds-non-epp.csv'
*    
*    
*    
* return
* 
* 
* 
* 
* WOMatPush:
*    
*    *    WOMatKeyList = Database_Services('ReadDataRow', 'SYSLISTS', 'FABTIME_PUSH')
*    *    
*    *    NumWOMatKeys = DCount(WOMatKeyList, @FM)
*    *    
*    *    Def               = ""
*    *    Def<MCAPTION$>    = "Updating WO_MAT..."
*    *    Def<MTYPE$>       = "GC"
*    *    Def<MEXTENT$>     = NumWOMatKeys
*    *    Def<MTEXTWIDTH$>  = 600
*    *    MsgUp             = Msg(@WINDOW, Def) ;* Start gas guage message
*    *    Table             = 'WO_MAT'
*    *    WOMatKeyListIndex = 1
*    *    NewWOMatKeyList   = WOMatKeyList
*    *    Loop
*    *        ID                 = WOMatKeyList<WOMatKeyListIndex>
*    *        Copy_Record_To_SQL(Table, ID, 1)
*    *        NewWOMatKeyList    = Delete(NewWOMatKeyList, 1, 0, 0)
*    *        WOMatKeyListIndex += 1
*    *        Database_Services('WriteDataRow', 'SYSLISTS', 'FABTIME_PUSH', NewWOMatKeyList)
*    *        Running            = Msg(@WINDOW, MsgUp, WOMatKeyListIndex, MSGINSTUPDATE$) ;* Update message
*    *    Until WOMatKeyListIndex GE NumWOMatKeys
*    *    Repeat
*    *    
*    *    Msg(@WINDOW,MsgUp)      ;* Take message down
*    
* return
*    
*    
* TaskSubmit:
*    
*    TaskID = RTI_Task_Submit('', 'TEST_DANIEL', '', '', '', '')
*    
*    If TaskID NE 0 then
*        Done         = False$
*        TaskResponse = ''
*        Loop
*            Status      = RTI_Task_Status(TaskID, TaskResponse)
*            If (Status EQ 'COMPLETED') OR (Status EQ 'ERROR') then Done = True$
*        Until Done
*        Repeat
*    end else
*        // Track if task id wasn't created at all.
*    end
*    StatusError = Get_Status(errCode)
*    If (Index(errCode, 'SHELLEXECUTE', 1)) NE 0 then StatusError = 0
* 
* 
* return
* 
*    retval = Utility("PRINTSETUP")
* 
*    IF NOT(ASSIGNED(PrinterID))		THEN PrinterID = ''
*    IF NOT(ASSIGNED(RetDefault))	THEN RetDefault = ''
* 
*    Printers	= ''
*    Default		= ''
* 
*        //PrintCount	= PrintSetupNew(Printers,Default)	;* OI routine returns printer names, driver, port information
*    //end else
*        PrintCount	= PrintSetup(PRN_GET$,'',Printers,Default)	;* OI routine returns printer names, driver, port information
*    //end
* 
*    DefPrinter	= Default[1,',']
*    DefPort		= FIELD(Default,',',3)
*    DefLine		= DefPrinter:' on ':DefPort
*    
*    If Default NE 'Microsoft XPS Document Writer,winspool,Ne00:' then
*        Null
*        PrintSetup(PRN_SET$, 'Microsoft XPS Document Writer,winspool,Ne00:')
*    end
* 
* return
* 
* 
*    // Import 6 inch Excel spreadsheet
*    
*    RetainFilepath    = 'D:\Apps\Temp\6in-IFEPI GaN Retain Inventory.xlsx'
*    RetainFilepath    = 'D:\Apps\Temp\8in-IFEpi GaN Retain Inventory.xlsx'
*    RetainFilepath    = 'D:\Apps\Temp\Sample.xlsx'
*    RetainExcelHandle = Excel_Services('OpenDocument', RetainFilepath)
*    RetainWorksheet   = 'Sheet1'
*    NumExcelRows      = Excel_Services('GetNumRows', RetainExcelHandle, RetainWorksheet)
*    
*    Open 'DICT.REACT_RUN' to @DICT then
*        For ExcelRow = 2 to NumExcelRows
* 
*            RunID        = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'A', ExcelRow) )
*            Convert @Upper.Case to @Lower.Case in RunID
*            RDSNo        = ''
*            Column       = 'GAN_RUN_ID'
*            SearchString = Column:@VM:RunID:@FM
*            Btree.Extract(SearchString, 'REACT_RUN', @DICT, RDSNo)
*            If RDSNo NE '' then
*                ReactRunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
*                If Error_Services('NoError') then
*                    RRRecipe  = ReactRunRec<REACT_RUN_GAN_RECIPE$>
*                    RRPart    = Xlate('REACT_RUN', RDSNo, 'EPI_PART_NO', 'X')
*                    RRScribes = Xlate('REACT_RUN', RDSNo, 'WFR_SCRIBES', 'X')
*                    InWfrIDs  = ReactRunRec<REACT_RUN_IN_WFR_ID$>
* 
*                    * Read the data from the Excel retain spreadsheet *
*                    Recipe     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'B', ExcelRow) )                    
*                    Pocket     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'C', ExcelRow) )
*                    If Pocket _NEC 'ref' then                 
*                        Scribe     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'D', ExcelRow) )                   
*                        Grade      = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'E', ExcelRow) )                    
*                        Part       = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'F', ExcelRow) )                    
*                        WorkOrder  = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'G', ExcelRow) )
*                        RetainBox  = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'H', ExcelRow) )                   
*                        RetainSlot = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'I', ExcelRow) )
*                        Operator   = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'J', ExcelRow) )
*                        RetainDTM  = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'K', ExcelRow) )
*                        CurrLoc    = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'L', ExcelRow) )                   
*                        Status     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'M', ExcelRow) )
*                        Comment    = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'N', ExcelRow) )
* 
*                        Begin Case
*                            Case Operator _EQC 'AH'
*                                RetainSig = 'ANTHONY_H'                          
*                            Case Operator _EQC 'SB'
*                                RetainSig = 'SYEDA_B'
*                            Case Operator _EQC 'PM'
*                                RetainSig = 'PEYTON_M'
*                            Case Operator _EQC 'JL'
*                                RetainSig = 'JAVIER_L'
*                            Case Operator _EQC 'PS'
*                                RetainSig = 'PRISCILA_S'
*                            Case Operator _EQC 'NC'
*                                RetainSig = 'NIKOLAS_C'
*                            Case Operator _EQC 'HG'
*                                RetainSig = 'HECTOR_G'
*                            Case Operator _EQC 'ES'
*                                RetainSig = 'ESTEBAN_S'
*                            Case Operator _EQC 'AD'
*                                RetainSig = 'ALIYAH_D'
*                            Case Operator _EQC 'LB'
*                                RetainSig = 'LACEY_B'
*                            Case Operator _EQC 'IP'
*                                RetainSig = 'IAN_P'
*                            Case Operator _EQC 'RC'
*                                RetainSig = 'RYAN_C'
*                            Case Operator _EQC 'GR'
*                                RetainSig = 'GEORGE_R'
*                            Case Operator _EQC 'AH/JL'
*                                RetainSig = 'ANTHONY_H'
*                            Case Operator _EQC 'NC/JL'
*                                RetainSig = 'NIKOLAS_C'
*                            Case Operator _EQC 'SW'
*                                RetainSig = 'STEVEN_W'
*                            Case Otherwise$
*                                RetainSig = ''
*                        End Case
*                        
*                        // Truncate DTM to just the date, then convert to internal format
*                        RetainDate = RetainDTM[1, 'F ']
*                        RetainDate = IConv(RetainDate, 'D')
*                        
*                        * Clean the data *                    
*                        // Format the Recipe
*                        Convert @Lower.Case to @Upper.Case in Recipe
*                        // Format the Pocket                    
*                        If Pocket[1, 1] NE '0' then Pocket = '0':Pocket
*                        // Format the Scribe
*                        Convert @Lower.Case to @Upper.Case in Scribe
*                        // Format the Grade
*                        Begin Case
*                            Case Grade _EQC 'aborted'
*                                Grade = 'Aborted'
*                            Case Grade _EQC 'CT'
*                                Grade = 'CT'
*                            Case ( (Grade _EQC 'Eng  test') or (Grade _EQC 'Eng test') or (Grade _EQC 'Engtest') or (Grade _EQC 'Test') )
*                                Grade = 'Eng Test'
*                            Case Grade _EQC 'Eq Failure'
*                                Grade = 'EQ Failure'
*                            Case Grade _EQC 'Mechanical'
*                                Grade = 'Mechanical'
*                            Case Grade _EQC 'NA'
*                                Grade = 'NA'
*                            Case Grade _EQC 'retain'
*                                Grade = 'Retain'
*                            Case Grade _EQC 'scrap'
*                                Grade = 'Scrap'
*                            Case Grade _EQC 'Terminated'
*                                Grade = 'Terminated'
*                            Case Grade _EQC ''
*                                Grade = ''
*                            Case Otherwise$
*                                Null
*                        End Case
*                        // Format the Part No
*                        Convert @Lower.Case to @Upper.Case in Part
*                        // Format the Current Location
*                        Begin Case
*                            Case CurrLoc _EQC 'Cleanroom'
*                                CurrLoc = 'Cleanroom'
*                            Case ( (CurrLoc _EQC 'Wafer Destroyed') or (CurrLoc _EQC 'Wafers Destroyed') or (CurrLoc _EQC 'Wasfer Destroyed') )
*                                CurrLoc = 'Wafer Destroyed'
*                            Case CurrLoc _EQC 'Warehouse'
*                                CurrLoc = 'Warehouse'                        
*                        End Case
*                        
*                        * Write the data to the WO_WFR record *
*                        WfrIndex = Pocket + 0 ; // Convert string to integer and trim 0 padding
*                        
*                        RRScribe = RRScribes<0, WfrIndex>  
*                        WfrID = InWfrIDs<0, WfrIndex>
*                        WOWfrRec = Database_Services('ReadDataRow', 'WO_WFR', WfrID)
*                        If Error_Services('NoError') then
*                            WOWfrRec<WO_WFR_GRADE$>          = Grade
*                            WOWfrRec<WO_WFR_GAN_RUN_ID$>     = RunID
*                            WOWfrRec<WO_WFR_POCKET$>         = Pocket
*                            WOWfrRec<WO_WFR_SCRIBE$>         = Scribe
*                            WOWfrRec<WO_WFR_RETAIN_BOX$>     = RetainBox
*                            WOWfrRec<WO_WFR_RETAIN_SLOT$>    = RetainSlot
*                            WOWfrRec<WO_WFR_RETAIN_LOC$>     = CurrLoc
*                            WOWfrRec<WO_WFR_RETAIN_COMMENT$> = Comment
*                            WOWfrRec<WO_WFR_RETAIN_STATUS$>  = Status
*                            WOWfrRec<WO_WFR_RETAIN_SIG$>     = RetainSig
*                            WOWfrRec<WO_WFR_RETAIN_DT$>      = RetainDate
*                            Database_Services('WriteDataRow', 'WO_WFR', WfrID, WOWfrRec, True$, False$, True$)
*                        end                
*                    end
*                end
*            end
*        Next ExcelRow
*    end 
*    Excel_Services('CloseDocument', RetainExcelHandle)
* 
*    // Import 8 inch Excel spreadsheet
*    
*    RetainFilepath    = 'D:\Apps\Temp\8in-IFEpi GaN Retain Inventory.xlsx'
*    RetainExcelHandle = Excel_Services('OpenDocument', RetainFilepath)
*    RetainWorksheet   = 'Sheet1'
*    NumExcelRows      = Excel_Services('GetNumRows', RetainExcelHandle, RetainWorksheet)
*    
*    Open 'DICT.REACT_RUN' to @DICT then
*        For ExcelRow = 2 to NumExcelRows
* 
*            RunID        = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'A', ExcelRow) )
*            Convert @Upper.Case to @Lower.Case in RunID
*            RDSNo        = ''
*            Column       = 'GAN_RUN_ID'
*            SearchString = Column:@VM:RunID:@FM
*            Btree.Extract(SearchString, 'REACT_RUN', @DICT, RDSNo)
*            If RDSNo NE '' then
*                ReactRunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
*                If Error_Services('NoError') then
*                    RRRecipe  = ReactRunRec<REACT_RUN_GAN_RECIPE$>
*                    RRPart    = Xlate('REACT_RUN', RDSNo, 'EPI_PART_NO', 'X')
*                    RRScribes = Xlate('REACT_RUN', RDSNo, 'WFR_SCRIBES', 'X')
*                    InWfrIDs  = ReactRunRec<REACT_RUN_IN_WFR_ID$>
*                    
*                    * Read the data from the Excel retain spreadsheet *
*                    Recipe     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'B', ExcelRow) )                    
*                    Pocket     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'C', ExcelRow) )
*                    If Pocket _NEC 'ref' then                 
*                        Scribe     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'D', ExcelRow) )                   
*                        Grade      = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'E', ExcelRow) )                    
*                        Part       = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'F', ExcelRow) )                    
*                        WorkOrder  = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'G', ExcelRow) )
*                        RetainBox  = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'H', ExcelRow) )                   
*                        RetainSlot = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'I', ExcelRow) )
*                        Operator   = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'J', ExcelRow) )
*                        RetainDate = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'K', ExcelRow) )
*                        CurrLoc    = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'L', ExcelRow) )                   
*                        Status     = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'M', ExcelRow) )
*                        Comment    = Trim( Excel_Services('GetCellValue', RetainExcelHandle, RetainWorksheet, 'N', ExcelRow) )
*                        
*                        Begin Case
*                            Case Operator _EQC 'AH'
*                                RetainSig = 'ANTHONY_H'                          
*                            Case Operator _EQC 'SB'
*                                RetainSig = 'SYEDA_B'
*                            Case Operator _EQC 'PM'
*                                RetainSig = 'PEYTON_M'
*                            Case Operator _EQC 'JL'
*                                RetainSig = 'JAVIER_L'
*                            Case Operator _EQC 'PS'
*                                RetainSig = 'PRISCILA_S'
*                            Case Operator _EQC 'NC'
*                                RetainSig = 'NIKOLAS_C'
*                            Case Operator _EQC 'HG'
*                                RetainSig = 'HECTOR_G'
*                            Case Operator _EQC 'ES'
*                                RetainSig = 'ESTEBAN_S'
*                            Case Operator _EQC 'AD'
*                                RetainSig = 'ALIYAH_D'
*                            Case Operator _EQC 'LB'
*                                RetainSig = 'LACEY_B'
*                            Case Operator _EQC 'IP'
*                                RetainSig = 'IAN_P'
*                            Case Operator _EQC 'RC'
*                                RetainSig = 'RYAN_C'
*                            Case Operator _EQC 'GR'
*                                RetainSig = 'GEORGE_R'
*                            Case Operator _EQC 'AH/JL'
*                                RetainSig = 'ANTHONY_H'
*                            Case Operator _EQC 'NC/JL'
*                                RetainSig = 'NIKOLAS_C'
*                            Case Operator _EQC 'SW'
*                                RetainSig = 'STEVEN_W'
*                            Case Otherwise$
*                                RetainSig = ''
*                        End Case
*                        
*                        // Truncate DTM to just the date, then convert to internal format
*                        RetainDate = RetainDTM[1, 'F ']
*                        RetainDate = IConv(RetainDate, 'D')
*                        
*                        * Clean the data *                    
*                        // Format the Recipe
*                        Convert @Lower.Case to @Upper.Case in Recipe
*                        // Format the Pocket                    
*                        If Pocket[1, 1] NE '0' then Pocket = '0':Pocket
*                        // Format the Scribe
*                        Convert @Lower.Case to @Upper.Case in Scribe
*                        // Format the Grade
*                        Begin Case
*                            Case Grade _EQC 'aborted'
*                                Grade = 'Aborted'
*                            Case Grade _EQC 'CT'
*                                Grade = 'CT'
*                            Case ( (Grade _EQC 'Eng  test') or (Grade _EQC 'Eng test') or (Grade _EQC 'Engtest') or (Grade _EQC 'Test') )
*                                Grade = 'Eng Test'
*                            Case Grade _EQC 'Eq Failure'
*                                Grade = 'EQ Failure'
*                            Case Grade _EQC 'Mechanical'
*                                Grade = 'Mechanical'
*                            Case Grade _EQC 'NA'
*                                Grade = 'NA'
*                            Case Grade _EQC 'retain'
*                                Grade = 'Retain'
*                            Case Grade _EQC 'scrap'
*                                Grade = 'Scrap'
*                            Case Grade _EQC 'Terminated'
*                                Grade = 'Terminated'
*                            Case Grade _EQC ''
*                                Grade = ''
*                            Case Otherwise$
*                                Null
*                        End Case
*                        // Format the Part No
*                        Convert @Lower.Case to @Upper.Case in Part
*                        // Format the Current Location
*                        Begin Case
*                            Case CurrLoc _EQC 'Cleanroom'
*                                CurrLoc = 'Cleanroom'
*                            Case ( (CurrLoc _EQC 'Wafer Destroyed') or (CurrLoc _EQC 'Wafers Destroyed') or (CurrLoc _EQC 'Wasfer Destroyed') )
*                                CurrLoc = 'Wafer Destroyed'
*                            Case CurrLoc _EQC 'Warehouse'
*                                CurrLoc = 'Warehouse'                        
*                        End Case
*                        
*                        * Write the data to the WO_WFR record *
*                        WfrIndex = Pocket + 0 ; // Convert string to integer and trim 0 padding
*                        
*                        RRScribe = RRScribes<0, WfrIndex>  
*                        WfrID = InWfrIDs<0, WfrIndex>
*                        WOWfrRec = Database_Services('ReadDataRow', 'WO_WFR', WfrID)
*                        If Error_Services('NoError') then
*                            WOWfrRec<WO_WFR_GRADE$>          = Grade
*                            WOWfrRec<WO_WFR_GAN_RUN_ID$>     = RunID
*                            WOWfrRec<WO_WFR_POCKET$>         = Pocket
*                            WOWfrRec<WO_WFR_SCRIBE$>         = Scribe
*                            WOWfrRec<WO_WFR_RETAIN_BOX$>     = RetainBox
*                            WOWfrRec<WO_WFR_RETAIN_SLOT$>    = RetainSlot
*                            WOWfrRec<WO_WFR_RETAIN_LOC$>     = CurrLoc
*                            WOWfrRec<WO_WFR_RETAIN_COMMENT$> = Comment
*                            WOWfrRec<WO_WFR_RETAIN_STATUS$>  = Status
*                           WOWfrRec<WO_WFR_RETAIN_SIG$>      = RetainSig
*                           WOWfrRec<WO_WFR_RETAIN_DT$>       = RetainDate
*                           Database_Services('WriteDataRow', 'WO_WFR', WfrID, WOWfrRec, True$, False$, True$)
*                        end                
*                    end
*                end
*            end
*        Next ExcelRow
*    end 
*    Excel_Services('CloseDocument', RetainExcelHandle)
* 
* return 



