Professional Documents
Culture Documents
File : myDataDigger.p
Purpose : Customized routines for DataDigger.
History:
DD18: customFilter added.
DD18: customDump moved here instead of having its own .p
DD20: customShowField added
DD21: customSaveFilterValue / customGetFilterValue added, customFilter removed
DD24: added support for events 'query' and 'datadigger'
DD25: added example for customFrameColor, updated with wiki links
DD26: added customBorderColor
*************************************************************************/
/*
/* global_domain definition for #QAD usage */
define new global shared variable global_domain as character.
*/
/*
/* Function for #QAD to determine the domain-field in a table */
FUNCTION getDomainFieldName RETURNS CHARACTER
( pcDatabase AS CHARACTER
, pcTable AS CHARACTER ):
/*
** SDBNAME wille return a different name
** if pcDatabase is a non Progress database like MSS [dataserver]
*/
IF SDBNAME(pcDatabase) <> pcDatabase THEN RETURN "".
RETURN cDomainFieldName.
/*
PROCEDURE DataDigger:
/*
* Name: DataDigger
* Desc: Called on open and close of a DataDigger window.
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-
StartDataDigger
*
* When DD is started and closed, this event is published
* with piNumber = 1 for opening and -1 for closing.
*/
DEFINE INPUT PARAMETER piNumber AS INTEGER.
/*
PROCEDURE customBorderColor:
/*
* Name: customBorderColor
* Desc: Change the border color of the main window
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-BorderColor
*
* This is handy if you want to make it clear that you have a certain
* database connected, eg production or test. This routine is called on startup
* and every time you connect or disconnect a database.
*/
DEFINE OUTPUT PARAMETER pcColor AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDatabases AS CHARACTER NO-UNDO.
/*
PROCEDURE customDump:
/*
* Name: customDump.p
* Desc: Customized dump data from DataDigger
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-CustomDump
*
* DataDigger will call this file with the following parameters:
*
* input pcAction (character) - type of dump (Delete | Save)
* input pcDatabase (character) - name of the database
* input pcTable (character) - name of the table
* input phData (handle ) - handle to a dynamic tt with the data to dump
* input pcFilename (character) - filename as suggested by DataDigger
*
* The phData parameter is a handle to a temp-table that holds only the
* data you would like to dump. So it contains 1 record in case of a save
* action and 1 or more in case of a delete action.
*
* You can give these parameters back to DataDigger:
*
* output pcMessage (character) - a message to show the user
* output plDefaultDump (logical ) - perform regular DD dump or not
* output plContinue (logical ) - perform regular DD dump or not
*
* pcMessage:
* This can be an informative message, a warning or an error. This
* will be shown to the user by DataDigger.
*
* plDefaultDump
* This tells DD whether to perform its own dump or not.
*
* plContinue
* This tells DD whether the action should be committed. You
* can use this to prevent certain delete or save actions.
*
*
* Note that if you do your own dump, using the filename DD suggests in
pcFilename
* and you set plDefaultDump to TRUE, DD will overwrite your file because it too
* uses this filename to dump its data.
*
*/
DEFINE INPUT PARAMETER pcAction AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcDatabase AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcTable AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER phData AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER pcFilename AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER pcMessage AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER plDefaultDump AS LOGICAL NO-UNDO INITIAL TRUE.
DEFINE OUTPUT PARAMETER plContinue AS LOGICAL NO-UNDO INITIAL TRUE.
/*
/* Ask if user is really sure to delete */
IF pcAction = 'Delete' THEN
DO:
MESSAGE 'Are you really really really sure you want to delete these precious
records?'
VIEW-AS ALERT-BOX INFORMATION BUTTONS YES-NO UPDATE plContinue.
END.
ELSE
DO:
phData:WRITE-XML
( 'file' /* TargetType */
, pcFileName /* File */
, YES /* Formatted */
, ? /* Encoding */
, ? /* SchemaLocation */
, NO /* WriteSchema */
, NO /* MinSchema */
).
END.
*/
/*
PROCEDURE customFrameColor:
/*
* Name: customFrameColor
* Desc: Change the background color of the main window
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-
CustomFrameColor
*
* This is handy if you want to make it clear that you have a certain
* database connected, eg production or test. This routine is called on startup
* and every time you connect or disconnect a database.
*/
DEFINE OUTPUT PARAMETER pcFrameColor AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDatabases AS CHARACTER NO-UNDO.
/*
PROCEDURE customFormat:
/*
* Name: customFormat
* Desc: Change the format for a field
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-CustomFormat
*
* Depending on the input parameters you are able to adjust the format of
* a field. This routine is called after the custom format is fetched
* from the user settings.
*
* This is handy if - for example - all userid fields in your
* database have the wrong format. Or if you want to show
* all decimal fields with 4 decimals instead of 3.
*/
DEFINE INPUT PARAMETER pcDatabase AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcTable AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcField AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcDatatype AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER pcFormat AS CHARACTER NO-UNDO.
/*
/* Example 1: Set minus sign at the front of an decimal field */
IF pcDataType = "DECIMAL"
AND NOT pcFormat BEGINS "-" THEN pcFormat = "-" + pcFormat.
/*
/* Example 1: hide the cust-num field except on the customer table */
IF pcField = 'cust-num' AND pcTable <> 'customer' THEN plShow = FALSE.
/*
PROCEDURE customQuery:
/*
* Name: customQuery.p
* Desc: Adjust query string
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-CustomQuery
*
* This routine is called when DataDigger places a query in the WHERE-editor
* and when you select a table. In that case the query is empty. In all
* cases this routine is called just prior to placing the text in the query
* editor. This gives you a chance to alter the query.
*
* INPUT pcDatabase (character) - name of the database
* INPUT pcTable (character) - name of the table
* INPUT-OUTPUT pcQuery (character) - your query string
*
*/
DEFINE INPUT PARAMETER pcDatabase AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcTable AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER pcQuery AS CHARACTER NO-UNDO.
/*
/* Example: get the most recently used query from query history */
IF pcQuery = "" THEN
pcQuery = getQuery(pcDatabase, pcTable, 1).
*/
/*
PROCEDURE customGetFilterValue:
/*
* Name: customGetFilterValue
* Desc: Set a default value for field filters
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-FilterValue
*
* After the data browse is created, the filter fields are created
* one by one. You can use this routine to give them a default value.
*/
DEFINE INPUT PARAMETER pcDatabase AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcTable AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcField AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER pcFilterValue AS CHARACTER NO-UNDO.
/*
PROCEDURE customSaveFilterValue:
/*
* Name: customSaveFilterValue
* Desc: Perform actions based on the value of a filter
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-FilterValue
*
*/
DEFINE INPUT PARAMETER pcDatabase AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcTable AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcField AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcFilterValue AS CHARACTER NO-UNDO.
/*
PROCEDURE queryOpen:
/*
* Name: queryOpen
* Desc: Receive the full query that is executed
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-QueryOpen
*/
DEFINE INPUT PARAMETER pcQuery AS CHARACTER NO-UNDO.
/*
DEFINE VARIABLE iWord AS INTEGER NO-UNDO.
DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
/* Parse the query word by word and look for the domain field.
* If the #QAD domain field is used in an equality match, filter
* out the value and save that as the new global_domain
*/
DO iWord = 1 TO NUM-ENTRIES(pcQuery,' ') - 2:
IF ENTRY(iWord,pcQuery,' ') MATCHES '*_domain'
AND ENTRY(iWord + 1,pcQuery,' ') = '=' THEN
DO:
cValue = ENTRY(iWord + 2,pcQuery,' ').
cValue = TRIM(cValue,'()"~'').
IF cValue > '' THEN global_domain = cValue.
END.
END.
*/
/*
PROCEDURE setWindowTitle:
/*
* Name: setWindowTitle
* Desc: Change the title of the main window
* Wiki: https://github.com/patrickTingen/DataDigger/wiki/Customize-
SetWindowTitle
*
* This hook enables you to change the title of the DataDigger window.
*
* This is handy if you want to have other information in the title bar
* that is not provided by DataDigger (for example user name)
*
*/
DEFINE INPUT PARAMETER pcDatabase AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcTable AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER pcTitle AS CHARACTER NO-UNDO.