• 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. Remembering form settings between invocations (and sessions...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 144
  • Views 14746
  • 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

Remembering form settings between invocations (and sessions)

Ivars
Ivars over 11 years ago

 Hi,

I'm trying to create a popup form that will allow a user to specify a file name and directory in which to save a plot (amoung other things).

The difficulty I'm having is having the form remember the directory and file name between invocations of the form. In the skeleton code below, I've used a pair of global varibles to maintain a history of the previous directory path and file name. This seems like a rather crude approach. The string field structure has a "lastValue" property but I don't know how to make use of it.

My questions are:

1) How to elegantly have the last directory path and file name filled in on the form every time it is invoked.

2) How to maintain the history of these settings between Cadence session. Should I write the variables to a file each time the form completed and then read in the file when initially creating the form in a new session? What is the cleanest approach?

3) I've set the defValue for both fields, but only the plotDirField gets set to the default value when the "Default" button is pushed. The plotNameField retains its previous value. Why?

Thanks for any help.

I'm using IC6.1.5.500.17 if it matters.

Ivars

Code Skeleton:


procedure( igfPlotNameCB( theForm )
      igfPlotNameFieldLastValue = theForm->igfPlotNameField->value
      );procedure

procedure( igfPlotDirCB( theForm )
      igfPlotDirLastValue = theForm->igfPlotDir->value
      )


procedure( igfSavePlotFormCB( theForm )
      hiSetCallbackStatus( theForm t)
      )

igfPlotDirLastValue = "~/"
igfPlotNameFieldLastValue = ""

