Skill: creating FormFields with ?modifyCallback

Discussion in 'Cadence' started by Flash, May 27, 2005.

  1. Flash

    Flash Guest

    Dear All,

    I have created a Form with an InputField using hiCreateStringField()
    and I want to check the entered string if it has reached a length of 10
    (during typing).
    Therefore I use the ?modifyCallback argument as follows:

    ***
    l_field=list(hiCreateStringField(
    ?name 'strfield
    ?prompt "Prompt"
    ?modifyCallback "if(strlen(Form->strfield->value)<=10
    then x=t
    else x=nil)"
    ?value "xyz"
    ) 0:30 200:30 100)
    ***

    The Form works properly until I try to enter something into the field.
    Then I get this:

    Form->strfield->value="xyzq"
    *Error* eval: not a function - 'strfield
    *Error* car: Can't take car of atom - ERROR

    What have I done wrong?

    Regards

    Flash
     
    Flash, May 27, 2005
    #1
  2. Flash

    Guest Guest

    The value of the field itself doesn't contain the value you want to verify,
    so what you are doing wouldn't work even if it weren't the wrong thing to do
    in the first place. The modify CB is passed arguments: the field name, the
    new value, and the source of the change (t for programmatic, nil for user
    entry).

    The return value from the modify callback will be t for "accept the change",
    nil for "reject the change", and a different value for "replace changed value
    with this value".

    You want to do something like:

    (defun MyModifyCB ( field value changeSource ) strlen(value)<=10)

    l_field=list(hiCreateStringField(
    ?name 'strfield
    ?prompt "Prompt"
    ?modifyCallback "MyModifyCB"
    ?value "xyz"
    ) 0:30 200:30 100)

    -Pete Zakel
    ()

    "The man who sets out to carry a cat by its tail learns something that will
    always be useful and which will never grow dim or doubtful."
    -Mark Twain
     
    Guest, May 27, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.