• 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. Create Nested Toggle (Check) Boxes

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 15482
  • 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

Create Nested Toggle (Check) Boxes

gs748
gs748 over 10 years ago

Hello,

I am new to SKILL and would like to take your inputs on the below scenario.
I am creating a App form with Toggle (Check) Boxes for few lines in a file which are as below:

 <file lout >
Numbers
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15

Characters
a,b,c,d,e
e,f,g,h,i
j,k,l,m,n

Letters
ab,cd,ef,gh,ij
kl,mn,op,qr,st


I read each line from file lout and create a Check Box for each line but if the user selects “Numbers” or “Characters” then all lines below “Numbers” or “Characters” must be checked until an empty line is read.
I have the below code which errors out with below message:

----------------------
*Error* hiCreateToggleField: each toggle item must be a list of at least it's unquoted symbol representation
*Error* load: error while loading file - "te.il"
---------------------

 Can you please help me with the error check on this code as I am not familiar with most SKILL functions . Thanks in advance.
---------------------
CODE
---------------------

procedure(readcsv(ln)
 cline=ln
 tline = substring(cline 1 strlen(cline)-1)
 pline=parseString(tline ",")
  i=length(pline)
;  printf("Length is %d\n" i)
   item8 = nth(i-1 pline)
   item7 = nth(i-2 pline)
   item6 = nth(i-3 pline)
   item5 = nth(i-4 pline)
   item4 = nth(i-5 pline)
;printf("ITEM'S 1-8:\n %L\n %L\n %L\n %L\n %L\n %L\n %L\n %L\n" item1 item2 item3 item4 item5 item6 item7 item8)
lista = list(item4 item5 item6 item7 item8)
printf("LIST ITEM'S:%L\n" lista)
lista
);end proc readcsv


port=infile("lout")
listN='()
listM='()
listNew='()
count =0
when(port
   while(gets(ln port)
        listb=readcsv(ln)
        listM = cons(listb listM)
        ;printf("ListM:%L\n" listM)
    );end while
   );end when
 close(port)

; Create Check Box

mytoggle = hiCreateToggleField(
 ?name ’toppings
 ?prompt "Toppings"
 ?choices listM
 ;?value ’( nil)
 ;?numSelect 1 )
)
hiCreateAppForm( ?name ’iceCreamForm
 ?formTitle "Ice Cream"
 ?callback "buildIceCreamCone()"
 ?fields list( mytoggle )
 ?help "cream" )
status = hiDisplayForm( iceCreamForm )

