COMPILE ROUTINE FIX_SYSLISTS(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, RList,Btree.Extract, Set_Status, Get_Status, ErrMsg


$INSERT RLIST_EQUATES
debug

EQU TAB$ TO \09\


OPEN 'SYSLISTS' TO SysListsTable ELSE
	debug
	GOTO Bail
END


SelectStatement = 'SELECT SYSLISTS BY @ID'

RList(SelectStatement, TARGET_ACTIVELIST$, '','','')

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	DEBUG
	GOTO Bail
END

Done = 0

YesterDay = Date() - 1

Stations = ''
StatSeqs = ''

RecCnt = 0
LOOP
	READNEXT ListID ELSE Done = 1
UNTIL Done 

	Type = ListID[1,'*']
	Stat = ListID[COL2()+1,'*']
	User = ListID[COL2()+1,'*']
	
	*IF Type = 'T' AND Stat[1,11] = 'MESIRWAP001' AND User = 'DAVID_KL' THEN
		
		READ ListRec FROM SysListsTable,ListID THEN
		
			RecCnt += 1
			RecLen = LEN(ListRec)
			
			*DELETE SysListsTable,ListID THEN
				Send_Dyn(ListID:TAB$:RecLen)
				Send_Info(ListID:' ':RecCnt)
			*END
			
			
		END
	*END

REPEAT



* * * * * * *
Bail:
* * * * * * *

END


/*

BEGIN CASE
				CASE ListID[1,2] = 'T*' 
				
					First	= ListID[1,'*']
					Station	= ListID[COL2()+1,'*']
					User	= ListID[COL2()+1,'*']
					SeqNo	= ListID[COL2()+1,'*']
					StatSeq = Station:'.':SeqNo
					
					Send_Dyn(First:TAB$:Station:TAB$:User:TAB$:SeqNo:TAB$:ListID)
					
					LOCATE Station IN Stations USING @FM SETTING Pos THEN
						LOCATE StatSeq IN StatSeqs<Pos> BY 'AR' USING @VM SETTING ssPos ELSE
							StatSeqs = INSERT(StatSeqs,Pos,ssPos,0,StatSeq)
						END
						
						
					END ELSE
						Stations = INSERT(Stations,Pos,0,0,Station)
						LOCATE StatSeq IN StatSeqs<Pos> USING @VM SETTING ssPos ELSE
							StatSeqs = INSERT(StatSeqs,Pos,ssPos,0,StatSeq)
						END
						
					END
					
					*Send_Dyn(StatSeqs)
					
				
					
				CASE ListID[1,2] = 'Q*'
				
					First	= ListID[1,'*']
					Station	= ListID[COL2()+1,'*']
					User	= ListID[COL2()+1,'*']
				
					Send_Dyn(First:TAB$:Station:TAB$:User:TAB$:TAB$:ListID)
					
					LOCATE Station IN Stations USING @FM SETTING Pos THEN
						NULL
					END ELSE
						Stations = INSERT(Stations,Pos,0,0,Station)
					END
					
					*DEBUG
					
				CASE ListID[1,2] = 'W*'
					First		= ListID[1,'*']
					Station		= ListID[COL2()+1,'*']
					User		= ListID[COL2()+1,'*']
					DtmStamp	= OCONV(ListID[COL2()+1,'*'],'DT4/^S')
					
					Send_Dyn(First:TAB$:Station:TAB$:User:TAB$:DtmStamp:TAB$:ListID)
					
				
				CASE 1
				
							
					*DELETE SysListsTable,ListID THEN
						Send_Dyn(TAB$:ListID)
					*END
					
			END CASE
			
			
*/

