Skip to content

Instantly share code, notes, and snippets.

@jbratu
jbratu / O4W_CS_TEST_DIALOG_HELLOWORLD.oibp
Created March 7, 2016 01:19
Simple OpenInsight O4W Hello World example with dialog.
Subroutine O4W_CS_TEST_DIALOG_HELLO_WORLD(CtrlEntId, Event, Request)
$Insert O4WEquates
$Insert O4WCommon
BEGIN Case
CASE EVENT _EQC "CREATE"
O4WForm()
O4WHeader("Hello World Example")
@jbratu
jbratu / bind plugin to button snippet.oibp
Last active April 11, 2016 01:45
Example jQuery plugin for OpenInsight O4W
O4WButton("Hello World", "BTN_HELLO_WORLD")
O4WQualifyEvent("BTN_HELLO_WORLD", "CLICK")
//Bind the sayhello plugin to the button
O4WPlugin("BTN_HELLO_WORLD", "sayhello", "")
Function CS_TransposeSort(A, Bys, Justs)
Declare Subroutine V119
ARowCount = DCOUNT(A<1>, @VM)
AColCount = DCount(A, @FM)
ATransposed = ''
*Transpose it for use with V119
//Original source: http://www.sprezzatura.com/library/whitepapers/OI%20Coding%20Standards%20v1%200%207.pdf
//Protect any active select list. Pop it at end of routine.
saveAtDict_ = @dict
saveAtRecord_ = @record
saveAtID_ = @id
saveAtRecCount_ = @recCount
saveAtRnCounter_ = @rn.Counter
A_ = 0 ; B_ = 0 ; C_ = 0 ; D_ = 0
call push.Select( A_, B_, C_, D_ )
@jbratu
jbratu / CS_TEST_MSG_GASGAUGE.oibp
Created May 18, 2016 18:15
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…
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...'
@jbratu
jbratu / CS_SNIP_CreateCopy_ReadNext.oibp
Created May 23, 2016 18:32
A basic copy table function.Example routine creates the destination dictionary and data tables and writes the data using a select/readnext/write loop.
Subroutine CS_SNIP_CreateCopy_ReadNext(void)
Declare Subroutine Set_Status, create_Table,Msg,attach_table
declare function Set_FSError,Msg
$Insert Logical
*Source table to copy from
TABLE_NAME = "CUSTOMERS"
*Destination table to create and copy to
@jbratu
jbratu / CS_OI_RESPONSE_DIALOG.oibp
Created June 21, 2016 18:18
Simple OpenInsight response dialog. See the help file for more information or see https://wiki.srpcs.com/display/Commands/Msg+Function
$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
@jbratu
jbratu / OIMSG_CUSTOM_BUTTONS.oibp
Created July 4, 2016 15:39
Example showing how to use the Msg function with custom button text.
WantsFries = '' ;* Set to 'No' or 'Yes' after Msg.
Def = ""
Def<MTEXT$> = "Do you want fries with your order?"
Def<MTYPE$> = "BNo Fries,Fries" ;*B indicates beginning of comma separated list.
Def<MICON$> = "?"
Resp = Msg(@window, Def)
Begin Case
@jbratu
jbratu / CS_SNIP_RANDOM_NUMBER.oibp
Created July 7, 2016 13:43
The OpenInsight random number generator is pseudo-random and running simultaneous sessions on the same computer can result in the same random number results. This snippet calls the JScript random number generator.
common /csRnd/ WScript, init%
If Assigned(init%) Else init% = ''
If init% else
WScript = oleCreateInstance("ScriptControl")
OlePutProperty(wscript, "Language", "JScript")
s = 'function getrandom() {return Math.random();}'
x = WScript->AddCode(s)
init% = 1
end
RetVal = WScript->Eval("getrandom();") * 1
@jbratu
jbratu / CS_BREAKON_BOUNDARY.oibp
Created July 7, 2016 19:57
Given a string of words the function breaks the string into chunks no longer than the specified length. Breaks on word boundaries and avoids breaking words into fragments.
Function CS_BREAKON_BOUNDARY(Sentence, Boundary, BreakLength)
/*
Example:
Sentence = 'The Quick Brown Fox................ Jumped Over the Lazy Dog ....'
Lines = CS_BREAKON_BOUNDARY(Sentence, ' ', 10)
Lines contains an array of sentences And words that do Not exceed 10 characters In length.
*/