• 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. hiCreateAppForm - Creating an unknown changing number of...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 1713
  • 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

hiCreateAppForm - Creating an unknown changing number of fields

patschouly
patschouly over 4 years ago

Hi,

I'm building a form similar to the "Create Instance"-Dialog (Layout), so the user can choose the library and the instance name and change some parameters. This is, however, connected to an external tool, not the library manager or any open access databases. I'm currently struggling on how to include the parameters, which change with the chosen instance (just like the "Create Instace" dialog). Now I know that you can add fields to a form with hiAddField and delete unused ones with hiDeleteField(s), but how do I know which fields to remove? The form has to fields that are always present, all other fields are dynamic.

The dynamic fields are created similar to this:

; iterate over list of parameters
let((type name fieldlist field)
    foreach(p paramlist
        type = car(p)
        name = cadr(p)
        case(type
            ("number" field = hiCreateIntField(?name stringToSymbol(name) /* other arguments */))
            ("string" field = hiCreateStringField(?name stringToSymbol(name) /* other arguments */))
            /* other fields */
        )
        cons(field fieldlist)

    )
)

The two main (static) fields of the form are created in a procedure and assigned to global variables, which I then use for creation of the form together with the dynamic field list. This all works well, but I want to have a callback on the second static field (instance name), that changes the displayed dynamic fields. How can I do this? The callback needs to look something like this:

procedure(formcallback(field form)
    let(
        (instname newfieldlist)
        instname = field->value
        newfieldlist = /* get parameter field list as listed above */
        ; delete all old fields except the two static fields (how?)
        foreach(newfield newfieldlist
            hiAddField(form newfield)
        )
    )
)

As a little extra on top I would like to reuse the same field, if the string that is used to create the symbol (stringToSymbol) (the name of the parameter) was already used to create a field.

Thanks in advance,
kind regards,
Patrick

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    Patrick,

    An example of dynamically adding and deleting fields is shown in this post. You'll see I use a property on the form to store any extra fields (I called it extraFields) that I've created that aren't necessarily added - so that way I can add them when needed. Of course, you might do that a little differently - you might use a property to cache any dynamically created fields that you created in the callback, so that if you delete them and later add them again you don't need to recreate but can pull them out of your cache (you could use a table as the value of the property to make it easier to find them).

    Hopefully this will give you enough of a steer in the right direction?

    Regards,

    Andrew

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

    Hi Andrew, thanks for the link, that helped me alot. I needed a little time to get everything working, but I want to show to other how I solved it in the end:

    This part assembles the list of fields for the form. A unique symbol sym is created that can be used to check if the field was already generated. If yes, it is retrieved, if no it is created and stored in extraFields of the form.

    if(get(form->extraFields sym)
        then
            field = get(form->extraFields sym)
        else
            field = hiCreateFloatField(
                ?name sym
                ?value 0
                ?prompt "some field"
            )
            ; store field
            putprop(form->extraFields field sym)
    ) ; if
    fieldlist = cons(field fieldlist)

    Next, we need to update the field entries of the form. The form has two fields that always have to be presen ('liblist and 'celllist):

    let(
        (fieldlist toinsert todelete)
        fieldlist = /* get field list from above */
        foreach(field form->fieldList
            unless(member(field fieldlist) || equal(field 'liblist) || equal(field 'celllist)
                todelete = cons(field todelete)
            )
        )
        foreach(field fieldlist
            unless(member(field todelete)
                toinsert = cons(field toinsert)
            )
        )
        when(todelete
            hiDeleteFields(OPCCellForm todelete)
        )
        when(toinsert
            hiAddFields(OPCCellForm toinsert)
        )
    )

    The form is created like this:

    let(
        ()
        hiCreateAppForm(
            ?name 'form
            ?formType 'options
            ?formTitle "Test Form"
            ?fields list(liblist celllist) /* these fields are created earlier in this procedure */
            ?buttonLayout 'HideCancelDef
        )
             /* store all fields in extraFields (a disembodied property list) */
        form->extraFields = list(nil 'liblist celllist 'celllist celllist)
        form
    )

    I hope that helps others.

    Kind regards,

    Patrick

    • 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