working on it ...

Filters

Explore Public Snippets

Sort by

Found 3 snippets

    public by congruityservice  2321  1  5  0

    OpenInsight POPUP Function Example With Literal Data

    The Popup function (see https://wiki.srpcs.com/display/Commands/Popup+Function) is very flexible but with flexibility comes complexity. This is a code example showing a multi-column Popup with literal data.
    $Insert POPUP_EQUATES
    Declare Function Popup
    
    PopDisp = ''
    PopDisp<PCOL$> = -1
    PopDisp<PROW$> = -1
    PopDisp<PWIDTH$> = -1
    PopDisp<PHEIGHT$> = -1
    PopDisp<PFILE$> = ''
    PopDisp<PMODE$> = 'L'
    PopDisp<PTITLE$> = 'Please choose a line'
    PopDisp<PTYPE$> = 'E'
    
    //Show multi-column list
    PopDisp<PDISPLAY$> = "One":@SVM:"A is for Apple":@VM:"Two" :@SVM: "B is for Banna":@VM:"Three":@SVM:"C is for Code"
    PopDisp<9> = 1:@SVM:10:@SVM:'L':@SVM:'L':@SVM:'':@SVM:'Num Col':@VM:2:@SVM:25:@SVM:'L':@SVM:'L':@SVM:'':@SVM:'Phrase'
    
    //For simple single column list
    /*
    PopDisp<PDISPLAY$> = "One":@VM:"Two":@VM:"Three"
    PopDisp<PFORMAT$> = 1:@SVM:10:@SVM:'L':@SVM:'L':@SVM:'':@SVM:'Num Col'
    */
    
    Resp = Popup(@WINDOW, PopDisp)
    

    public by congruityservice  2752  2  5  0

    Save List of Attached Tables as Code

    Run routine To parse the list of attached tables And save the list To an OS file In a form that is suitable For copying And pasting into source code For re-attaching the same list of tables.
    Function CS_SAVE_ATTACHED_TABLES(void)
    /*
    Usage:
    Run routine To parse the list of attached tables And save the list
    To an OS file In a form that is suitable For copying And pasting into
    source code For re-attaching the same list of tables.
    */
    declare function Set_FSError
    $Insert Logical
     
    *Location to save the generated list of attached tables
    OutputFile = "C:\temp\tables.txt"
    
    *Readnext through the systables which contains a list of currently attached tables.
    TABLE_NAME = "SYSTABLES"
    
    *Storage for list of attached tables
    AttachEntry = ''
    
    open TABLE_NAME To TABLE else
    	status = Set_FSError()
    	return
    End
    
    select TABLE
    Done = False$
     
    Loop
    	ReadNext @ID else Done = True$
    Until Done Do
    
    
    	read @RECORD From TABLE, @ID Then
    		
    		Gosub processRecord
    	   
    	End Else
    		status = Set_FSError()
    		return
    	End
    	
    Repeat
     
    *Write the list of attached tables to a file
    Swap @FM With \0D0A\ In AttachEntry
    OSWrite AttachEntry To OutputFile
     
    return
    *
    * End Main
    *
    processRecord:
    
    	//Don't bother processing Index or Dictionary tables
    	If @ID[1,1] EQ "!" Then Return
    	If @ID[1,5] EQ "DICT." Then Return
    
    	//Check the volume against certain system volumes and exclude them
    	Vol = Field(@RECORD<1>, "*", 2)
       
    	*Exclude tables in RevBoot
    	ExVol = ''
    	If Vol = ExVol Then Return
       
    	*exclude tables in various system directories
    	ExVol = 'REPOSITORY'
    	If Vol[1,Len(ExVol)] = ExVol Then Return
       
    	ExVol = 'MEMORY_RESIDENT'
    	If Vol[1,Len(ExVol)] = ExVol Then Return
       
    	ExVol = 'O4WFILES'
    	If Vol[1,Len(ExVol)] = ExVol Then Return
       
    	ExVol = 'WEBOI'
    	If Vol[1,Len(ExVol)] = ExVol Then Return
       
    	ExVol = 'REVBOOT'
    	If Vol[1,Len(ExVol)] = ExVol Then Return
       
    	ExVol = 'DATAVOL'
    	If Vol[1,Len(ExVol)] = ExVol Then Return
       
    	*Tables attached outside of the revboot directory have absolute
    	*paths and will be changed to be relative.
    	Swap "\\SERVER1\SHARE\REVTABLES\" With "" In Vol
    	Swap "\\SERVER2\SHARE\REVTABLES\" With "" In Vol
       
    	TableName = @RECORD<2>
    	App = @RECORD<3>
       
    	*Build a list of tables in an openinsight data structure suitable for compiling in source code
    	*Generated output will look like:
    	*Tables<-1> = 'TEST_VOL,PERSON_INFO_TEST,GLOBAL' ;* TEST_VOL
    	AttachEntry<-1> = "Tables<-1> = '" : VOL : "," : TableName : "," : APP : "' ;* " : VOL
    
    return
    

    public by congruityservice  2253  1  5  0

    ReadNext Loop with Read and Delete

    This simple code snippet is useful if you have find and remove records from a table that can't be selected through RLIST. Add your selection code to checkRecord branch. Program is split into separate select and remove loops. Uncomment the debug statement to see what will be removed before the delete loop.
    Subroutine CS_SNIP_ReadNext_ReadDelete(void)
    *
    *CAUTION - This will delete records from the table in TABLE_NAME
    *
    
    declare function Set_FSError
    $Insert Logical
    
    *Change to the name of the table to ReadNext through
    TABLE_NAME = "CUSTOMER"
    
    open TABLE_NAME To TABLE else
    	status = Set_FSError()
    	return
    end
    
    select TABLE
    
    Done = False$
    
    *Keep a list of keys to delete
    DeleteList = ''
    
    *Loop through all of the table records to find keys for DeleteList
    Loop
    	ReadNext @ID else Done = True$
    Until Done Do
    
    	read @RECORD From TABLE, @ID Then
    		
    		*Check if @ID and @RECORD should be deleted
    		*Place criteria in this subroutine
    		Gosub checkRecord
    		
    	End Else
    		status = Set_FSError()
    		return
    	End
    	
    Repeat
    
    *At this point all keys selected for deletion are in DeleteList
    *debug ;* Break here if you want to check list.
    
    *Track how many keys couldn't be deleted
    DeleteListFails = ''
    DeleteListCount = DCOUNT(DeleteList,@FM)
    
    *Loop through the delete record list and delete the record
    For i = 1 To DeleteListCount
    
    	KeyToDelete = DeleteList<i>
    	
    	Delete TABLE, KeyToDelete Else
    		DeleteListFails<-1> = KeyToDelete 
    	End
    	
    	KeyToDelete = ''
    Next
    
    *debug ;* Process finished
    
    return
    *
    * End Main
    *
    
    checkRecord:
    
    	//Add code here to check if @ID / @RECORD should
    	//be deleted.
    	
    	*Sample check, if record key begins with 0.
    	If @ID[1,1] EQ '0' Then
    		DeleteList<-1> = @ID
    	End
       
    return
    	

    List Complete ( 3 snippets total )

    • Public Snippets
    • Channels Snippets