How to make LEN(n-m) dynamic?

Author: (istiller)

Hi  freaks

We do have a textfield, 70 characters long, for names. Our customers do have differnt third party products (CRMs), each of them accept other name length.

Now we got the request to limit the input in out UnifAce application.

Okay, one can use the LFLD-trigger to check the length an reject the input if to long. But the user could input up to 70 characters without any warning but only when he/she leaves the field.

When using LEN(0-30), the user can only 30 characters, but this is fix at compile time. As a VAR and with different third party products this is not a solution for us.

Any other idea beside LFLD?

Or should I write a (never read/fulfilled)  wish :-)





  1. Hi Ingo,

    another awful option:

    intercept each keystroke and check the length of the string
    with all the known problems about SMOD and $char.


    Author: ulrich-merkel (
  2. Hello,

    one strange idea would be to use a field for every single input length you need (i.e. 1 field for 30chars, 1 for 70chars, 1 for 150chars) and then use combination of hiding (HID) fields and moving fields ($paintedfieldsproperties) - so at any time only 1 fields would be visible - the one you need.


    PS: We are crying for real dynamic forms (moving everything, dynamic almost all properties of fields including Interface, Syntax, Layout) for several years. Unfortunately, it seems our crying is not strong enough, and our dreams has never came true. :-) But we won't give up. ;-)

    Author: sochaz (
  3. Hi Zdeněk

    Your idea is the same then we do have :-)

    So we need 70 painted fields for every database field. And this a least three times (first_name, last_name_1, last_name_2,...)

    That  are over 200 fields, but where to place (hidden) on the surface.  Worse, when this fields are in a "grid"

    So, as a wise man said a few years ago: "I have a dream. I have a dream that some times UnifAce will have a dynamic surface"  :-)








    Author: istiller (
  4. Hi

    Setup a component variable $MAX_FIELD_LENGTH$ and assign the dynamic length  to it.

    In the StartMod trigger of your unifield, use:


    then in the Leave field trigger use:

    if ($length(@$fieldname) > $MAX_FIELD_LENGTH$)
        message/info "Maximum field length reached"
        @$fieldname = @$fieldname[1:$MAX_FIELD_LENGTH$]

    Good luck



    Author: KevinMcKeever (
  5. 2 notes on that:

    - you assume that charaters are entered only at the END of the text,
    this may be not the case and we get all kind of funny experiences for the enduser

    - it is faster to use precompile constants instead of field indirection

    So the code may look like:

    if ($length(<$fieldname>) >= $MAX_FIELD_LENGTH$)
        message/info "Maximum field length reached for
    <$fieldname> %%$MAX_FIELD_LENGTH$%%%"
       <$fieldname>  = <$fieldname>[1:$MAX_FIELD_LENGTH$]

    Author: ulrich-merkel (