maxLength

maxLength specifies maximum length in bytes for strings input to a field.

 

in Lycia Form Designer

 

Form XML code:

 

<element_name maxLength="125">

 

By default, maxLength is not specified and is absent from the form and theme XML codes. The property value will appear in the form and theme XML codes only once it is specified.

 

 

Possible values: any integer (limited by the data type (and size) of a variable assigned to the field)

 

Default value: depends of the data type (and size) of a variable assigned to the field

 

Associated containers, widgets and theme elements:

Browser

Calendar

ComboBox

FunctionField

TextArea

TextField

TimeEditField

 

Associated 4gl syntax:

INPUT

INPUT ARRAY

 

Associated ui methods:

SetMaxLength

GetMaxLength

 

Influence and behavior:

 

 

 

 

The value set to the property specifies the maximum length (in bytes) you will be able to input into the field:

 

lycia form designer

For the first textArea (identifier=f1), maxLength=5:

 

 

For the second textArea (identifier=f2), maxLength=10:

 

 

4gl code

MAIN

DEFINE f1, f2 STRING

 

OPEN WINDOW w WITH FORM "maxLength" ATTRIBUTE(BORDER)

 

MENU

  COMMAND "input"

    INPUT BY NAME f1 WITHOUT DEFAULTS

    INPUT BY NAME f2 WITHOUT DEFAULTS

  COMMAND "exit"

    EXIT MENU

END MENU

 

END MAIN

 

intended input

0123456789

 

runtime appearance

 

When set together with autonext, the property can be used in order to increase the interface user-friendliness.

 

 

 

 

 

At runtime, you can use ui methods to find out the maximum length of the data string which can be input to the field and change it:

 

LET widget_var = ui.<widget>.ForName("widget_id1")

CALL widget_var.setMaxLength(<int>)

 

4gl code sample

DEFINE ta_1 ui.TextArea

...

LET ta_1 = ui.TextArea.ForName("f1")

CALL ta_1.setMaxLength(10)

 

DEFINE ta_2 ui.TextArea

...

LET ta_2 = ui.TextArea.ForName("f2")

CALL ta_2.setMaxLength(5)

 

initial runtime appearance

runtime appearance after ui methods were applied

 

LET widget_var = ui.<widget>.ForName("widget_id1")

DISPLAY widget_var.getMaxLength()

 

4gl code

MAIN

DEFINE f1, f2 STRING,

       ta_1, ta_2 ui.TextArea

 

OPEN WINDOW w WITH FORM "maxLength" ATTRIBUTE(BORDER)

LET ta_1 = ui.TextArea.ForName("f1")

LET ta_2 = ui.TextArea.ForName("f2")

 

MENU

 COMMAND "display"

  DISPLAY "With f1, maxLength=", ta_1.getMaxLength(), "."

  DISPLAY "With f2, maxLength=", ta_2.getMaxLength(), "."

 COMMAND "change"

  CALL ta_1.setMaxLength(10)

  CALL ta_2.setMaxLength(5)

 COMMAND "exit"

  EXIT MENU

END MENU

 

END MAIN

 

runtime appearance

 

 

Example programs:

CVS server: client.querix.com

CVS repository: /lycia_doc_examples

User: client

Project: form_properties

Program: maxlength

 

Related articles:

autonext