• 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. clear list box value

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 9372
  • 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

clear list box value

Drake96
Drake96 over 3 years ago

Hola,

I have list box field which contains several items as-

Design1

Design2

Design3

.

.

.

DesignN

Layout1

Layout2

Layout3

.

.

.

LayoutN

how can i do that whn i multi-select Design and layout together from above field, it should prompt error and clear the selected field value(list box)....but when i select any multiple design only or multiple layout it should prompt success.
Also , how to clear pre-selected values from list box field after error prompt?

below is script-

check=hiCreateListBoxField(
?name 'check
?multipleSelect t
?callback "back(hiGetCurrentForm())"
?choices list("design1" "design2" "design3" "layout1" "layout2" "layout3")
)

procedure(back(form)

; fixed the condition
if(form->check->value == list("design2" && "layout1") then
hiDisplayAppDBox( ?name 'errorbox2 ?dboxBanner "Error" ?dboxText "wrong selected" ?dialogType hicErrorDialog ?buttonLayout 'Close ?buttons 'Cancel)
form->check->value = "" ;;;;;;;;;;;; to clear the selected value from listbox ;;;;;;;;;;;
)
)

; added a small form around the field to show the problem
hiDisplayForm(
hiCreateLayoutForm(
'forum21
"Forum21"
hiCreateFormLayout(
'lay
?items list(check)
)
)
)

drake

  • Cancel
Parents
  • AurelBuche
    AurelBuche over 3 years ago

    Hi, the following sample should give you an example of how you could handle your problem (it only works in SKILL++ though)
    The changeCB argument of hiCreateListBoxField is the right solution for this purpose but you have to be careful not looping it infinitely

    Cheers

    Aurélien

    (inScheme
    (let (form)

      (defun do_nothing (@rest _args)
        "Always return nil, whatever the inputs"
        nil)

      (defun create_form nil
        "Create the form"
        (hiCreateLayoutForm 'custom_form "Custom Form"
          (hiCreateFormLayout 'main_layout ?items (list
              (hiCreateListBoxField ?name 'list_box_field
    ?choices '("Design1" "Design2" "Design3" "Layout1" "Layout2" "Layout3")
                ?multipleSelect t
                ?changeCB
                (lambda (field form)
                  ;; Here we are making sure to deactivate this change callback
                  ;; before updating field value, this avoids generating an
                  ;; infinite loop and crashing Virtuoso
                  (let ((prev_cb field->changeCB))
                    (setf field->changeCB do_nothing)
                    (unwindProtect
                     ;; The following S-expression is run  in a safe environment
                     ;; Even if its body raises errors, `unwindProtect' will make
                     ;; sure to restore the updated changeCB to its previous value
                     (let ((choices (field->value)))
                       ;; Check and update input value
                       (cond
                         ;; No choice, do nothing
                         ((not choices)
                           nil)
                         ;; All choices are 'design', print success
                         ((forall choice choices (pcreMatchp "Design" choice))
                           (info "Success!\n"))
                         ;; All choices are 'layout', also print success
                         ((forall choice choices (pcreMatchp "Layout" choice))
                           (info "Success!\n"))
                         ;; If we reach this case, it means both 'design' and 'layout'
                         ;; choices are selected
                         ;; Clear selected values
                         (t
                           (setf field->value nil)
                           (error "Both 'design' and 'layout' choices were selected")
                           )))
                     (setf field->changeCB prev_cb)
                     ));unwindProtect ;let
                  ));list_box_field
              ));main_layout
          ));def

      (defglobalfun display_gui (@rest _args)
        "Main function, display the GUI"
        (unless form (setq form (create_form)))
        (hiDisplayForm form))

      );closure
    )
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Drake96
    Drake96 over 3 years ago in reply to AurelBuche

    Thank you Aurel :)
    If possible can you guide in Skill     as Skill++ is very very new to me.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • AurelBuche
    AurelBuche over 3 years ago in reply to Drake96
    procedure( back(field form)
      let( (prev_cb)
        prev_cb=field->changeCB
        field->changeCB=(lambda (@rest _args) nil)
        (if forall( choice field->value (pcreMatchp "design" choice)) || forall( choice field->value (pcreMatchp "layout" choice))
           ;; choices are all design or all layout
           info("Success!\n")
           ;; choices are a mix of design and layout
           progn(
             hiDisplayAppDBox( ?name 'errorbox2 ?dboxBanner "Error" ?dboxText "wrong selected" ?dialogType hicErrorDialog ?buttonLayout 'Close ?buttons 'Cancel)
             form->check->value = nil ;;;;;;;;;;;; to clear the selected value from listbox ;;;;;;;;;;;
             ))
        field->changeCB=prev_cb
        ))


    check=hiCreateListBoxField(
    ?name 'check
    ?multipleSelect t
    ?changeCB 'back
    ?choices list("design1" "design2" "design3" "layout1" "layout2" "layout3")
    )
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Reply
  • AurelBuche
    AurelBuche over 3 years ago in reply to Drake96
    procedure( back(field form)
      let( (prev_cb)
        prev_cb=field->changeCB
        field->changeCB=(lambda (@rest _args) nil)
        (if forall( choice field->value (pcreMatchp "design" choice)) || forall( choice field->value (pcreMatchp "layout" choice))
           ;; choices are all design or all layout
           info("Success!\n")
           ;; choices are a mix of design and layout
           progn(
             hiDisplayAppDBox( ?name 'errorbox2 ?dboxBanner "Error" ?dboxText "wrong selected" ?dialogType hicErrorDialog ?buttonLayout 'Close ?buttons 'Cancel)
             form->check->value = nil ;;;;;;;;;;;; to clear the selected value from listbox ;;;;;;;;;;;
             ))
        field->changeCB=prev_cb
        ))


    check=hiCreateListBoxField(
    ?name 'check
    ?multipleSelect t
    ?changeCB 'back
    ?choices list("design1" "design2" "design3" "layout1" "layout2" "layout3")
    )
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Children
  • Drake96
    Drake96 over 3 years ago in reply to AurelBuche

    Thank you Aurel   !!!!!!!!!!! :)

    • 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