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:

1.

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

2.

Set the Immediate property to TRUE.

3.

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

4.

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.

5.

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:

UPDATE(?PRE:FieldName)

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

! use size of -1 with CSTRING or PSTRING

 SELECT(?+1)

END     !IF

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

UPDATE(?PRE:FieldName)

Str" = PRE:FieldName

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

 SELECT(?+1)

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.

6.

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.