How to Complete an Entry Field when the Last Character is Entered

Top  Previous  Next

In Clarion's older DOS products, an entry field with the immediate attribute (IMM) was automatically completed when the last character was typed. In Clarion, the IMM attribute behaves differently. In Clarion, an entry field with the IMM attribute generates an Event:NewSelection as each character is typed.

To mimic the behavior of the Clarion DOS products, a few lines of embedded source code are needed.

In the Window Designer:


RIGHT-CLICK on the control, then select Properties to open the Properties Pad.


Set the Immediate property to TRUE.


RIGHT-CLICK on the control and select Embeds to access the Embedded Source dialog.


Select the Control Event Handling--Event:NewSelection embed point for the control, then press the Insert button.

This embed point will only appear after you have checked the Immediate box.


Select SOURCE and type one of the following code segments in the Embedded Source Code Point:

Use this code if the field is a string:


IF LEN(CLIP(PRE:FieldName)) = SIZE(PRE:FieldName) AND KEYCODE()<> MouseLeft

! use size of -1 with CSTRING or PSTRING


END     !IF

Use this code if the field is any non-string numeric data type:


Str" = PRE:FieldName

IF LEN(CLIP(Str") = 5 AND KEYCODE() <> MouseLeft


END     !IF

In this example the value of the field is assigned to an implicit string variable (Str") so that its length can be determined. Its length is compared to a constant number (in this case 5) instead of using the SIZE function. Since SIZE() returns the number of BYTES in the Use variable, it is not a valid comparison for numeric data types.


Set the Priority to 2500.

This example does not handle leading zeros. If your data can contains leading zeros, you will have to modify the embedded source code to handle them.