CapeSoft.Com
Clarion Accessories
RecentLookups
Documentation
CapeSoft Logo

CapeSoft RecentLookups
Documentation

Download Latest Version JumpStart FAQ History
Installed Version Latest Version

Introduction

Lookups are one of the features common to pretty much any Clarion application. They have been in our applications since the days of Clarion for DOS. Most lookup controls though are very feature-poor, forcing the user to use out-dated techniques to look up related records.

The goal of RecentLookups is to make looking up a related record as simple, and as powerful, as it can possibly be.

Features

Jump Start

Recent Lookups contains a number of different functionalities, which can be added to your application independently of each other. In other words you may choose to implement all the functionalities, or just some of them This section explains briefly how to get the functionality into your application.

1. Import Into Dictionary

Open your application dictionary, and import the file RecentLookups.Txd. This TXD file is located in your Clarion9\accessory\libsrc\win folder. This should add a table called RecentLookups to your application. You are welcome to adapt the table to your application, for example by changing the File Driver, if you wish to do so. You may also need to change the sizes of some fields if your file driver has key-length limits. For a longer discussion on changing the table see the section entitled RecentLookups Table.

2. Add Global Extension

Add the Recent Lookups Global Extension to your application.

Set the following settings on the Global Extension; If you have a Multi-DLL system then add the global extension, to each of the apps.

Once you have done the two mandatory steps above, then you can do one or more of the following optional steps;

3. Configure Lookup Browses

Adding the global extension automatically adds the Recent Selections functionality to any browse which has a Select button. To get the most out of the functionality though, the following changes to the browse are recommended;
  1. Using the List Box Formatter, set the STYLE attribute on for the Header Field in the list control. Or better yet;
  2. (Recommended) Set the STYLE attribute on for all the columns in the list control.
  3. (Optional) On the RecentSelections Extension set the Header Field to the field you wish to contain the ALL and RECENT headers. This will default to the first String field in the List. (If you override the template, then you must also select a column which is a String.)

4. Replace Lookup Controls on Forms

