• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. What is the correct way to set form values?

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 142
  • Views 5596
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What is the correct way to set form values?

FormerMember
FormerMember over 3 years ago

Hello,

I have a function, which sets multiple fields of a custom form. If the form does not exist yet, it is created, otherwise the value fields are only updated.

When the form is first created, everything is set correctly, however when the form is just modified and displayed, the values of the fields are not shown correctly (but the internal value property is actually correct).

I found a similar forum entry https://community.cadence.com/cadence_technology_forums/f/custom-ic-skill/38074/updating-a-form-in-skill which exactly describes my problem, but the explanation is unclear for me. 

I tried different approaches and got different behaviors. Here is a simplified code example, which only works correct, when 'form' does not exist yet.

form = boundp('theForm) && theForm
unless( form
   form = ...create form...
   form->valueFields = list(...list of field objects to be set/read...)
)

foreach( field form->valueFields
   field->value = ...some value...
   hiSetFieldEnabled(field ...state...) ;; state can vary, I also tried setting field->enabled  directly (not sure if there is a difference)
)
hiDisplayForm(form) ; assume the form is currently hidden

However, what somehow works, is this code for the second part:

hiDisplayForm(form) ; display before altering values
foreach( field form->valueFields
   field = get(form field->hiFieldSym) ; get field directly from form (with out this, it does not work)

   field->value = ...some value...
   hiSetFieldEnabled(field ...state...)
)

My question is, what is the correct way to modify forms within a Skill function? The Skill UI manual states, that at least changing 'value' directly should work.  I also tried using hiSetFormBlock to block updates during the loop, but this also did not help.

Best regards
Paul 

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    Paul,

    You didn't show enough of the code to see how the form was created, but if it's a form created with hiCreateAppForm and you didn't pass ?dontBlock t, then it will be blocking. The newer layout forms (created with hiCreateLayoutForm) are non-blocking though. If the form is blocking that means that the hiDIsplayForm() will block until the form has been cancelled or OK'd, and so it won't get to the code modifying the fields until you've OK'd or cancelled the form.

    Why not make the changes you want before displaying the form?

    Also, it's possible that the way you are storing this valueFields slot may not be the right way - it looks as if it's probably just the fields before they are added to the form, and so they may not be properly linked to the form in question. 

    If you want a better answer, you'll need to provide a complete example because the problem is most likely in part of the code you've not shared - I'm having to guess a little what might be wrong.

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to Andrew Beckett

    Put another way, updating fields is normally a matter of doing:

    form->theField->value="blah"
    hiSetFIeldEnabled(form->theField t) 

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FormerMember
    FormerMember over 3 years ago in reply to Andrew Beckett

    Hello Andrew,

    thank you for your comment. The adding to the form gave me the right idea where to look. Indeed I created the form fields with hiCreate... and added them to a layout form. I then stored the fields in the 'valueFields' variable. This was done before displaying the form. 

    I realized, that the objects returned from an instantiated form are different from the objects used during creation (first is of type 'other'  second of type '...struct'). I was confused, because the 'struct' objects I changed seem to be still linked to the 'other' objects, because changing the 'value' of one affected both.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • FormerMember
    FormerMember over 3 years ago in reply to Andrew Beckett

    Hello Andrew,

    thank you for your comment. The adding to the form gave me the right idea where to look. Indeed I created the form fields with hiCreate... and added them to a layout form. I then stored the fields in the 'valueFields' variable. This was done before displaying the form. 

    I realized, that the objects returned from an instantiated form are different from the objects used during creation (first is of type 'other'  second of type '...struct'). I was confused, because the 'struct' objects I changed seem to be still linked to the 'other' objects, because changing the 'value' of one affected both.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • AurelBuche
    AurelBuche over 3 years ago in reply to FormerMember

    Hi Paul,

    Yes if I understood correctly the behavior, when you use hiCreate...Field it returns kind of a generator which is then used to instanciate the field on any form it is added to

    I encountered this problem in SKILL++ when I was trying to build closures defining the field to access it quickly in callbacks

    Here is a dummy example of what I intended (which does not work):

    (inScheme

    (let (field)

    (defglobalfun custom_field nil
    (or field (setq field (hiCreateIntField ?name 'int ?prompt "Integer")))
    (hiCreateHorizontalBoxLayout 'int_layout ?items (list
    field
    (hiCreateButton ?name 'increment_button ?buttonText "Increment"
    ?callback (lambda (@rest _args) (setf field->value (add1 field->value))))
    ))
    )

    );closure

    (hiDisplayForm (hiCreateLayoutForm 'custom_form "Custom Form" (custom_field)))
    )


    The only solution I found for now is to always access the field from the form (either by storing the form in my closure or using the callbacks first argument)

    Cheers

    Aurélien

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to AurelBuche

    Hi Aurélien,

    The whole point of adding function object support for callbacks in hi was to allow closures to be created for callbacks, but you do need to use the arguments passed to those function object callbacks to access the fields. You can't just use the field objects which are not attached to the form. You can of course close over other objects and access those - that's the benefit.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information