Compile Subroutine Table_Info_Sym(Table, Process, Exceptions)


If Assigned(Table) else Table = ""
If Assigned(Process) else Process = ""
If Assigned(Exceptions) else Exceptions = ""

If Process EQ "" then Process = "ALL"

TableInfo = ""
MaxLens = ""
HeadInfo = ""
MaxFMs = ""
ColInfo = ""
Open Table to handle then
    Open "DICT.":Table to @DICT then
        GoSub Pull_Dict_Items
        Done = 0
        Counter = 0
        
        Select handle
        Loop
            Readnext @ID else Done = 1
            If Num(Process) then
                // go this many times
                If Counter GT Process then Done = 1
            end
        Until Done
            Read @RECORD from Handle, @ID then
                For ColLoop = 1 to NumCols
                    CurVal = Calculate(DictList<ColLoop>)
                    Begin Case
                        Case Index(CurVal, @SVM, 1)
                            If Index(ColInfo<ColLoop>, "SVM,", 1) else
                                ColInfo<ColLoop> = ColInfo<ColLoop>:"SVM,"
                            end
                        Case Index(CurVal, @VM, 1)
                            If Index(ColInfo<ColLoop>, "VM,", 1) else
                                ColInfo<ColLoop> = ColInfo<ColLoop>:"VM,"
                            end
                            NumVms = Count(CurVal, @VM) + (CurVal NE "")
                            For VMLoop = 1 to NumVMs
                                CurVMVal = CurVal<0, VMLoop>
                                CurLen = Len(CurVMVal)
                                If CurLen GT MaxLens<ColLoop> then
                                    MaxLens<ColLoop> = CurLen
                                end
                            Next VMLoop
                        Case 1
                            CurLen = Len(CurVal)
                            If CurLen GT MaxLens<ColLoop> then
                                MaxLens<ColLoop> = CurLen
                            end
                    End Case
                        
                Next ColLoop
                Counter += 1
            end
        Repeat
    end
end

FinalVar = ""
For ColLoop = 1 to NumCols
    FinalVar := HeadInfo<1, ColLoop>:@VM:ColInfo<ColLoop>:@VM:MaxLens<ColLoop>:@FM
Next ColLoop

Open "SYSLISTS" to hSyslists then
    Write FinalVar to hSyslists, "TABLE_INFO_SYM" else null
    Call SRP_Editor_Open("Record", "SYSLISTS":@FM:"TABLE_INFO_SYM")
end

Return


Pull_Dict_Items:
    HeadInfo = ""
    DictList = ""
    
    // If Dictlist is Null then make a list of all data dicts.
    Clearselect
    Select @DICT
    Done = 0
    Loop
        Readnext DictID else Done = 1
    Until Done
        Read DictRec from @DICT, DictID then
            If DictRec<1> _EQC "S" then
                Locate DictID in Exceptions using "," setting Pos else
                    Locate DictID in DictList by "AL" using @FM setting Pos else
                        DictList = Insert(DictList, Pos, 0, 0, DictID)
                    end
                end
            end
        end
    Repeat
    
    NumCols = Count(DictList, @FM) + (DictList NE "")
    For ColLoop = 1 to NumCols
        CurDictID = DictList<ColLoop>
        VMPos = Field(CurDictID, "*", 2, 1)
        If VMPos then
            If VMPos[1, 2] _EQC "VM" then
                VMPos[1, 2] = ""
            end
            CurDictID = Field(CurDictID, "*", 1, 1)
            Swap " " with "_" in CurDictID
            Convert @Lower.Case to @Upper.Case in CurDictID
        end else
            Swap " " with "_" in CurDictID
            Convert @Lower.Case to @Upper.Case in CurDictID            
            If CurDictID EQ "ID" then
                expDictID = "MAIN_ID"
            end else
                expDictID = CurDictID
            end      
        end
        Read DictRec from @DICT, CurDictID else DictRec = ""
        Begin Case
            Case DictList<ColLoop> EQ "ID"
                HeadInfo<1, ColLoop> = "ID"
                HeadInfo<2, ColLoop> = 0
                HeadInfo<3, ColLoop> = ""
                HeadInfo<4, ColLoop> = ""
                HeadInfo<5, ColLoop> = ""
            Case DictRec
                HeadInfo<1, ColLoop> = DictList<ColLoop>
                HeadInfo<2, ColLoop> = DictRec<2>   ; * FM
                HeadInfo<3, ColLoop> = DictRec<7>  ; * Oconv
                HeadInfo<4, ColLoop> = VMPos
                HeadInfo<5, ColLoop> = ""
        End Case
    Next ColLoop
return