---------------------

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    This isn't going to work, because hiCreateToggleList doesn't do all of that for you. The structure you're passing to hiCreateToggleList is wrong (please read the manual, which makes it pretty clear that it's expecting a list of lists, where each list is a symbol and a string (the prompt), or just a symbol).

    Assuming you had just one section in a single list:

    Characters=' ("a" "b" "c" "d" "e"  "f" "g" "h" "i" "j" "k" "l" "m" "n" "o") ; I removed the duplicate "e" in  your example

    you could then do:

    choices=foreach(mapcar elem Characters list(stringToSymbol(elem) elem))

    mytoggle = hiCreateToggleField(
     ?name 'toppings
     ?prompt "Toppings"
     ?choices choices
     ?itemsPerRow 5
     ;?value ?( nil)
     ;?numSelect 1 )
    )
    hiCreateAppForm( ?name 'iceCreamForm
     ?formTitle "Ice Cream"
     ?callback "buildIceCreamCone()"
     ?fields list( mytoggle )
     ?help "cream" )

    hiDisplayForm(iceCreamForm)

    Get that working first, and then figure out how to add a checkbox to turn the entire section on or off. Here's a slightly different example which shows the principle. This is using boolean buttons rather than toggle fields, but you hopefully can get the idea.

    Your code was too confusing and not particularly clear whether your rather abstract example would actually align with your real application, so I didn't spend the limited time I had writing something that would work for your example (only then to find that your real example is different in some fundamental way).

    Regards,

    Andrew.

    /* abToggleForm.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 23, 1999 
    Modified   Sep 16, 2009 
    By         A.D.Beckett
    
    Functions for creating a variable list of toggles
    with all and none toggles. The list of toggles is
    in a scroll region.
    
    Attempted to make it resizable, but this rather contradicted
    with the scroll region, so left the scroll region in the form 
    instead.
    
    Three main entry functions:
    
    abCreateToggleForm()
    abToggleFormGetSelected()
    abToggleFormSetSelected()
    
    Example:
    
    procedure(myToggleCB(form)
       printf("Selected Files were:\n")
       pprint(abToggleFormGetSelected(form))
       newline()
    )
    
    hiDisplayForm(
      abCreateToggleForm(
         ?name 'myTogForm
         ?textList getDirFiles("/bin")
         ?prompt "Choose Files"
         ?callback 'myToggleCB
      )
    )
    
    ***************************************************
    
    SCCS Info: @(#) abToggleForm.il 09/16/09.12:22:46 1.5
    
    */
    
    /********************************************************************
    *                                                                   *
    *                abCreateToggleForm(?name s_formName                *
    *              ?textList l_textitems ?prompt t_prompt               *
    *         [?formTitle t_formTitle] [?value b_defaultValue]          *
    * [?yStep x_yStep] [?formWidth x_formWidth] [?xPosition x_position] *
    *          [?toggleHeight x_height] [?toggleWidth x_width]          *
    *                      [?callback s_callback])                      *
    *     [?formType 'options/'nonoptions] [?buttonLayout 'OKCancel]    *
    *                                                                   *
    *      Create a form full of toggle items, with an all or none      *
    *       button. Must provide at least the symbol for the form       *
    *              name, the list of items, and a prompt.               *
    *                                                                   *
    ********************************************************************/
    
    procedure(abCreateToggleForm(@key 
    	(name nil)
    	(formTitle "")
    	(textList nil) 
    	(prompt "") 
    	(value t)
    	(yStep 20) (formWidth 300) 
    	(xPosition 220) (toggleHeight 200) (toggleWidth 250)
    	(callback nil)
    	(formType 'nonoptions)
    	buttonLayout
    	)
        let((toggleList togName (toggleNumber 0)
    	    (yPosition 0) topLabel allButton noneButton
    	    scrollRegion separator form)
    	;----------------------------------------------------------------
    	; delete any existing form
    	;----------------------------------------------------------------
    	when(boundp(name) && symeval(name)
    	    hiFormCancel(symeval(name))
    	    hiDeleteForm(symeval(name)))
    	;----------------------------------------------------------------
    	; Default button layout
    	;----------------------------------------------------------------
    	unless(buttonLayout
    	    buttonLayout=if(formType=='nonoptions 'OKCancel 'HideCancel)
    	    )
    	;----------------------------------------------------------------
    	; create the label at the top of the toggle list
    	;----------------------------------------------------------------
    	topLabel=hiCreateLabel(?name 'label ?labelText prompt)
    	;----------------------------------------------------------------
    	; create the toggles for each entry in the textList
    	;----------------------------------------------------------------
    	toggleList=foreach(mapcar text textList
    	    ;------------------------------------------------------------
    	    ; create the name of the toggle
    	    ;------------------------------------------------------------
    	    togName=concat('toggle ++toggleNumber)
    	    ;------------------------------------------------------------
    	    ; return the first value in the group
    	    ;------------------------------------------------------------
    	    prog1(
    		;--------------------------------------------------------
    		; create the toggle and add it onto the list
    		;--------------------------------------------------------
    		list(
    		    hiCreateBooleanButton(
    			?name togName
    			?buttonText text
    			?callback 
    			sprintf(nil "abToggleFormOtherButtonCB(%s '%s)"
    			name togName)
    			?value value
    			); hiCreateBooleanButton
    		    0:yPosition
    		    toggleWidth:yStep
    		    xPosition
    		    ); list
    		;--------------------------------------------------------
    		; increment the step 
    		;--------------------------------------------------------
    		yPosition=yPosition+yStep
    		); prog1
    	    ); foreach mapcar
    	;----------------------------------------------------------------
    	; add the line and the All and None toggles 
    	;----------------------------------------------------------------
    	separator=hiCreateSeparatorField(?name 'separator)
    	allButton=hiCreateBooleanButton(
    	    ?name 'All
    	    ?buttonText "All"
    	    ?callback sprintf(nil "abToggleFormAllButtonCB(%s)" name)
    	    ?value value
    	    )
    	noneButton=hiCreateBooleanButton(
    	    ?name 'None
    	    ?buttonText "None"
    	    ?callback sprintf(nil "abToggleFormNoneButtonCB(%s)" name)
    	    ?value !value
    	    )
    	;----------------------------------------------------------------
    	; the sroll region itself
    	;----------------------------------------------------------------
    	scrollRegion=hiCreateScrollRegion(
    	    ?name 'scrollRegion
    	    ?fields toggleList
    	    ?borderWidth 0
    	    )
    	;----------------------------------------------------------------
    	; create the form
    	;----------------------------------------------------------------
    	form=hiCreateAppForm(
    	    ?name name
    	    ?fields list(
    		list(topLabel 0:0 formWidth:yStep*2)
    		list(scrollRegion 0:yStep*2 formWidth:toggleHeight)
    		list(separator 0:toggleHeight+yStep*2 formWidth:0)
    		list(allButton 0:toggleHeight+yStep*3 formWidth:yStep xPosition)
    		list(noneButton 0:toggleHeight+yStep*4 formWidth:yStep xPosition)
    		)
    	    ?formTitle formTitle
    	    ?formType formType
    	    ?buttonLayout buttonLayout
    	    ?callback callback
    	    )
    	;----------------------------------------------------------------
    	; store various information on the form
    	;----------------------------------------------------------------
    	form->numButtons=toggleNumber
    	if(value then
    	    form->numSelected=toggleNumber
    	else 
    	    form->numSelected=0
    	    )
    	form
    	))
    
    /***************************************************************
    *                                                              *
    *            abToggleFormOtherButtonCB(form field)             *
    *                                                              *
    *  Callback for each toggle (except all or none) on the form   *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormOtherButtonCB(form field)
        let((numSelected)
    	numSelected=form->numSelected
    	if(get(form->scrollRegion field)->value 
    	    numSelected++
    	    numSelected--)
    	form->numSelected=numSelected
    	form->None->value=numSelected==0
    	form->All->value=numSelected==form->numButtons
        ))
    
    /***************************************************************
    *                                                              *
    *              abToggleFormAllButtons(form value)              *
    *                                                              *
    *    Utility function to set all the buttons to a specified    *
    *                            value.                            *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormAllButtons(form value)
        let(((scrollRegion form->scrollRegion))
    	foreach(field scrollRegion->fieldList
    	    get(scrollRegion field)->value=value
    	    )
        ))
    
    /***************************************************************
    *                                                              *
    *                abToggleFormAllButtonCB(form)                 *
    *                                                              *
    *                 Callback for the All button                  *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormAllButtonCB(form)
        cond(
    	(form->All->value
    	    abToggleFormAllButtons(form t))
    	(form->numSelected==form->numButtons
    	    form->All->value=t)
    	)
        )
    
    /***************************************************************
    *                                                              *
    *                abToggleFormNoneButtonCB(form)                *
    *                                                              *
    *                 Callback for the None button                 *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormNoneButtonCB(form)
        cond(
    	(form->None->value
    	    abToggleFormAllButtons(form nil))
    	(form->numSelected==0
    	    form->None->value=t)
    	)
        )
    
    /***************************************************************
    *                                                              *
    *                abToggleFormGetSelected(form)                 *
    *                                                              *
    *  Function that may be used in the form callback function to  *
    *             retrieve all the selected item names             *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormGetSelected(form)
        let(((scrollRegion form->scrollRegion))
    	foreach(mapcar field
    	    setof(field scrollRegion->fieldList
    		get(scrollRegion field)->value)
    	    get(scrollRegion field)->prompt
    	    )
    	))
    
    /****************************************************************
    *                                                               *
    *          abToggleFormSetSelected(form promptValList)          *
    *                                                               *
    * Function that may be used to set (or unset) a list of fields. *
    *   The second argument is a list of lists, with each sublist   *
    *  being the prompt for the field, followed by t/nil to set or  *
    *                       unset the toggle.                       *
    *                                                               *
    ****************************************************************/
    
    procedure(abToggleFormSetSelected(form promptValList)
        let(((scrollRegion form->scrollRegion) (fieldTable makeTable('fields nil))
    	    foundField)
    	foreach(field scrollRegion->fieldList
    	    fieldTable[get(scrollRegion field)->prompt]=field
    	    )
    	foreach(promptVal promptValList
    	    foundField=fieldTable[car(promptVal)]
    	    if(foundField then
    		get(scrollRegion foundField)->value=cadr(promptVal)
    	    else
    		warn("No toggle with prompt %L on form\n" car(promptVal))
    		)
    	    )
    	t
    	)
        )
    
    
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • gs748
    gs748 over 10 years ago

    Andrew Beckett said:

    This isn't going to work, because hiCreateToggleList doesn't do all of that for you. The structure you're passing to hiCreateToggleList is wrong (please read the manual, which makes it pretty clear that it's expecting a list of lists, where each list is a symbol and a string (the prompt), or just a symbol).

    Hi Andrew, 

    Thank you for your response.  My scenario is a bit different here. I have a script which creates a tree structure. I want to add check box buttons to root of each  tree structure. Below is the script which creates a tree structure:  I would like to know if I can modify the below script to add check boxes to tree structure: Ex: I want to add checkboxes to Maths and Physics, and also for A Book, B Book, C Book and E Book. Whenever I check Maths checkbox it should check all the contents of Maths i.e. A Book and B Book.  Also, When I select Maths, I would like to unselect either A or B Book.:

    ; create a root tree
    maintree=hiCreateTree('index)
     
    ; create two tree items and append them to the root tree
    dow=hiCreateTreeItem('dow list("Maths"))
    nas=hiCreateTreeItem('nas list("Physics"))
     
    hiTreeAppendItem(maintree dow)
    hiTreeAppendItem(maintree nas)
     
    ; create two sub-trees
    dowTree=hiCreateTree('dows)
    nasTree=hiCreateTree('nass)
     
    ; put the two sub-trees into the two items created earlier
    hiItemInsertTree(dow dowTree)
    hiItemInsertTree(nas nasTree)
     
    ; add a few leaves for the dowTree and nasTree
    hiTreeAppendItem(dowTree hiCreateTreeItem('acom list("A Book" 80.5 1 "Good   Buy")))
    hiTreeAppendItem(dowTree hiCreateTreeItem('bcom list("B Book" 118 3 "Better")))
    hiTreeAppendItem(nasTree hiCreateTreeItem('ccom list("C Book" 27.750 4   "Better ")))
    hiTreeAppendItem(nasTree hiCreateTreeItem('dcom list("E Book" 28.925 5 "Best   Sell")))
     
    procedure( expandCB(name item)
        println("expanded")
        println(name)   
        println(item))
     
    procedure( collapseCB(name item)
         println("collapsed")
         println(name)
         println(item))
    ; create tree table and use maintree as the value for ?choice
    treeField = hiCreateTreeTable(
           ?name 'treeField         
           ?title "Books"        
           ?titleAlignment 'center    
           ?headers list(list("Name"  125    'left    'string)    
                list("Price"    60       'left    'float3)  
                list("Rating"       45      'center  'int)   
                list("Recommendation"  125      'right)    )    
                ?choice maintree    
               ?callback "treeCB"
                ;?expandCallback "expandCB"
                ;?collapseCallback  "collapseCB"          
                )
    ; create a form
    form = hiCreateAppForm(
           ?name 'form    
           ?formTitle "A Tree Book"  
           ?fields list(  list(treeField 5:5 400:200 55) )       
           ?initialSize 500:250)

    hiDisplayForm(form)








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

    You keep doing this - asking a question, and then following up an answer by stating that what you are doing is different - completely different to your original question. It rather makes me less inclined to answer your questions, because they're often somewhat vague, and then it turns out that you're doing something nothing like your question.

    The simple answer to your last question is that you cannot have checkboxes in a tree structure.

    Kind 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