To make use of the advanced Lookup control you need to replace the lookup fields on the Form. (This has nothing to do with the Recent Selections functionality - you get that regardless of whether you do this step or not. To replace a lookup control with a RecentLookups Lookup control, follow these steps;
  1. Open the form in the Window Formatter, and identify the field that can be populated via a lookup.
  2. Make a note of the variable the field is using.
  3. Delete the Entry field from the window. (Leave the prompt field alone.) If the field has a Lookup button, or description string field then remove those as well.
  4. From the Control Templates pad, select the RecentLookupControl and place it on the form where the deleted field used to be.
  5. Position and set the size of the control appropriately. Remember this will show the description, not the value, so may need to be wider than the control you had there before. You do not need to allow space for the Drop or Lookup buttons, these will be added inside the space you allocate to the Entry control.
  6. Right-Click on the control, and select Actions to see the template prompts for the control. (You will also find these prompts on the Procedure Extension list.) Fill out the field settings appropriately (For more on what each field means, see the section  Lookup Control Template.
   

RecentLookups Table

The information RecentLookups needs is stored in a table called RecentLookups. This table needs to be imported into your dictionary by importing the RecentLookups.TXD file.This TXD file is located in your Clarion9\accessory\libsrc\win folder.

The table contains a number of fields, but you are able to make changes to the table if you need to do so. Here are some of the changes you are most likely to make;
  1. Change the file driver to match the rest of your application.
  2. Set the Owner Name property to match other tables in your application - especially for SQL tables.
  3. Reduce the size of the User and Table fields to accommodate key-length or record-length restrictions imposed by your file driver of choice. The User field should be large enough to contain your application's User ID value, and the Table field should be long enough to contain your largest table name.
  4. You can reduce the number of KeyFields to match the maximum number of key fields that your dictionary has in a primary key. Typically developers have no more than 2 or 3 fields in a primary key, but RecentLookups supports up to 10 fields in a primary key. If you remove fields from the table, then you will need to remove fields from the key KeyFields as well.
  5. You can reduce the size of each Keyfield as well. They default to very large strings, and most developers use much shorter fields in their Primary Keys. To accommodate LONG values, a minimum string length of 10 is required.
Note that while changing the name of fields is permissible, changing the DATA TYPE of fields is not allowed.

Browses Used for Lookups

The Recent Selections extension template is automatically added to any browse which has a Select button. When the browse is in Select mode, then the extension is active.

The requirements for this to work on a browse are pretty straight-forward, however there are a few things you can do to make the browses look even better when being used as a Lookup.
First the Requirements;
  1. One of the fields on the browse must be a String field. Ideally this field should be in the first, or second column of the browse.
  2. This field must have the STYLE attribute turned on.
Now some of the suggestions;
  1. Turn on the STYLE attribute for all columns in the browse

Templates

Global Template

General Tab

Disable All Recent Lookup Features
This disables the Recent Lookup template, and no template code will be generated into the application. This is useful for debugging.

Saving Tab

Table
The RecentLookups table in the dictionary.
Fields Key
The key which contains the following fields; Favorite, User, Table and Keyfields.
Time Key
The key containing Favorite, User, Table, Date and Time fields.
ID Field
A unique ID string field for the table - acts as the unique row identifier (primary key) for the table.
Favorite Field
Reserved for future use.
User Field
A string containing the user ID field for your application. This allows different users to have different recent values selected for each table.
Table Field
A string to contain the name of the table the lookup was done on.
Date Field
The Date field, stored as a LONG, in the table.
Time Field
The Time field, stored as a LONG, in the table.
Key Field 1 ... Key Field 10
Up to 10 key fields, which means support for up to 10 components in a lookup key.

Options Tab

Use Secwin User
If you are using Secwin in this program, then tick this option on to automatically associate the lookup history with the currently logged in Secwin user.
Use Super Security User
If you are using Super Security (from BoxSoft) in this program, then tick this option on to automatically associate the lookup history with the currently logged in Super Security user.
Logged In User
If you are not using Secwin then enter an expression here to identify the current user.
Include Section Headers
Tick this option on to include Section Headers on lookups where recent selections exist. This adds a line for RECENT and another line for ALL.
Drop List Height
Sets the number of rows visible when a drop-list is activated on an Entry field. The default is 5 rows. This setting is used for all lookup fields, which do not have a specific drop list value of their own.

Styles Tab

Headers
Set the style, which will be applied to the list control, for the ALL and RECENT header lines.
Recents
Set the style which will be applied to all Recent values added to the lookup. This can be useful to differentiate the recent values from the normal values, if the headers are not used.

Drop Button Tab

Icon
Specify the icon to use on the drop button. This defaults to tDown.ico, but you can use any other icon that you prefer. Leave this field blank if you prefer to use text on the button rather than an icon.
Text
Instead of an icon you can place text on the button. Typically a single character as the button is very small. This can be useful though if you are using a pictoral font, like WingDings.
Font Name
If you are using text, then enter the Font name here, if it is not the default font for the window.
Flat
Tick this on to set the FLAT attribute on the button.
Background Color
If the FLAT attribute is not set, then you can set the background color for the button here.

Lookup Button Tab

Hotkey
The hotkey which when pressed on the entry field will automatically trigger the lookup. This defaults to the F2 Key (113). This is in addition to the ? key which which also acts as a hot key for the lookup.

The other settings on this tab are the same as for Drop Button (see above), but applied to the Lookup button.

Auto Complete Tab

Chars before auto-complete
The number of characters which are typed before the automatic auto-complete list appears.

Translate Tab

All
Used to indicate the ALL section in a lookup.
Recent
Used to indicate the RECENT section in a lookup.
Edit Warning
This warning will appear if the user attempts to call a form for a Recent item. recent items cannot be edited, the user must edit from the ALL section of the lookup, if indeed Editing is available at all from the lookup.

Multi-DLL Tab

This is part of a Multi-DLL Program
Tick this on if this application is a DLL or EXE which is part of a multi-app suite of apps.
Export Recent Classes from this DLL
Tick this on only if this is the data dll in the suite of apps.

Classes Tab

Class Version
An internal version number.

Recent Browse Template

General Tab

Disable This Template
Tick this on and no code for this template will be generated. Useful for debugging.
Header Field
Lets you select which field in the list control will be the designated Header column, used for the ALL and RECENT headers.

Options Tab

Use View
Reserved for future use.

Class Tab

Object Name
The name of the object which will be generated.
Class Name
the class to use for the object. Defaults to SelectRecentManager.

Recent List Template

General Tab

Disable This Template
Tick this on and no code for this template will be generated. Useful for debugging.
Control
The list control to attach this template to.
Queue
The Queue which is used to populate the selected list control.
Header Field
Lets you select which field in the list control will be the designated Header column, used for the ALL and RECENT headers.

Options Tab

Class Tab

Object Name
The name of the object which will be generated.
Class Name
the class to use for the object. Defaults to SelectRecentManager.

Lookup Control Template

Options Tab

Disable this template
Turn this on to not generate any code for this control template. This can be useful for debugging purposes.
Table
Select the remote table here. This is the table the user will be selecting from.
Desc Key
Enter the Description key for the remote table here. This field is optional, however having a key on the description field(s) in the remote table will improve the functionality of the control.
Id Key
Enter the remote table's ID Key here. This is usually the primary key of the remote table.
Linking Fields
Match up any unmatched fields here. Typically each item in the remote table's ID key appears in this list, and must be matched to a field in the local table.
More Assignments
If you are fetching data from the remote table, that is not in the primary key, then add those assignments here.
Show Lookup if Entry invalid
If this options is on and the user enters an incorrect value, and the field did not contain a correct value before, then the Lookup window is automatically displayed.
Allow Invalid Entries
If this option is on and the user types a value into the field, which is not located in the lookup, then accept the value as correct.
Allow Blank Entries
If this option is on, and the user clears a field, then allow the field to remain cleared. This allows the field to be either a valid value, or blank.
Call Reset After Lookup
If this is on then the Reset method (ABC) or RefreshWindow routine (Legacy) will be called when the contents of the lookup field changes. This is useful for fields which are acting as filters for other fields on the window, like browses.

Lookup Tab

Activate Lookup
Turn this on to include a lookup button, and functionality with the control.
Lookup Procedure
Select the name of a Lookup Procedure here. When the user clicks the lookup button, then this procedure will be called, using normal Clarion lookup calls. This lookup can have, but does not have to have, the Recent Browse Extension added to it.
Parameters
Optionally enter any additional parameters that the procedure may need here.

Auto Complete Tab

Activate Auto-Complete
Tick this on to activate Auto-Complete functionality on the entry field.
Chars before auto
The number of characters to type before the auto-complete search is done.
Order (csl)
The default sort order for the auto-complete results is the Description fields. If you wish to customize the sort order, then enter it here as a comma separated list.
Filter
If you wish to apply an additional filter to the auto-complete selection, then enter the filter here.
Display
By default the description fields will be displayed in the drop down. If you wish to customize the fields displayed in the drop list then enter an expression here.
Search Type
The auto-complete can search using a CONTAINS search or a BEGINS-WITH search. Choose the one appropriate to your situation. The default is CONTAINS.
Send Filter to Debugview
If this option is on then the filter created during the auto-complete will be sent to Debugview for debugging purposes.
Additional Search Fields
By default the search (for the letters the user has already typed) spans across all the code, and description fields. If you want the search to apply to other fields in the remote table as well, then enter them here.
Maximum Options
The maximum number of items to read from the table to display in the auto-complete list. The default vlaue is 100. The higher this value the longer it can take to read the possible options.
Drop List Height
Sets the number of rows to display when the drop-down button is pressed. If left blank then the global default value is used.
Min Drop List Width
If left blank the width of the Entry control is used to set the drop list width. However if you want the drop list have a minimu width, and hence be wider then the entry field then you can enter an expression here. If the entry is wider than this expression then the entry width will be used for the drop list, otherwise the value entered here will be used.

ViewFields Tab

Remote View Field
A VIEW structure is generated to populate the Auto-Complete list. If you are using fields in code, or in the DISPLAY setting, other than the ID and Description fields, then enter those fields here.

Class Tab

Object Name
The name of the object. Defaults this ThisLookupX where X is a number.
Class Name
The name of the class that the object is instantiated from. the default class is LookupManager.

Using in a Multi-DLL System

In your Data-DLL: In your other applications (that use RecentLookups) - including DLL and EXE apps:

Example

There are a number of examples that ship with RecentLookups;
  1. ABC
    An example of using RecentLookups in a single ABC Template based EXE program
  2. Legacy
    An example of using RecentLookups in a single Clarion Template based EXE program
  3. MultiDLLABC
    An example of using RecentLookups in an ABC program, comprising of a Data DLL, an EXE and other DLL's.
  4. MultiDLLLegacy
    An example of using RecentLookups in a Clarion Template program, comprising of a Data DLL, an EXE and other DLL's.

Embed Code

This section shows specific embed code that you might want to use in specific situations.

Updating the contents of the lookup control when the ID field changes

When a form opens the lookup controls are automatically synchronized with the child tables. In other words the child records are loaded and the necessary description fields are placed in the entry control. If you change the underlying ID in code though you want the description to change as well. This is accomplished with the following line of embed code;

Inv:CustomerId = 'newId'   ! This is your line of code to change the ID
ThisLookup1.LocalChanged() ! This is the line you add to update the lookup control

another example;

Access:Invoices.Fetch(somekey) ! a new record has been loaded
ThisLookup1.LocalChanged()     ! this is the line you add to update the control

Controlling the Description field in the Lookup Field

When using the lookup control, a description field (or fields) are displayed instead of the "code" field. This is desirable because this makes for a much more intuitive interface for the user to use. In most cases you simply enter a "description key" for the lookup table, and the fields from that key are used by the class and everything just works.

In some cases however the description field is not in the lookup table at all, and thus no description key exists. You can of course simply leave the key setting blank and the code field will be used instead. Alternatively you can use embed code to control the relationship between the code field, and the description you wish to display. This section in the document explains the requirements for your code.

In order to use your own description fields, it is a good idea to set the Desc Key field for the control to nothing.


RemoteFileLinks

The next step is to embed code to identify the fields you will use. This is done in the RemoteFileLinks method in your procedure. Note that if you have multiple lookup fields on the window you will want to make sure you are embedding into the correct method, so check the Class tab for the correct name.

The code you will add will come after the Parent call in this method.
There are two distinct properties to set here, and each is an Array, so there are also two "counter" properties to add.

The first property to set is an array called RemoteDesc. You are allowed up to 5 of these for one entry field. This property determines the text which will be visible to the user in the display field. These are assigned using a &= operator. The DescFields is set to indicate how many of the array fields are used. For example;

self.RemoteDesc[1] &= 'inv:date'
self.RemoteDesc[2] &= 'cus:name'
self.DescFields = 2


The second property to set is called RemoteDescName. This is used when creating the filter for auto-complete. It is used to best match what the user is typing. The fields used here need to be in the tables used by the View [1]. As before there is a property containing the umber of fields used. This property is called DescNameFields.  If the auto-complete feature is turned off, or suggesting auto-complete options via the description is not practical, then you can just set DescNameFields to 0. For example;

Self.RemoteDescName[1] = 'inv:date'
Self.DescNameFields = 1


[1] A view is generated into the LoadSuggestions method, and is used to populate the auto-complete lookup list. You can add additional tables to the View if you wish by embedding JOIN commands.

GetEntryDescription

By default the description field displayed to the end user is a space separated list of the RemoteDesc fields. Should you wish to alter this description then you can do so in the GetEntryDescription method. For example, to replace the space separator with a / separator you might have code as follows;

Return clip(Self.RemoteDesc[1]) & '/' & clip(Self.RemoteDesc[2]))

LoadRemoteRecordDesc

If the user types an entry in the lookup field and moves on to a new field then a lookup is done to find the record that the user is specifying. This is done in the LoadRemoteRecordDesc method. Since the template setting Desk Key is blank this method does nothing and simply returns -1.

If this facility is possible using the alternate description, then you can add your own embed code to find the appropriate lookup record here. Your code should do the following things in order to indicate success;
  1. load the lookup table record with the correct record.
  2. set the self.RemoteFound property to true
  3. Return 0
If it is not possible for the user to type an entry which can be matched to the record they are looking for, then you can choose not to embed any code in this method and this feature will not exist. (It is still possible for the user to type the code field.)

Class Reference

RecentBase

The RecentBase class is an internal class which covers functionality common to the other classes. It covers mostly debugging and logging functionality.

Properties

PropertyTypeDescription
LoggingOnLongIf this property is set to 1, then calls to the LOG method are automatically passed on to the TRACE method, and hence output to DebugView.
ProcStringThe name of the procedure which owns the object.
SuppressErrorsLongIf this error is true, then calls to the ERRORTRAP method will not generate a MESSAGE to the user. If this is false then Errors are displayed to the user as a MESSAGE statement.

Methods

DebugEvent

DebugEvent (string pExtra)

Description

Sends a string version of the current event, along with the current field() and keycode() values to the trace method. The contents of the extra parameter are passed to the trace method as well. Typically called from a TakeEvent method to help debug the sequence of events.

Parameters

ParameterDescription
pExtra StringAdditional information to include in the call to trace.

Return Value

none

See Also

Trace

ErrorTrap

ErrorTrap (string pProc, string pStr)

Description

Displays a message to the user when some unexpected error occurred. These messages can be suppressed by setting the SuppressErrors property to true. The message is also passed on to the Log method.

Parameters

ParameterDescription
pProc StringThe name of the method that made the call.
pStr StringThe Message to display to the user (if the SuppressErrors property is 0)

Return Value

none

See Also

Log

InterpretEvent

InterpretEvent ([long pEvent])

Description

Converts an event code into an English description of the event. Used by the DebugEvent method to translate event codes into Event descriptions.

Parameters

ParameterDescription
pEvent Long (optional)The event to interpret. If omitted then the current Event() value is used.

Return Value

none

See Also

DebugEvent

Log

Log (string pStr)

Description

Sends the pStr value to the Trace method, but only if the LoggingOn property is true.

Parameters

ParameterDescription
pStr StringThe string to add to the log

Return Value

none

See Also

Trace

Trace

Trace (string pStr)

Description

Sends a string to standard windows debugging output (like DebugView.Exe). Includes the tag [rec] the thread number and the procedure name.

Parameters

ParameterDescription
pStr StringThe string to send to Debugview.

Return Value

none

See Also

Log

LookupManager

The LookupManager is derived from the RecentBase class, so all those methods and properties apply here as well.

Properties

PropertyTypeDescription
AsAtTextSTRINGLast known contents of the entry control.
AutoCompleteLONGSet to true if the Auto Complete functionality is active.
AutoCompleteLenLONGNumber of characters to type before auto-complete automatically displays the options. Default is 2.
AutoLookupWhenEntryInvalidLONGIf set to true, and the user types an invalid entry, then the Lookup browse automatically appears.
DescFieldsLONGNumber of description fields in the remote table.
DropButtonLONGFEQ of the Drop button
EntryControlLONGFEQ of the entry control
EntryTextSTRINGCurrent contents of the entry control.
HotKeyLONGKeycode of the HotKey used to Trigger a Lookup. F2Key by default.
LinkedFieldsLONGNumber of id fields in the link between the local table and the remote table.
ListControlLONGFEQ of the List Control
LocalIdANY,Dim(MaxLinkFields)Array of pointers to the id fields in the local table.
LookupLONGSet to true if the Lookup functionality is active.
LookupButtonLONGFEQ of the Lookup Button
LookupResultLONGValue returned from the lookup procedure.
RemoteDescANY,Dim(MaxDescFields)Array of pointers to the fields in the description key of the remote table.
RemoteDescKey&KEYPointer the the description key in the remote table.
RemoteDescNameString,Dim(MaxDescFields)Names of all the fields in the remote table description key.
RemoteFile&FILEFile pointer to the remote file structure.
RemoteIdANY,Dim(MaxLinkFields)Array of pointers to the id fields in the remote table.
RemoteIdKey&KEYPointer to the ID key in the remote table.
RemoteIdNameANY,Dim(MaxLinkFields)Names of all the fields in the remote table ID key.
Suggestions&SuggestionsQueueTypeThe queue used for the List Control. Contains the auto-complete suggestions.
SuggestionsQueueType  
DisplaySTRINGText displayed in the List Control as an auto-complete suggestion.
DisplayStyleLONGThe style number used for the List Control
SuggestionIDSTRING,Dim(MaxLinkFields)The ID value(s) for the record.
SuggestionDescSTRING,Dim(MaxDescFields)The Description value(s) for the record.

Methods

MethodDescription
AfterChangeCalled after the entry field is changed, via either a Lookup or the user typing something.
AfterEntryCalled when the entry field has been changed by the user typing something into the field.
AfterLookupCalled when the user returns from a lookup window.
CheckFilterChecks the filter set by SetFilter when the user enters a code, or description, directy.
ClearFieldClear the entry field. (Same as the Clear button.)
DisableDisable the field (and related fields) on the window.
DisableUnderneath Disables fields under the list control.
Drop Open the Drop list (Same as the Drop button.)
EnableEnable the field (and related fields) on the window.
EnableUnderneath Enables fields previously disabled with DisableUnderneath.
GetEntryDescription Returns the description as a single string.
HideHide the field (and related fields) on the window.
HideSuggestionsHides the drop-down list.
InitInitializes the object and sets various properties to match desired behaviors.
LocalChangedLoads the foreign record if the contents of the lookup field has changed.
LoadSuggestionsA method that loads suggestions into the drop-list, as the user types.
MakeFilterMakes the filter for the VIEW as the user types.
ReadOnlySets the entry field as read-only.
RefreshRefreshes the state, and position of the various controls, with respect to the entry control.
SetFilterSets the filter for records that can be entered directly into the Entry control.
SetListPositionSets the position of the list control
ShowSuggestionsShows suggestions to the user (as a drop-down list) as they are typing.
UnhideUnhide the field (and related fields) on the window.

AfterChange

AfterChange()

Description

Called after the entry field is changed, via either a Lookup or the user typing something. Used by the template to embed additional assignments and so on.

Parameters

none

Return Value

none

See Also

AfterEntry, AfterLookup

AfterEntry

AfterEntry()

Description

Called when the entry field has been changed by the user typing something into the field.

Parameters

none
Return Value

none

See Also

AfterChange, AfterLookup

AfterLookup

AfterLookup()

Description

Called when the user returns from a lookup window.

Parameters

none

Return Value

none

See Also

AfterChange, AfterEntry

CheckFilter

CheckFilter()

Description

Evaluates the filter set by the SetFilter method.

Parameters

none

Return Value

0 if the record is successful, non-zero if it is not successful.

notes

This method is called when a user enters an ID or Description directly into the entry field. It will only be called if a record matching the ID or Description is found. Only the lookup record is loaded at this point. Therefore if the filter contains additional records then those need to be loaded manually (most likely in the CheckFilter method, before the parent call).

See Also

SetFilter

ClearField

ClearField()

Description

Clear the entry field. (Only does anything if the AllowBlank property is set.) Same as clicking on the Clear button (X) on the entry control.

Parameters

none

Return Value

none

See Also

Hide, Disable, ReadOnly

Disable

Disable()

Description

Disable the field (and related fields) on the window.

Parameters

none

Return Value

none

See Also

Hide, Unhide, Enable, ReadOnly, ClearField

DisableUnderneath

DisableUnderneath()

Description

When a drop-list appears it can overlap other fields on the window. These other fields in turn can interact with the list visually, and in responding to mouse-clicks. In order to prevent this fields (wholly or partially) under the list control are disabled while the list is open. This method finds the applicable controls, and disables them.

Parameters

none

Return Value

none

See Also

EnableUnderneath

Drop

Drop (<Long pShow>)

Description

Triggers the same behavior as the user clicking on the drop button.

Parameters

ParameterDescription
pShowIf true then the Drop list is displayed. If false then the drop list is hidden. If omitted then the state of the drop list is toggled (as if the user pressed on the Drop button.)

Return Value

none

See Also

ShowSuggestions, HideSuggestions

Enable

Enable()

Description

Enable the field (and related fields) on the window.

Parameters

none

Return Value

none

See Also

Hide, Unhide, Disable, ReadOnly

EnableUnderneath

EnableUnderneath()

Description

Enable the fields disabled with a previous call to DisableUnderneath.

Parameters

none

Return Value

none

See Also

DisableUnderneath

GetEntryDescription

GetEntryDescription()

Description

Returns a description for the selected row. By default this is a space separated concatenation of the .RemoteDesc properties. You can override this method to alter the description in some way.

Parameters

none

Return Value

String. The description for the row.

See Also

Controlling the description in the lookup field

Hide

Hide()

Description

Hide the field (and related fields) on the window.

Parameters

none

Return Value

none

See Also

Unhide, Enable, Disable,, ReadOnly, ClearField

HideSuggestions

HideSuggestions()

Description

Hide the drop-list if it is open.

Parameters

none

Return Value

none

See Also

Drop, ShowSuggestions

Init

Init (String pProc, File pTable, Key pIdKey, <Key pDescKey>, Long pEntryControl=0, Long pLookup, Long pAutoComplete, Long pAutoCompleteChars=3, Long pHotKey=0, Long pAutoLookup=0, Long pAllowInvalid=0, Long pAllowBlank=0)

Description

Initializes the object and sets various properties to match desired behaviours.

Parameters

ParameterDescription
pProcSets the .proc property. This is used by the TRACE method for debugging purposes.
pTableThe name of the foreign table which this field is looking up on.
pIdKeyThe Key in the foreign table to use as the ID Key. The ID Key field will usually be the value stored by the calling form.
pDescKeyThe Key (if it exists) containing the description field. If this is set then the user will see, and can enter, the description field instead of the code field.
pEntryControlThe Use Equate of the entry field on the window.
pLookupSet to true if the lookup button should be visible to the user.
pAutoCompleteSet to true if the auto-complete functionality (via the drop list) should be visible to the user.
pAutoCompleteCharsThe minimum number of characters the user needs to type before the auto-complete begins.
pHotKeyA hotkey to use to trigger the lookup automatically. Defaults to F2.
pAutoLookupIf true, and the user types an invalid entry, then the Lookup window (if it exists) is automatically called.
pAllowInvalidIf true the user is allowed to type entries that are not in the foreign table.
pAllowBlankIf true then this field is allowed to be blank. If false then this is effectively a REQUIRED field.

Return Value

none

LocalChanged

LocalChanged (Long pDisplay=true)

Description

If the local ID field has changed (in embed code) then this method can be called to load the matching foreign-table record.

Parameters

ParameterDescription
pDisplayIf true, updates the entry field with the updated description value.

Return Value

none

See Also

Updating the contents of the lookup control when the ID Field changes


LoadSuggestions

LoadSuggestions()

Description

A method that loads suggestions into the drop-list, as the user types.
The suggestions list is a queue (self.Suggestions property) of type SuggestionsQueueType.

Typically the template generates a VIEW in order to populate the suggestions, but you could override this with alternate code if you wanted to.

Parameters

none

Return Value

none

See Also

MakeFilter

MakeFilter

MakeFilter (<string pField1>,....,<string pField10>)

Description

Makes the filter for the VIEW as the user types.

Parameters

ParameterDescription
pField1 ... pField10One or more (up to 10 fields) to do the search on.

Return Value

A filter which can be applied to the VIEW to return a list of suggestions into the drop listbox.

Notes

In builds prior to 1.30 this method had an optional first parameter containing an additional filter to apply. This parameter was removed in build 1.30 and the SetFilter method called instead.

See Also

LoadSuggestions, SetFilter

ReadOnly

ReadOnly (Long pReadOnly=true)

Description

Sets the entry field as read-only.

Parameters

ParameterDescription
pReadOnlyIf true, or omitted, then the entry field is displayed as Readonly. If the field is Readonly then the Drop, Lookup and Clear buttons are hidden. Set this parameter to false to make the field not read-only.

Return Value

none

See Also

Hide, Unhide, Enable, Disable, ClearField

Refresh

Refresh()

Description

Refreshes the state, and position of the various controls, with respect to the entry control. For example if the entry control itself is moved, or hidden, then this method should be called.

Parameters

none

Return Value

none

See Also

Hide, Unhide, Enable, Disable, ReadOnly

SetFilter

SetFilter (String pFilter)

Description

Sets the filter that should be applied to the child table when the user opens the Droplist or types a code or description directly. The filter is not applied at the time this call is made, it just sets the filter for when it is needed. the filter is checked later on by the Checkfilter method.

The filter parameter is tested to make sure it can be evaluated by the VIEW engine later on. If the filter is not correct then the filter is set to false (meaning that no records are available to the user), an error is written to Debugview, and a non-zero value is returned.

Parameters
ParameterDescription
pFilterA filter which limits the options available for the user to select, either via the Droplist, or by typing a code, or description directly into the entry field.

Return Value

0 if the filter is syntactically correct, an errorcode() if it is not correct.

See Also

CheckFilter, MakeFilter

SetListPosition

SetListPosition (Long px, Long py, Long pw, Long ph)

Description

Sets the position of the DropList control. Called automatically when the list control is unhidden.

Parameters

ParameterDescription
pxX Position of the List control
pyY Position of the List control
pwWidth of the list control. If the MinDropWidth property is set, and this is less than that, then the MinDropWidth property is used instead.
phThe height of the List control

Return Value

none

See Also



ShowSuggestions

ShowSuggestions (Long pSelect=0)

Description

Shows suggestions to the user (as a drop-down list) as they are typing. If the list is not already visible it will be displayed.

Parameters

ParameterDescription
pSelectThe row in the list to pre-select.

Return Value

none

See Also

Drop, HideSuggestions

Unhide

Unhide()

Description

Unhide the field (and related fields) on the window.

Parameters

none

Return Value

none

See Also

Hide, Enable, Disable, ReadOnly

SelectRecentManager

The SelectRecentManager is derived from the RecentBase class, so all those methods and properties apply here as well.

Properties

PropertyTypeDescription
AllTextSTRINGThe text to display at the top of the ALL section in the lookup.
ControlLONGThe List control into which the recent values will be injected.
CurrentPrimaryKey&KEYA pointer to the primary key of the lookup table.
CurrentRecord&GROUPA pointer to the record structure of the lookup table.
FieldsKey&KEYA pointer to the Fields Key in the RecentLookups table structure.
File&FILEA pointer to the RecentLookups table structure.
IncHeadersLONGIf set to true then the ALL and RECENT headers are added into the Queue for the list control.
InitializedLONGAn internal property, set when the class has been correctly initialized.
MaxRememberLONGThe number of items to store, and display for each lookup. the default value is 5.
PopulateDoneLONGSet once the lsit has been populated with the recent values.
Q&QUEUEA pointer to the Queue, which is the source data for the list control.
qNameANYA pointer to the "Header column" field.
qNameStyleFieldNumberLONGThe field number, for the Style field, of the Header column.
RecentTextSTRINGThe text to display at the top of the RECENT section in the lookup.
tDate&LONGA pointer to a field in the RecentLookups table containing the Date Stamp when the record was last written to.
tFavorite&LONGReserved for future use.
tID&STRINGA pointer to a field in the RecentLookups table containing the ID field (the Primary Key field) for the table itself.
TimeKey&KEYA pointer to the Time Key in the RecentLookups table structure.
tKF&STRING,DIM(MaxKeyFields)An array of pointers to the Key Fields in the RecentLookups Table structure.
tTable&STRINGA pointer to the field in the RecentLookups table which contains the Table name.
tTime&LONGA pointer to a field in the RecentLookups table containing the Time Stamp when the record was last written to.
tUser&STRINGA pointer to a field in the RecentLookups table containing the User login.
View&VIEWA Pointer to a VIEW structure, used for populating the queue.

Methods

CloseFile

CloseFile()

Description

Closes the RecentLookups table.

Parameters

None

Return Value

None

See Also

OpenFile

GetFieldLabel

GetFieldLabel (*File pFile, Long pX)

Description

Returns the label of a field (not the external name) given a file structure and a field number.

Parameters

ParameterDescription
pFile  FILEThe name of the File structure.
pFieldNumber LongThe Field Number in the structure.

Return Value

A string containing the label of the field.

Init

Init (String pProc, Long pControl, Long pHeaders, String pAllText, String pRecentText)

Description

Initializes the object with some basic behaviours.

Parameters

ParameterDescription
pProc  StringThe name of the procedure which owns the object.
pControl LongThe Field Equate (FEQ) of the List Control
pHeaders LongSet to True to include the ALL and RECENT headers in the list.
pAllText StringThe text to include at the top of the ALL section.
pRecentText StringThe text to include at the top of the RECENT section.

Return Value

none

IsHeaderSelected

IsHeaderSelected()

Description

Determines if the user just selected a "Header" record. Called from the TakeEvent method. If the user did select a header row then the selection moves down another row.

Parameters

None

Return Value

Returns True if the user just selected the ALL or RECENT header record.

See Also

TakeEvent

OpenFile

OpenFile()

Description

Opens the RecentLookups table.

Parameters

None

Return Value

none

See Also

CloseFile

PopulateFromFile

PopulateFromFile(File pFile, <View pBrowseView>, <String pUser>, String pTable, Long pForce=0)

Description

Adds the headers, and recent selections, to the List control. If the PopulateDone property is already set (and the Force parameter is not set) then

Parameters

ParameterDescription
pFile FILEA handle to the table being looked up on.
pBrowseView VIEW (optional)An optional link to the Browse View so that secondary records can be loaded into the "recent" lines.
pUser String (optional)A string identifying the current user in the program. This allows each user to have a different recent selections list.
pTable String (optional)The name of the table being looked up on.
pForce Long (optional)If true then the recent entries are added to the list control, regardless of whether the PopulateDone property is set or not.

Return Value

none

See Also



PopulateFromView

PopulateFromView(<String pUser>, String pTable, Long pForce=0)

Description

Reserved for future use.



PopulateName

PopulateName(String pName)

Description

Adds a header line to the Queue under the List control

Parameters

ParameterDescription
pName StringThe text of the header to add. (This is usually one of self.AllText or self.RecentText

Return Value

None

PrimeRecord

PrimeRecord()

Description

Sets the Date, Time and Key fields in the RecentLookups table. The date and time are primes to now, the Key fields are primed to the key values in the Lookup table.

Parameters

None

Return Value

None

RecordSelected

RecordSelected(File pFile, Long pFavorite=0, <String pUser>, String pTable)

Description

Called when a record in the lookup table has been selected. the selection is stored in the RecentLookups table.

Parameters

ParameterDescription
pFile FILEThe table which was just used for the Lookup.
pFavorite Long (optional)Set to recent:LookupSelection (the default) or recent:Favorite
pUser StringA string containing an identifier for the currently logged in user.
pTable StringThe name of the table on which the Lookup just occured.

Return Value

None

SetFile

SetFile(File pFile, Key pFieldsKey, Key pTimeKey, *String pId, *Long pFavorite, *String pUser, *String pTable, *Long pDate, *Long pTime, *string pkf1, <*string pkf2>,<*string pkf3>, <*string pkf4>,<*string pkf5>, <*string pkf6>,<*string pkf7>, <*string pkf8>,<*string pkf9>, <*string pkf10>)

Description

Primes all the internal properties with the various keys, and fields, in the RecentLookup table. Usually called as part of the Object Initialization, after the call to .INIT.

Parameters

ParameterDescription
pFile FILEThe RecentLookups table.
pFieldsKey KEYThe key in the RecentLookups table on the Favorite, User, Table , Keyfield1, ... fields
pTimeKey KEYthe key in the RecentLookups table on the Favorite, User, Table, Date, Time fields.
pID StringThe ID field in the RecentLookups Table.
pFavorite LongThe FAVORITE field in the RecentLookups Table.
pUser StringThe USER field in the RecentLookups Table.
pTable StringThe TABLE field in the RecentLookups Table.
pDate LongThe DATE field in the RecentLookups Table.
pTime LongThe TIME field in the RecentLookups Table.
pKF1... pKF10 StringThe Keyfield1 to Keyfield10 fields in the RecentLookups Table.

Return Value

None

SetQueue

SetQueue(Queue pQueue,*? pName)

Description

Sets the internal Q property, and the variable which will be used for header column. Usually called right after the call to .INIT.

Parameters

ParameterDescription
pQueue QueueThe Queue used by the List control.
pName ANY (optional)The variable assigned to the column in the list box, that should be used as the Header column. (If not specified this defaults to the first String column in the queue.)

Return Value

None


SetQueueRecord

SetQueueRecord()

Description

Populates the Recent row, when a Recent row is added to the List control. This calls the BrowseClass.SetQueueRecord method (in ABC) or the FillQueue routine (in Legacy).

When this method is called the Table record buffer needs to have been loaded.

Parameters

None
 
Return Value

None

SetStyle

SetStyle(Long pUseFor, Long pFrontColor, Long pBackColor, <string pName>, <String pSize>, Long pStyle=700)

Description

Sets the styles to the list box.

Parameters

ParameterDescription
pUseFor  LongOne of recent:StyleHeader, recent:StyleHeaderX, recent:StyleRecent.

recent:StyleHeader
is used for the ALL and RECENT text. recent:styleHeaderX is used for all the other columns in a header row. Typically it's the same as the recent:StyleHeader, but with the text color set to be the same as the background color.

The recent:StyleRecent style is used for the actual rows of recently selected data.
pFrontColor  LongThe foreground (text) color
pBackColor LongThe background color
pName String (optional)The Font to use.
pSize String (optional)The size of the font to use. This can be a "relative" value, eg '+1' or '-2' and so on.
pStyle Long (optional)the Style value for the font. Font:Regular or Font:Bold and so on.

Return Value

None

SetStylesItem

SetStylesItem(Long pStyle)

Description

Sets the Style and/or Color fields for all columns in a Quick-Selection row.

Parameters

ParameterDescription
pStyle LongThe style to apply to all the columns.

Return Value

None

See Also

SetStyle, SetStylesHeader

SetStylesHeader

SetStylesHeader(Long pStyleX,Long pStyle)

Description

Sets the Style and/or Color fields in  a row, based on the styles set with the SetStyle method. This method is called when adding the RECENT and ALL heading rows to the list.

Parameters

ParameterDescription
pStyleX LongThe style for all the columns except the column with ALL or RECENT in it.
pStyle LongThe style for the Header column (ie the column with the word ALL and RECENT.

Return Value

None

See Also

SetStyle, SetStylesItem

SetView

SetView(View pView)

Description

Reserved for future Use.


TakeEvent

TakeEvent()

Description

Gets called for every event on the window. Any Event-dependent code is added here.

Parameters

None
 
Return Value

None

SyncBrowseView

SyncBrowseView(View pBrowseView, String pFilter)

Description

Calls either SyncBrowseViewTPS or SyncBrowseSQL depending on the driver used by the primary table in the View.

Parameters
ParameterDescription
pBrowseView VIEWThe view being used to populate the browse.
pFilter StringA filter, constructed in PopulateFromFile, so that the correct record in the view is located.

Return Value

Returns nothing, however the secondary fields are loaded into their respective file records.

See Also

SyncBrowseViewISAM, SyncBrowseViewSQL

SyncBrowseViewISAM

SyncBrowseViewISAM(View pBrowseView, String pFilter)

Description

Loads a record using the Browse View structure, which ensures that all secondary fields joined in the view are loaded.

Parameters
ParameterDescription
pBrowseView VIEWThe view being used to populate the browse.
pFilter StringA filter, constructed in PopulateFromFile, so that the correct record in the view is located.

Return Value

Returns nothing, however the secondary fields are loaded into their respective file records.

See Also

SyncBrowseViewSQL, SyncBrowseView

SyncBrowseViewSQL

SyncBrowseViewSQL(View pBrowseView, String pFilter)

Description

Loads a record using the Browse View structure, which ensures that all secondary fields joined in the view are loaded.

Parameters
ParameterDescription
pBrowseView VIEWThe view being used to populate the browse.
pFilter StringA filter, constructed in PopulateFromFile, so that the correct record in the view is located.

Return Value

Returns nothing, however the secondary fields are loaded into their respective file records.

See Also

SyncBrowseViewISAM, SyncBrowseView

ValidateRecord

ValidateRecord()

Description

Checks to make sure that a recently selected row in the browse, is still valid for the filter being applied to the current lookup browse.

Parameters

None

Return Value

None

See Also



Frequently Asked Questions

  1. Hiding / Unhiding an entry control

1. Hiding / Unhiding an entry control

See the Hide and Unhide methods

Support

Your questions, comments and suggestions are welcome. See our web page (www.capesoft.com) for new versions. You can also contact us in one of the following ways:
CapeSoft Support
Email
Telephone +27 87 828 0123 or
087 828 0123

CapeSoft Sales
Web www.capesoft.com
Email sales at capesoft dot com
Telephone +27 87 828 0123 or
087 828 0123
Fax +27 21 715 2535
Post PO Box 511, Plumstead, 7801, Cape Town, South Africa

Installation

Run the supplied installation file.

Distribution

This product is supplied as source files that are included in your application. There are no additional files for you to add to your distribution.

License and Copyright

This template is copyright © 2017 by CapeSoft Software. None of the included files may be distributed. Your programs which use this product can be distributed without any royalties due on this product.

Each developer needs his own license to use this product. (Need to buy more licenses?)

This product is provided as-is. Use it entirely at your own risk. Use of this product implies your acceptance of this, along with the recognition of the copyright stated above. In no way will CapeSoft Software, their employees or affiliates be liable in any way for any damages or business losses you may incur as a direct or indirect result of using this product

Version History

Version 1.30 (2 May 2017) Version 1.29 (20 March 2017) Version 1.28 (13 March 2017) Version 1.27 (31 October 2016) Version 1.26 (26 September 2016) Version 1.25 (20 September 2016) Version 1.24 (12 September 2016) Version 1.23 (24 June 2016) Version 1.22 (12 January 2016) Version 1.21 (30 October 2015) Version 1.20 (7 October 2015) Version 1.19 (26 August 2015) Version 1.18 (23 July 2015) Version 1.17 (22 July 2015) Version 1.16 (20 July 2015) Version 1.15 (10 April 2015) Version 1.14 (25 February 2015) Version 1.13 (4 January 2015) Version 1.12 (5 December 2014) Version 1.11 (24 November 2014) Version 1.10 (10 November 2014) Version 1.09 (20 October 2014) Version 1.08 (9 October 2014) Version 1.07 (3 Sept 2014) Version 1.06 (18 July 2014) Version 1.05 (27 January 2014) Version 1.04 (17 December 2013) Version 1.03 (4 December 2013) Version 1.02 (3 December 2013) Version 1.01 (3 December 2013) Version 1.00 (29 November 2013)