• 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. Variable number of dialog box fields

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 143
  • Views 15085
  • 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

Variable number of dialog box fields

thomas1000
thomas1000 over 12 years ago

I am trying to construct a dialog box with a variable number of fields, however,  the hiCreateStringField ?name parameter is supposed to be a single-quoted symbol reference so I cannot simply assign the result of hiCreateStringField to an array and then reference it.  I must have the wrong approach.  

Does anyone know how to construct a form with a variable number of fields?  If so, can you point me in the right direction?  I want to be able to create fields in an indexed loop and read their values that way.

  • Cancel
  • kb how
    kb how over 12 years ago

    No sure it this that you're looking for.

    StringList = list("field1" "field2" field3" "field4")

    form = hiCreateAppForm(?name 'form ?fields foreach(mapcar str StringList hiCreateStringField(?name stringToSymbol(str) ?prompt str)))
    hiDisplayForm(form)

    This will process all string in StringList and create a stringField for the form.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 12 years ago

    Hi Thomas,

    I think that you might want to auto-create the name for the ?name argument to hiCreateStringField using gensym() perhaps?  Or if you are within a numbered loop, you might just concatenate the number to a base name using something like concat('strField num) [where 'strField is the base name for each field and num is the loop variable].  You might consider looking at Solution Article 11106074 for some assistance.

    Hopefully this is the sort of thing that you are looking for?

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • thomas1000
    thomas1000 over 12 years ago

    Thanks for the inputs.  I can now create a form with default values filled in but there is still a missing component.  When I try to get the fields I have to reference them and everything I have tried either gives nil for all fields or the defaults and not the user entry.  Here is the code and when the dialog box dismisses it returns {nil nil nil}.  How do I get to the values that the user has filled into the form boxes?

    ;Get the values and print them in a list 

    procedure(FileFormCallback(theForm)
      let((
      ValueList
      )
      ValueList = nil
       for(i 0 2
       ValueList = append(ValueList list(nth(i theForm->fieldList)->value))
      );End for
      printf("%L\n" ValueList)
     );End let
     );End procedure
     

    ;Create the form fields


     procedure(DisplayForm()
     let((
      i
      )
     
      FieldList = nil
      N = 3
      for(i 1 3
       FieldList = append(FieldList list(hiCreateStringField(
         ?name gensym(sprintf(nil "CL%dLayerField" i))
         ?prompt sprintf(nil "Computational Layer %d Name:" i)
         ?defValue sprintf(nil "CL%dLayer" i)
         ?callback "FileFormCallback(hiGetCurrentForm())"
         ?editable t
         );End hiCreateStringField
        );End list
       );End append
      );End for

      FileForm = hiCreateAppForm(
       ?name 'FileForm
       ?formTitle "Test"
       ?callback "FileFormCallback(hiGetCurrentForm())"
       ?fields FieldList
       ?buttonLayout 'OKCancel
       ?unmapAfterCB t
      );End hiCreateAppForm
     );End let
     
     hiDisplayForm(FileForm)
    );End procedure

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • thomas1000
    thomas1000 over 12 years ago

    Continuing... Replacing the callback with the following returns the default values and not the user-entered values.  So I get back {"CL1LayerField" "CL2LayerField" "CL3LayerField"} even though different values have been entered into the form. 

    procedure(FileFormCallback(theForm)
      let((
      ValueList
      )
      ValueList = nil
     
       ValueList = append(ValueList list(nth(0 FieldList)->value))
       ValueList = append(ValueList list(nth(1 FieldList)->value))
       ValueList = append(ValueList list(nth(2 FieldList)->value))

      printf("%L\n" ValueList)
     );End let
     );End procedure

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    I think this is what you want:

    procedure(FileFormCallback(theForm)
      let((ValueList)
        ValueList=foreach(mapcar fieldName theForm->fieldList
          get(theForm fieldName)->value
        )
        printf("%L\n" ValueList)
      )
    )

    (note no need to use nth or anything like that, and will cope with any number of fields)

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • thomas1000
    thomas1000 over 12 years ago

    Thanks, Andrew,

    That is nice and concise, better than the code I wrote, but when I try it and enter non-default values into the form and click "OK" I still get default values back in ValueList.  So we still haven't solved the original problem.  Somehow this code is returning the default values and not the filled-in values.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • thomas1000
    thomas1000 over 12 years ago

    Here is the complete code - very simple because I am try ing to get this one thing working:

    procedure(FieldCheck(theForm)
     let((
      )
      hiSetCallbackStatus(theForm t)
     );End let
     );End procedure
     
    procedure(FileFormCallback(theForm)
      let((ValueList)
        ValueList=foreach(mapcar fieldName theForm->fieldList
          get(theForm fieldName)->value
        )
        printf("%L\n" ValueList)
      )
    )


     procedure(DisplayForm()
     let((
      i
      )
     
      FieldList = nil
      N = 3
      for(i 1 3
       FieldList = append(FieldList list(hiCreateStringField(
         ?name gensym(sprintf(nil "CL%dLayerField" i))
         ?prompt sprintf(nil "Computational Layer %d Name:" i)
         ?defValue sprintf(nil "CL%dLayer" i)
         ?callback "FieldCheck(hiGetCurrentForm())"
         ?editable t
         );End hiCreateStringField
        );End list
       );End append
      );End for

      FileForm = hiCreateAppForm(
       ?name 'FileForm
       ?formTitle "Test"
       ?callback "FileFormCallback(hiGetCurrentForm())"
       ?fields FieldList
       ?buttonLayout 'OKCancel
       ?unmapAfterCB t
      );End hiCreateAppForm
     );End let
     
     hiDisplayForm(FileForm)
    );End procedure

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • thomas1000
    thomas1000 over 12 years ago

    I found the problem.  I shut down Cadence and restarted and things all work fine now - I get the actual field values rather than defaults.

    Thanks for your help.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Well, for me if I enter fred, jim, harry in the three fields I get:

     ("fred" "jim" "harry")

    appearing in the CIW. So it works for me! (I cut and pasted the code above and used that, to be sure).

    No idea how it could be displaying the default values if the field values have been changed. You'd have to use ->defValue to get the default values...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 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