• 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. How to access the value of a boolean button within a form...

Stats

  • Locked Locked
  • Replies 20
  • Subscribers 143
  • Views 10301
  • 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

How to access the value of a boolean button within a form within a docked window

blankman
blankman over 1 year ago

Hi,

I have a form, within a docked window, within my session window. And within that form I have a boolean button. How do I access the value of that boolean button?

I have tried this, however is not accessing it:

hiGetCurrentForm()~>bool1~>value

Thanks,

B

  • Cancel
Parents
  • blankman
    blankman over 1 year ago

    PS, the dock window was created using code provided by AurelBuche (at the following location). ie the dock window was added to a global table.

    community.cadence.com/.../1395442

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    You can't use hiGetCurrentForm() with forms in dock windows - see this post. Are you trying to access this within a callback - if so that post will give you a suggestion, hopefully.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    Thanks Andrew,

    Yes this is for within a callback.

    I have tried the below, though not functioning. Can you advise what I might be missing?

    ?callback lambda((bool1 DockForm()) printf("New value in field %L scope %L\n" bool1 DockForm()))



    I am using the following to define the boolean button that is used within the form


    bool1 = hiCreateBooleanButton(
    ?name 'bool1
    ?buttonText "Test"
    ?callback lambda((bool1 DockForm()) printf("New value in field %L scope %L\n" bool1 DockForm()))
    ?buttonLocation 'right
    )

    Thanks,

    B

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    I'm not sure why you've put parentheses after DockForm - it's not a function. Also, you're missing the third argument for the callback function. This will work:

      bool1 = hiCreateBooleanButton(
        ?name 'bool1
        ?buttonText "Test"
        ?callback 
          lambda((bool1 DockForm value) 
            printf("New value %L in field %L scope %L\n" value bool1 DockForm)
          )
        ?buttonLocation 'right
      )

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    Thanks Andrew, yes it is more a trial and error approach I am taking at the moment not yet having formally trained in skill. This works now, this is much appreciated.

    What syntax would I then use to assign the value of the boolean button to a variable for use in other procs? ie if ticked, TestVar = t, and if unticked, TestVar = nil. 

    Thanks again,

    B.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    Well, you could do exactly as you've described - set a global variable in the callback function (use TestVar=t or TestVar=nil or even TestVar=value if value was the argument to the callback function). However, I really don't see any good reason to introduce a global variable for this - if it's needed in the callback for another field, you could use DockForm->bool1->value (DockForm being the variable describing the scope argument) to look up the value - no additional variables are needed.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    THanks Andrew, "DockForm->bool1->value" - this works a charm, however, when I have multiple dock windows open, ie across different session windows, all referncing the same DockForm, I notice only the most recently opened dockwindow seems to register the boolean button change. ie if I change the boolean button value on a previosuly opened dock window, "DockForm->bool1->value" doesn't register that change. Is there a way of grabbing the boolean button change per session window so that the boolean in each docked window registers the change? I am assuming this might have something to do with accessing the table that each docked window has been added to, as per this example?

    https://community.cadence.com/cadence_technology_forums/f/custom-ic-skill/58186/after-creating-dockable-window-containing-a-form-how-to-locate-and-delete-in-order-to-recreate-the-dockable-window-and-form/1395442#1395442

    Thanks again,

    B

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    THanks Andrew, "DockForm->bool1->value" - this works a charm, however, when I have multiple dock windows open, ie across different session windows, all referncing the same DockForm, I notice only the most recently opened dockwindow seems to register the boolean button change. ie if I change the boolean button value on a previosuly opened dock window, "DockForm->bool1->value" doesn't register that change. Is there a way of grabbing the boolean button change per session window so that the boolean in each docked window registers the change? I am assuming this might have something to do with accessing the table that each docked window has been added to, as per this example?

    https://community.cadence.com/cadence_technology_forums/f/custom-ic-skill/58186/after-creating-dockable-window-containing-a-form-how-to-locate-and-delete-in-order-to-recreate-the-dockable-window-and-form/1395442#1395442

    Thanks again,

    B

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    Given that DockForm is the argument to the callback function (the lambda), I would expect this to show you the value of the field on the form. I only briefly looked at Aurélien's example code, but I don't think the table stuff should make a difference.

    Can you either share a complete enough example that shows the problem, or if you can't do that, contact customer support?

    Thanks,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    Hi Andrew, yes example test code below. See condition statement used in proc: UseBoolTest()

    [EDIT: code removed]

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    Thanks for the sample code.

    However, this doesn't really explain where you are trying to access the boolean button from (the function UseBoolTest is not called from anywhere), and also the global variable Test is just set in that uncalled function and not used anywhere. I would have expected that you might have some kind of callback/action in the docked form and that the callback for those items would do everything necessary. Without understanding the overall flow of how you expect to interact with the form and what it triggers, it's pretty hard to advise...

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    Andrew, Ok, see updated below adding button to DockForm, this new button functions differently depending on the state of bool1. Thanks, B

    [EDIT: code removed]

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    I changed the button callback to be the name of the function (it could have been a local function or a lambda, but I didn't want to confuse you with understanding lexical scoping and SKILL++), and in that case it receives information about the field and the scope (the form in this case). Because of this, it will get the form for the specific window you're in - and thus will work. I'm not sure why you need to set a global variable "Test" in your callback (that said your code is lacking let() functions across the board and is not being careful to declare local variables). This part of the code is what I changed (other than indenting to make the code a bit clearer):

    ; used by app_create_dwin(swin)
    procedure(DockFormProc()
      button1=hiCreateButton(
        ?name 'button1
        ?buttonText "Ticked/Unticked?"
        ; pass the name of the function so that it gets called
        ; as a "function object callback" (search in docs for that
        ; string)
        ?callback 'UseBoolTest
      )
      bool1 = hiCreateBooleanButton(
        ?name 'bool1
        ?buttonText " "
        ?buttonLocation 'right
      )
      DockForm=hiCreateAppForm(
        ?name gensym('DockFormApp)
        ?formTitle "Test"
        ?fields
        list( list(button1 0:3 165:18)
          list(bool1 86:25 15:2 25)
        )
      )
      DockForm
    )
    
    ;---------------------------------------------
    
    ;target proc that I intend to use the value of the boolean button in.
    ; for buttons, these only have two arguments (no value)
    procedure(UseBoolTest(field form)
      Test = nil
      if(form->bool1->value == nil 
        then Test = "a"
          printf("Button is unticked\n")
        else Test = "b"
          printf("Button is ticked\n")
      )
    )
    

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    Thanks Andrew, works perfectly, yes I had removed much of the finer details (let statements etc) for the test case. Appreciate the support, very helpful, thanks, B

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to blankman

    Hi Andrew, another quick question, say I want to add this proc UseBoolTest to a bindkey, what should I pass for variables field and form in the below code? See error I am seeing following. K Rgds, B

    hiSetBindKey("Layout" "1" "UseBoolTest()")

    *Error* BRSADI11Oct2023EnableMetals123: too few arguments (2 expected, 0 given) - nil

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to blankman

    If you add this function to your code (or something like it):

    procedure(CCFfindAssistant(assistantName @optional 
        (swin hiGetSessionWindow(hiGetCurrentWindow())))
      car(
        exists(
          assistant 
          setof(dwin hiGetWindowList('dockable) 
            hiGetSessionWindow(dwin)==swin && hiGetWindowState(dwin)=='mapped)
          hiGetWindowName(assistant)==assistantName
        )
      )
    )

    Then you can set your bindkey to be:

    hiSetBindKey("Layout" "1" "UseBoolTest('button1 symeval(CCFfindAssistant(\"Test\")->hiForm))")

    The idea is that CCFfindAssistant looks for an assistant which is associated with the current session window and is mapped (so it's visible) which has the window name matching the given argument (this is the "title" of your docked window). Having found that, it then gets the symbol associated with the form in that docked window and evaluates it to get the form handle - and then passes the two arguments to your UseBoolTest function. The first argument is just the name of the field but since your callback is  not using the field name it probably doesn't matter.

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to Andrew Beckett

    Thanks Andrew, this works, and yes the first argument is not showing to matter on my side, as I have just set this up across multiple different bindkeys that use multiple different buttons, and it still works. Thank again, B

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • blankman
    blankman over 1 year ago in reply to blankman

    Andrew, I am seeing some unexpected behaviour using the bindkey allocation. After a period of time of successful use I get the following error and the bindkey stops working.

    *Error* symeval: argument #1 should be a symbol (type template = "se") - nil

    Though I notice when I again call the UseBoolTest proc directly (by clicking button1 within DockForm) the bindkey again begins to function correctly. I cannot see what might be causing this. Any ideas what might be happening here?

    K Rgds, B

    • 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