procedure( igfCreateSavePlotPopUp()
      let( (plotDirField plotNameField)
          plotDirField =  hiCreateFileSelectorField(
                           ?name 'plotDir
                           ?mode 'directory
                           ?prompt "Plot Directory:"
                           ?value igfPlotDirLastValue
                           ?defValue "~/"
                           ?callback "igfPlotDirCB( hiGetCurrentForm() )"
                           ?enabled t
                           )
          plotNameField = hiCreateStringField(
                       ?name 'plotName
                       ?prompt "Plot Name"
                       ?value igfPlotNameLastValue
                       ?defValue " "
                       ?callback "igfPlotNameCB( hiGetCurrentForm() )"
                       ?editable t
                       )
          igfSavePlotForm = hiCreateAppForm(
                        ?name 'igfSavePlotPopUpMenu
                        ?formTitle "Save Plot"
                        ?callback 'igfSavePlotFormCB
                        ?fields list( plotDir plotNameField )
                        ?unmapAfterCB t
                  )
)


procedure( igfSavePlotPopUp()
      when(igfSavePlotForm == 'unbound
           igfCreateSavePlotPopup()
           ); when
      hiDisplayForm( igfSavePlotForm )
      ); procedure igfSavePlotPopUp()

hiSetBindKey( "vivaGraph" "<Key>F6" "igfSavePlotPopUp()" )

  • Cancel
Parents
  • Li Ting
    Li Ting over 11 years ago

    Hi Ivars:
     
    Here are the answers for your questions. The work to support cross session is a bit involved but that is how it should be done.
     
    1. For the case of current session,  you don't need to do anything. The form fields will retain their last set value. As for the lastValue attribute you mentioned, it simply contain the value from the last successful 'apply' or 'ok' action. This attribute usually is used if your field callack function detected an error and need to restore the previous valid field value.
    2. For the case of cross session, you will need define a Cadence Environment Variable partition for your tool.
      1. Needs to have CDS_LOAD_ENV shell environment variable set to "CSF"
      2. Create a file following the Cadence Environment Variable format and place it in the home directory (of any directory in the CSF path). You can look up this definition from cdnshelp and search for "Cadence Setup Search File: setup.loc".
      3. The name of this file needs to be in the format of "your_tool".cdsenv, e.g. customer.cdsenv
    3. After you have done this, you should be able to use envGetVal() function to retrieve the variable values from your code.
    4. During runtime, you can use envSetVal() function to update the variable value so future calls to envGetVal() will get the current value.
    5. To save the current values to the .cdsenv file so the next session can pick up the values, either you ask the user to use the CIW - Options - Save Defaults command and select your tool name and perform the save operation; or program this into your code with the envStoreEnv() function.
    6. I don't have issue with restoring the default value after clicking the Defaults button. But I do have some issue with the code you posted. There were some mistakes in them.  The version I have edited is  shown below
    ============================= 
    procedure( igfPlotNameCB( theForm )
          igfPlotNameFieldLastValue = theForm->igfPlotNameField->value
          );procedure

    procedure( igfPlotDirCB( theForm )
          igfPlotDirLastValue = theForm->igfPlotDir->value
          )


    procedure( igfSavePlotFormCB( theForm )
          hiSetCallbackStatus( theForm t)
          )

    igfPlotDirLastValue = "~/"
    igfPlotNameFieldLastValue = ""

    procedure( igfCreateSavePlotPopUp()
          let( (plotDirField plotNameField)
              plotDirField =  hiCreateFileSelectorField(
                               ?name 'plotDir
                               ?mode 'directory
                               ?prompt "Plot Directory:"
                               ?value igfPlotDirLastValue
                               ?defValue "~/"
                               ?callback "igfPlotDirCB( hiGetCurrentForm() )"
                               ?enabled t
                               )
              plotNameField = hiCreateStringField(
                           ?name 'plotName
                           ?prompt "Plot Name"
                           ?value igfPlotNameFieldLastValue
                           ?defValue " "
                           ?callback "igfPlotNameCB( hiGetCurrentForm() )"
                           ?editable t
                           )
              igfSavePlotForm = hiCreateAppForm(
                            ?name 'igfSavePlotPopUpMenu
                            ?formTitle "Save Plot"
                            ?callback 'igfSavePlotFormCB
                            ?fields list( plotDirField plotNameField )
                            ?unmapAfterCB t
                      )
    )
    )


    procedure( igfSavePlotPopUp()
          unless( boundp('igfSavePlotForm)
               igfCreateSavePlotPopUp()
               ); when
          hiDisplayForm( igfSavePlotForm )
          ); procedure igfSavePlotPopUp()
     
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Li Ting
    Li Ting over 11 years ago

    Hi Ivars:
     
    Here are the answers for your questions. The work to support cross session is a bit involved but that is how it should be done.
     
    1. For the case of current session,  you don't need to do anything. The form fields will retain their last set value. As for the lastValue attribute you mentioned, it simply contain the value from the last successful 'apply' or 'ok' action. This attribute usually is used if your field callack function detected an error and need to restore the previous valid field value.
    2. For the case of cross session, you will need define a Cadence Environment Variable partition for your tool.
      1. Needs to have CDS_LOAD_ENV shell environment variable set to "CSF"
      2. Create a file following the Cadence Environment Variable format and place it in the home directory (of any directory in the CSF path). You can look up this definition from cdnshelp and search for "Cadence Setup Search File: setup.loc".
      3. The name of this file needs to be in the format of "your_tool".cdsenv, e.g. customer.cdsenv
    3. After you have done this, you should be able to use envGetVal() function to retrieve the variable values from your code.
    4. During runtime, you can use envSetVal() function to update the variable value so future calls to envGetVal() will get the current value.
    5. To save the current values to the .cdsenv file so the next session can pick up the values, either you ask the user to use the CIW - Options - Save Defaults command and select your tool name and perform the save operation; or program this into your code with the envStoreEnv() function.
    6. I don't have issue with restoring the default value after clicking the Defaults button. But I do have some issue with the code you posted. There were some mistakes in them.  The version I have edited is  shown below
    ============================= 
    procedure( igfPlotNameCB( theForm )
          igfPlotNameFieldLastValue = theForm->igfPlotNameField->value
          );procedure

    procedure( igfPlotDirCB( theForm )
          igfPlotDirLastValue = theForm->igfPlotDir->value
          )


    procedure( igfSavePlotFormCB( theForm )
          hiSetCallbackStatus( theForm t)
          )

    igfPlotDirLastValue = "~/"
    igfPlotNameFieldLastValue = ""

    procedure( igfCreateSavePlotPopUp()
          let( (plotDirField plotNameField)
              plotDirField =  hiCreateFileSelectorField(
                               ?name 'plotDir
                               ?mode 'directory
                               ?prompt "Plot Directory:"
                               ?value igfPlotDirLastValue
                               ?defValue "~/"
                               ?callback "igfPlotDirCB( hiGetCurrentForm() )"
                               ?enabled t
                               )
              plotNameField = hiCreateStringField(
                           ?name 'plotName
                           ?prompt "Plot Name"
                           ?value igfPlotNameFieldLastValue
                           ?defValue " "
                           ?callback "igfPlotNameCB( hiGetCurrentForm() )"
                           ?editable t
                           )
              igfSavePlotForm = hiCreateAppForm(
                            ?name 'igfSavePlotPopUpMenu
                            ?formTitle "Save Plot"
                            ?callback 'igfSavePlotFormCB
                            ?fields list( plotDirField plotNameField )
                            ?unmapAfterCB t
                      )
    )
    )


    procedure( igfSavePlotPopUp()
          unless( boundp('igfSavePlotForm)
               igfCreateSavePlotPopUp()
               ); when
          hiDisplayForm( igfSavePlotForm )
          ); procedure igfSavePlotPopUp()
     
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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