• 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 write inline callback methods

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 144
  • Views 15435
  • 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 write inline callback methods

TauStudent
TauStudent over 12 years ago

Hello,
I'm writing a Form in skill for a university project, many of the controls in my form have a callback method which is very short
Example :


 EnableEddyRadioField = hiCreateRadioField(
   ?name 'EnableEddyRadio
   ?choices '("on" "off")
   ?prompt "Turn Eddy on/off:"
   ?value "off"
   ?callback list("EddyEnable(t)" "EddyEnable(nil)")
   ) 

   
procedure(EddyEnable(bool)
 myForm->EddyTextField1->editable=bool
 myForm->EddyTextField2->editable=bool
) 

writing this way makes pretty ugly code, so my question is if there a way to write the callback inline, something like that :

 EnableEddyRadioField = hiCreateRadioField(
   ?name 'EnableEddyRadio
   ?choices '("on" "off")
   ?prompt "Turn Eddy on/off:"
   ?value "off"
   ?callback list(
    (myForm->EddyTextField1->editable=t myForm->EddyTextField1->editable=t)
    (myForm->EddyTextField1->editable=nil myForm->EddyTextField1->editable=nil)
   )
   

Thanks !

  • Cancel
  • berndfi
    berndfi over 12 years ago

    To separate code into procedural pices is in my opinion not uggly,

    but here is an inline example.

     

    procedure( BFcreateEddyForm( )
        let( ( eddyStringField eddyRadioField )
            
    ;; creating the fields
        eddyStringField =
            hiCreateStringField(
                ?name       'eddyStringField
                ?prompt     "Eddy Text:"
                ?editable   nil
                )
                
        eddyRadioField =
            hiCreateRadioField(
                ?name       'eddyRadioField
                ?choices    '( "On" "Off" )
                ?prompt     "Turn Eddy On/Off:"
                ?value      "Off"
                ?callback   list(
                                "hiGetCurrentForm( )->eddyStringField->editable = t"  
                                "hiGetCurrentForm( )->eddyStringField->editable = nil"
                            )
            )
          
    ;; creating the form
        hiCreateAppForm(
            ?name       '__eddyForm__  
            ?formTitle  "Eddy Form"
            ?initialSize list( 300 260 )
            ?fields     list(
                        list(
                            eddyStringField
                            15:5 250:25 120
                            )
                        list(
                            eddyRadioField
                            15:50 250:25 120
                            )
                        )
        )
            
    ) ;; close let
    ) ;; close procedure

    procedure( BFeddyForm( )

        unless( boundp( '__eddyForm__ ) && hiIsFormDisplayed( __eddyForm__ )
                BFcreateEddyForm( )
                )
                
        hiDisplayForm( __eddyForm__ )
     
    ) ;; close procedure
            

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

     And in your case you have two commands you want to do - so your callback could be:

    "myForm->EddyTextField1->editable=t myForm->EddyTextField2->editable="

    i.e. space separate them.

    In addition, in the upcoming IC616 release you'll be able to specify the callbacks as function objects, so you can create a lambda function (an unnamed inline function) to do this. Note that you can't do this in IC615. For example (adapting Bernd's code):

    procedure( BFcreateEddyForm( )
         let( ( eddyStringField1 eddyStringField2 eddyRadioField )
             
     ;; creating the fields
         eddyStringField1 =
             hiCreateStringField(
                 ?name       'eddyStringField1
                 ?prompt     "Eddy Text 1:"
                 ?editable   nil
                 )
         eddyStringField2 =
             hiCreateStringField(
                 ?name       'eddyStringField2
                 ?prompt     "Eddy Text 2:"
                 ?editable   nil
                 )
                 
         eddyRadioField =
             hiCreateRadioField(
                 ?name       'eddyRadioField
                 ?choices    '( "On" "Off" )
                 ?prompt     "Turn Eddy On/Off:"
                 ?value      "Off"
                 ?callback   
                    list(
                        lambda((field scope selection)
                            let((editable)
                                editable=if(selection=="On" t nil)
                                hiGetCurrentForm()->eddyStringField1->editable=editable
                                hiGetCurrentForm()->eddyStringField2->editable=editable
                            )
                        )
                    )
             )
           
     ;; creating the form
         hiCreateAppForm(
             ?name       '__eddyForm__  
             ?formTitle  "Eddy Form"
             ?initialSize list( 300 260 )
             ?fields     list(
                         list(
                             eddyStringField1
                             15:5 250:25 120
                             )
                         list(
                             eddyStringField2
                             15:35 250:25 120
                             )
                         list(
                             eddyRadioField
                             15:80 250:25 120
                             )
                         )
         )
             
     ) ;; close let
     ) ;; close procedure
    
     procedure( BFeddyForm( )
    
         unless( boundp( '__eddyForm__ ) && hiIsFormDisplayed( __eddyForm__ )
                 BFcreateEddyForm( )
                 )
                 
         hiDisplayForm( __eddyForm__ )
      
     ) ;; close procedure

     

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

     Thanks, that's exactly what I needed !

    • 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