working on it ...

Filters

Explore Public Snippets

Sort by

Found 11 snippets

    public by congruityservice  2801  2  5  0

    Basic Commuter Module

    OpenInsight contains a commuter module generator to create a shell program capable of handling window events. It doesn't work so well in OpenInsight 9.4 so below is a basic version generated from the commuter module generator that can be easily customized for your window.
    Function YOUR_WINDOW_NAME_EVENTS(CtrlEntID,Event,Param1,Param2,Param3,Param4,Param5,Param6,Param7,Param8)
    *
    * Blank Commuter Module
    *
    Declare Subroutine Msg, FsMsg, Set_Status, Set_Property
    
    Declare Function Msg, Get_Property, Get_Status, Set_Property, Popup
    Declare Function  Repository, Send_Message, Send_Event, Unassigned, Utility, XLate
    Declare Function  ContextMenu
    
    $Insert COLORS
    $Insert MSG_Equates
    $Insert Popup_Equates
    $Insert Logical
    
    If Unassigned(CtrlEntID) Then CtrlEntID = ''
    If Unassigned(Event) Then Event = ''
    If Unassigned(Param1) Then Param1 = ''
    If Unassigned(Param2) Then Param2 = ''
    If Unassigned(Param3) Then Param3 = ''
    If Unassigned(Param4) Then Param4 = ''
    If Unassigned(Param5) Then Param5 = ''
    If Unassigned(Param6) Then Param6 = ''
    If Unassigned(Param7) Then Param7 = ''
    If Unassigned(Param8) Then Param8 = ''
    *
    *
    If index(CtrlEntID,".",1) then
    	WinName = Field(CtrlEntID,'.',1)
    	Control = Field(CtrlEntID,'.',2)
    End else
    	WinName = CtrlEntID
    	Control = WinName
    End
    *
    Parent = @window
    Frame = Get_Property(Parent,'MDIFRAME')
    If len(Frame) then Parent = Frame
    *
    Retval = 1
    *
    Begin Case
    
    	Case Control = "YOUR_WINDOW_NAME" And Event = 'CREATE'
    		*Gosub handle create event
    	Case Control = "BTN_DOSOMETHING"
    		*Events for CONTROL go here
    		Begin Case
    			Case Event = "CLICK"
    				*Gosub handle click event
    		End Case
    		
    End Case
    *
    return retval
    *
    * End Main Routine
    *
                

    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  2063  3  6  0

    Gas Gauge Processing Message with Updating Text

    The standard help file for the OpenInsight Msg function shows a sample gas gauge for showing progress but it doesn't contain an example of how to change the processing text to indicate what the loop is currently working on. This example expands upon the help file example for Msg() and includes the ability to change the text during each processin
    Subroutine CS_TEST_MSG_GASGAUGE(void)
    $Insert Msg_Equates
    
    //Number of example processing loops
    MAX_LOOPS = 1000
    
    def = ''
    def<MCAPTION$> = 'Gas Guage with Cancel Button'
    def<MTYPE$> = 'GCU'
    def<MTEXT$> = 'Initializing...'
    def<MEXTENT$> = MAX_LOOPS 
    def<MTEXTWIDTH$> = 400 ;* Width of the progress window
    
    //Display the message for the first time
    msgup = Msg(@WINDOW, def)
    
    For i = 1 To MAX_LOOPS
    
    	//Update the text and progress of the message
    	Call Set_Property("MSG.ST_TEXT", "TEXT", "Working on loop " : i)
    	Resp = Msg(@WINDOW,MsgUp, i, MSGINSTUPDATE$)
    	
    	//If user canceled then abort the loop
    	If Resp EQ 0 Then
    		i = MAX_LOOPS
    	End
    	
    	//Allow processing of cancel events
    	Call Yield()
    
    Next
    
    //Take down the message
    Call Msg(@WINDOW, MsgUp)            

    public by congruityservice  2139  2  5  0

    Simple OpenInsight Response Dialog

    Uses the Msg function to display a dialog prompting the user to enter a response. See the Msg function in OpenInsight help file for more information.
    $Insert MSG_EQUATES
    
    Def = ""
    Def<MTEXT$> = "What did you eat for breakfast?"
    Def<MTYPE$> = "RC"
    Def<MICON$> = "?"
    
    Response = Msg(@window, Def)
    
    if Response = char(27) or Response = "" then
       * Message was escaped or not entered
       Return
    end

    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
    	

    public by congruityservice  2409  2  6  0

    ReadNext Loop with Read and Write

    Basic ReadNext loop through an entire table with a read and write of each record.
    Subroutine CS_SNIP_ReadNext_ReadWrite(void)
    
    declare function Set_FSError
    $Insert Logical
    
    *Change to the name of the table to ReadNext through
    TABLE_NAME = "CUSTOMERS"
    
    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
    		
    		Write @RECORD To TABLE, @ID Else
    			status = Set_FSError()
    			return
    		End
    		
    	End Else
    		status = Set_FSError()
    		return
    	End
    	
    Repeat
    
    return
    *
    * End Main
    *
    processRecord:
    
    	//Add your processing to @RECORD here
       
    return
    	            

    public by congruityservice  2257  2  5  0

    RDK View Import Export Code

    Function for exporting a list of RDK entries to an OS file and then re-importing it, perhaps into a different OpenInsight system.
    Subroutine CS_RDKView(Action, View, Path)
    /*Usage:
    *To export a view named SCRATCH
    run CS_RDKView "Export", "SCRATCH", "D:\TEMP"
    
    *Import a view named SCRATCH from the TEMP folder
    Run CS_RDKView "Import", "SCRATCH", "D:\TEMP"
    */
    Declare Subroutine Copy_row_to_os, Copy_OS_To_Row
    
    Convert @LOWER_CASE To @UPPER_CASE In View
    Key = @DBID<1>:"*":View
    OSFile = Path : "\" : View : "_viewexport.txt"
    Table = "SYSREPOSVIEWS"
    AlwaysOverwrite = 2
    AlwaysConvert = 0
    NoLocking = 0
    	
    If Action _EQC "Export" Then
    	
    	Call Copy_Row_to_os(Table,Key,OSFile,AlwaysOverwrite,AlwaysCOnvert,NoLocking)
    
    End
    
    If Action _EQC "Import" Then
    
    	Copy_OS_To_ROW(OSFile,Table, Key, AlwaysOverwrite, AlwaysCOnvert,NoLocking)
    
    End
    
    Return 

    public by congruityservice  1973  1  5  0

    Attach Revmedia for Editing

    This snippet is used for attaching a volume (directory) revmedia file for editing. Since the revmedia table can't be attached directly it must be edited using the alias_table command. The path to the table volume can be absolute, relative, or a UNC. The records in the revmedia volume are accessible through the table REVMEDIA_ALIAS. Commands must be
    //Run commands from System Monitor (F12) or Tools -> Advanced -> System Monitor
    run alias_table "C:\PathTo\TableVolume", "SYSPROG", "REVMEDIA", "REVMEDIA_ALIAS"
    
    //Show the contents of the table or use the System Editor
    run rlist "LIST REVMEDIA_ALIAS", 1

    public by congruityservice  2176  1  5  0

    Move Control Over Placeholder Control

    The snippet moves one control over another control. Useful if you need to design a form with place holders and then move the actual field onto that placeholder.
    *Move TXT_FNAME edit line over the LBL_PLACEHOLDER1 label.
    pcopTarget = @WINDOW:".LBL_PLACEHOLDER1"
    pcopSource = @WINDOW:".TXT_FNAME"
    Gosub PlaceControlOverPlaceholder
    
    *
    * Sub moves control over the specified placeholder control
    *
    PlaceControlOverPlaceholder:
    	*Acronym
    	*pcop - Place Control Over Placeholder
    
    	If Unassigned(pcopOffset_X) Then pcopOffset_X = 0
    	If Unassigned(pcopOffset_Y) Then pcopOffset_Y = 0
    
    	pcopS = Get_Property(pcopSource,'SIZE')
    	pcopT = Get_Property(pcopTarget,'SIZE')
    
    	pcopS<1> = pcopT<1> + pcopOffset_X ;* X
    	pcopS<2> = pcopT<2> + pcopOffset_Y	;* Y
    	*S<3> = 100 ;* Width
    	*S<4> = 20	;* Height
    
    	Call Set_Property(pcopSource,'SIZE', pcopS)
    
    	Call Set_Property(pcopSource,"VISIBLE", 0)
    	Call Set_Property(pcopTarget,"VISIBLE", 1)
    
    	pcopOffset_X = 0
    	pcopOffset_Y = 0
    
    Return
    *
    * End PlaceControlOverPlaceholder
    *
                
    • Public Snippets
    • Channels Snippets