D 2 Kcomn
D 2 Kcomn
D 2 Kcomn
Version: 2.0.3
Date: 26-JUN-1997
Author: DRMILLS
Purpose: This document defines the prototypes and usage of the D2KCOMN PL/SQL
library. Information on each program unit or package within the library is
provided, along with dependencies
1. D2KCOMN {Function}______________________________________________ 2
2. D2K_BuildParamList {Function} _____________________________________ 3
3. D2K_Delimited_String{Package}______________________________________ 4
4. D2K_Filler {Package}_______________________________________________ 7
5. D2K_Finder {Package}______________________________________________ 9
6. D2K_OSFiles {Package}____________________________________________ 10
7. D2K_Res {Package} _______________________________________________ 11
8. D2K_Show_Window_Centered {Procedure} ____________________________ 14
9. ToBoolean {Function} _____________________________________________ 15
10. The D2KCOMN.OLB Object Library ________________________________ 16
D2kCOMN Specification 1
1. D2KCOMN {Function}
1.1. Prototype
D2kComn Return VARCHAR2
Returns a version string for the D2Kcomn library
1.2. Dependencies
None
D2kCOMN Specification 2
2. D2K_BuildParamList {Function}
BuildParamlist provides a quick and simple way to create a parameter list to pass to another
Form, or to Graphics & Reports. The actual creation of the list is internal to the function as
is cleaning up old copies of the list.
2.1. Prototype
BuildParamlist ( ParamString in varchar2,
ParamListName in varchar2
) return PARAMLIST
The ParamString (varchar2) is just a sequence of ParameterName=ParameterValue
statements separated by a pipe symbol. Thus, the argument
‘ENAME=SCOTT|EMPNO=1234’ would create a parameter list with two entries, ENAME
and EMPNO, with their respective values.
To indicate a DATA parameter rather than a TEXT parameter prefix the name of the
parameter with the keyword ‘DATA:’ e.g.
‘ENAME=SCOTT|DATA:EMPQUERY=RECORDGROUPNAME’ this will then create a
parameter list with a text parameter ENAME and a data parameter EMPQUERY.
You are responsible for escaping any quotes or spaces in TEXT data strings into a format
acceptable by the target product..
ParamlistName can be left null for a default name, or if you need to create several co-
existing parameter lists you can supply your own name. If you re-use a list name, the old list
will be replaced by the new one.
2.2. Dependencies
D2K_Delimited_String
D2kCOMN Specification 3
3. D2K_Delimited_String{Package}
D2K_Delimited_String is a package for handling delimited strings. The strings can be
delimited by any character or set of characters (default is comma), and can be terminated or
un-terminated by the delimiter. The various functions within the package provide random
access to the delimited string, much as if it were an array.
The package can handle values of up to 2000 chars in length, although this could be
increased to 32k if required by changing the buffer sizes. The package is not capable of
handling multi-byte strings.
All the values saved to the string are of course saved as string values, but can be extracted to
their native datatypes using the correct Get functions. GetString will extract any data type
into a string variable.
Numeric data types are stored in the supplied precision, and Dates with full precision.
All of the Functions and Procedures within the Package take three common arguments:
• SourceString in varchar2 È The delimited string being accessed
È
• Unterminated in boolean TRUE if there is no trailing delimiter or FALSE (default) if
there is. e.g. in a string that had a comma for the delimiter “ a,b,c” would be classed as
Unterminated=TRUE, whereas “a,b,c,” would be FALSE.
• Delimiter in varchar2 È The actual delimiting char (or chars). This defaults to a
comma.
3.1. Prototype
3.1.1. Constants
None
3.1.2. Variables
none
3.1.3. Procedures
D2kCOMN Specification 4
3.1.3.3.PutDate( Source_string in out varchar2,
Date_to_add in varchar2,
Field_position in number,
UnTerminated in Boolean default FALSE,
Delimiter in varchar2 default ’,’);
As PutString for adding a date.
3.1.3.4.Put È An overloaded version that can put any of the above datatypes.
3.1.4. Functions
3.2. Dependencies
None
D2kCOMN Specification 5
3.3. Error Handling
None
D2kCOMN Specification 6
4. D2K_Filler {Package}
D2K_Filler raises a modal dialog window containing a progress bar. Each time the
increment procedure within the package is called, the progress bar is increased in size.
The programmer has to call the Setup procedure to define the scope of the Fill (e.g. the
number of steps required must be calculated in advance. After this, calls to the increment
procedure will increase the size of the filler bar, and update text in the display with progress
information if required.
4.1. Prototype
4.1.1. Constants
None
4.1.2. Variables
4.1.2.1.Interrupted [Exception]
You can raise this exception to stop the control in a clean manner.
4.1.3. Procedures
4.1.3.3.OK_Button;
Returns focus back to the item specified in the Setup call.
4.1.3.4.Aborted
Resets the internal state of the control when an error occurs. If you implement your own
interrupt mechanism, e.g. by using functions within D2KWUTIL.PLL, then be sure to call
the Aborted procedure after the interrupt, in order to ensure that subsequent calls to the
component work.
D2kCOMN Specification 7
4.2. Dependencies
È
D2KCOMN.OLB Object Group D2K_FILLER_COMPONENT
D2K_SHOW_WINDOW_CENTERED
D2kCOMN Specification 8
5. D2K_Finder {Package}
Finder is a package concerned with locating files, it provides a way of listing each of the
available directory locations that are contained in ORACLE_PATH, FORMS45_PATH,
FORMS50_PATH, TK23_ICON, TK25_ICON and the source directory containing the
current form. Additionally it has a procedure for checking that a named file actually exists.
You can add additional path variables to search by altering the package body initialisation
section. Any path variables that you add must be created at the same scope as
ORACLE_PATH, e.g. in the HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE branch of
the Registry, or in the current UNIX shell.
5.1. Prototype
5.1.1. Constants
None.
5.1.2. Variables
5.1.2.1.PossiblePaths [pls_integer]
PossiblePaths is initialised when this package is first accessed. It contains the number of
paths that have been extracted from the various information sources.
5.1.3. Procedures
None.
5.1.4. Functions
5.2. Dependencies
D2K_OSFILES
D2kCOMN Specification 9
6. D2K_OSFiles {Package}
OSFiles is a utility for parsing out the various components of a file name (e.g. path to file,
the name itself, file extension etc.) in a platform independent way.
6.1. Prototype
6.1.1. Constants
None
6.1.2. Variables
None
6.1.3. Procedures
None
6.1.4. Functions
6.2. Dependencies
None
D2kCOMN Specification 10
7. D2K_Res {Package}
The D2K_Res package is concerned with reading text strings from resource files. These can
be retrieved as normal strings, or as messages, or into alerts. D2K_Res can handle multiple
open resource files at once, and maintains it’s state across multiple forms, providing that the
library is shared.
7.1. Prototype
7.1.1. Constants
None
7.1.2. Variables
None
7.1.3. Procedures
7.1.3.2.CloseRes
Closes any resource files opened by InitialiseRes in this instance of the library. All the open
resource files should be closed when Forms Exits and so you’ll probably never use this
procedure in any case.
D2kCOMN Specification 11
7.1.3.4.GetMsg ( Target in varchar2,
Arg1..Arg10 in varchar2 )
GetMsg returns the specified resource in the form of a message. This can either be directed
to an alert, or to the message line. In both cases the length of the string resource will be
limited to 200 chars.
The resource string should be formatted into the following “fields” as follows with each
value delimited by a Pipe symbol “|”.
1. Text (max length implicitly 200 chars)
2. Alert Style (as varchar2) choose from ‘NONE’ (default), ‘STOP’, ‘CAUTION’ or
‘NOTE’.
3. Audible Signal: choose from ‘BEEP’ or ‘NOBEEP’ (note that messages displayed in
alerts may beep as a result of O/S setup independently of this setting)
4. Alert Title (default ‘Error’)
If and Alert style, the alert for a message will always be defined with a single button with the
text ‘OK’
So to define an message with a Stop Icon, the title of ‘Fatal Error’ the text of ‘An Error Has
Occurred’, and a beep to alert the user, you would enter the following string into the resource
file.
$Q(UURU+DV2FFXUUHG_6723_%((3_)DWDO(UURU
No terminating pipe symbol is required.
If an alert style of NONE (or blank) is selected, the message will just be echoed to the
console line rather than being popped up in an alert.
A style of STOP, CAUTION or NOTE will cause a conventional windows alert to pop up,
from which the user must press OK to exit.
If the resource string contains %s placeholders, these will be replaced with the contents of
the arguments Arg1 to Arg10.
Any tab placeholders “%t” will be replaced with a tab character
7.1.3.5.ClearMsg
Cleans off the message line.
7.1.4. Functions
D2kCOMN Specification 12
The resource string should be formatted into the following “fields” as follows with each
value delimited by a Pipe symbol “|”.
1. Text (max length implicitly 200 chars)
2. Alert Style (as varchar2) choose from ‘STOP’, ‘CAUTION’ (default) or ‘NOTE’.
3. Alert Title (default ‘Caution’)
4. Button 1 Text (default ‘OK’)
5. Button 2 Text (default ‘Cancel’)
6. Button 3 Text (default NULL - No Third button)
So to define an alert with a Stop Icon, the title of ‘Fatal Error’ the text of ‘An Error Has
Occurred’ and three buttons containing ‘Yes’, ‘No’ and ‘Cancel’ you would enter the
following string into the resource file.
$Q(UURU+DV2FFXUUHG_6723_)DWDO(UURU_<HV_1R_&DQFHO
No terminating pipe symbol is required.
The function returns the number of the button that the user pressed in response to the alert.
Use the defined forms alert button constants to compare against (ALERT_BUTTON1 etc.).
If the resource string contains %s placeholders, these will be replaced with the contents of
the arguments Arg1 to Arg10.
Any tab placeholders “%t” will be replaced with a tab character
7.2. Dependencies
D2K_Delimited_String, D2K_Finder, D2k_OSFiles, ToBoolean
È
D2KCOMN.OLB Object Group D2K_RES _COMPONENT
D2kCOMN Specification 13
8. D2K_Show_Window_Centered {Procedure}
A handy function for positioning a named window in the centre of the screen (relative either
to the MDI frame or the physical screen).
8.1. Prototype
PROCEDURE SHOW_WINDOW_CENTERED ( WindowName in VARCHAR2,
WindowStyle in VARCHAR2 := ‘DOCUMENT’,
Console in BOOLEAN := TRUE,
Xoffset in number,
Yoffset in number)
WindowStyle indicates if this is a Document or Dialog window. Documents are positioned
relative to the MDI and Dialogs to the physical Screen.
The code checks for the USESDI parameter and positions relative to the display is this is set.
Console indicates that the console line should be taken into account.
The additional arguments Xoffset and Yoffset allow you to “tweek” the position of the
centered window.
8.2. Dependencies
ToBoolean
D2kCOMN Specification 14
9. ToBoolean {Function}
A simple function primarily for converting the value of checkboxes to a boolean value, e.g. Y
become TRUE, N becomes FALSE.
9.1. Prototype
ToBoolean( Sample in varchar2,
TrueValue in varchar2 default ’Y’
) return boolean
Simply takes the sample value and compares it with the TrueValue. If they match it will
return TRUE, else FALSE. If one of the values is NULL then NULL will be returned.
The function is case insensitive.
9.2. Dependencies
None
D2kCOMN Specification 15
10. The D2KCOMN.OLB Object Library
Note: Objects in the D2KCOMN object library are all based on Points as a co-ordinate
system.
D2kCOMN Specification 16