Home > Community > Forums > Custom IC SKILL > Adding elements to open form in SKILL

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Adding elements to open form in SKILL 

Last post Wed, Sep 9 2009 8:23 AM by ToMWUT. 2 replies.
Started by ToMWUT 09 Sep 2009 03:22 AM. Topic has 2 replies.
Page 1 of 1 (3 items)
Sort Posts:
  • Wed, Sep 9 2009 3:22 AM

    • ToMWUT
    • Top 150 Contributor
    • Joined on Mon, Apr 20 2009
    • Warsaw, Poland
    • Posts 48
    • Points 795
    Adding elements to open form in SKILL Reply

    Hello,

    I’ve got a question about a form. I have a form created with hiCreateAppForm function and then it was also displayed using hiDisplayFunction.

    Is there any possibility using for example a callback function of a button on this form to add something to the form for example another field, so the form would reload and the user wouldn’t feel the difference? I would like to add another element to ScrollRegion.

     

    Any piece of code would be much appreciated.

     

    Regards,

    ToM

    • Post Points: 20
  • Wed, Sep 9 2009 4:07 AM

    Re: Adding elements to open form in SKILL Reply

    ToM,

    This code gives an example of adding fields on a form. To add them onto a scroll region, the first argument to the hiAddField or hiAddFields function would be form->scrollRegion (where scrollRegion is the ?name of the scroll region field).

    /* oferExample.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 09, 1999 
    Modified   Mar 02, 1999 
    By         A.D.Beckett
    
    Example code to demonstrate how to use various form functions,
    use of loading and saving templates, dynamic field addition, etc.
    
    Note that the templates don't include the values of the
    dynamic fields - that's an exercise for the reader!
    
    ***************************************************
    
    SCCS Info: @(#) oferExample.il 03/02/99.14:02:59 1.2
    
    */
    
    /***************************************************************
    *                                                              *
    *                       oferCreateForm()                       *
    *                                                              *
    *                     Create the main form                     *
    *                                                              *
    ***************************************************************/
    
    procedure(oferCreateForm()
        let((libName cellName viewName browse userData templateFile templateLoad templateSave
    	sep1 sep2 sep3 radio optionTwo optionThree)
    	; template loading and saving
    	templateFile=hiCreateStringField(
    		?name 'templateFile
    		?prompt "Template File"
    		)
    	templateLoad=hiCreateButton(
    		?name 'templateLoad
    		?buttonText "Load"
    		?callback "oferLoadTemplate()"
    		)
    	templateSave=hiCreateButton(
    		?name 'templateSave
    		?buttonText "Save"
    		?callback "oferSaveTemplate()"
    		)
    	; cellView specification
    	sep1=hiCreateSeparatorField(?name 'sep1)
    	libName=hiCreateStringField(
    		?name 'libName
    		?prompt "Library Name"
    		?callback "ddsUpdateSyncWithForm()"
    		)
    	cellName=hiCreateStringField(
    		?name 'cellName
    		?prompt "Cell Name"
    		?callback "ddsUpdateSyncWithForm()"
    		)
    	viewName=hiCreateStringField(
    		?name 'viewName
    		?prompt "View Name"
    		?callback "ddsUpdateSyncWithForm()"
    		)
    	browse=hiCreateButton(
    		?name 'browse
    		?buttonText "Browse"
    		?callback "oferSyncBrowser()"
    		)
    	sep2=hiCreateSeparatorField(?name 'sep2)
    	; example radio button
    	radio=hiCreateRadioField(
    		?name 'radio
    		?prompt "Radio"
    		?choices list("One" "Two" "Three")
    		?value  "One"
    		?callback list("oferRadioButtonCB()")
    		)
    	; extra entries for radio button options two and three
    	; these won't be mapped to start off with.
    	optionTwo=hiCreateStringField(
    		?name 'optionTwo
    		?prompt "Option for Two"
    		)
    	optionThree=hiCreateStringField(
    		?name 'optionThree
    		?prompt "Option for Three"
    		)
    	; the user data button
    	sep3=hiCreateSeparatorField(?name 'sep3)
    	userData=hiCreateButton(
    		?name 'userData
    		?buttonText "User Data"
    		?callback "oferDisplayUserDataForm()"
    		)
    	hiCreateAppForm(
    	    ?name 'oferExampleForm
    	    ?formTitle "Ofer's example form"
    	    ?fields
    		list(
    		    list(templateFile 0:0 600:30 200)
    		    list(templateLoad 100:5 45:20)
    		    list(templateSave 150:5 45:20)
    		    list(sep1 0:35 600:0)
    		    list(libName 0:40 600:30 200)
    		    list(cellName 0:70 600:30 200)
    		    list(viewName 0:100 600:30 200)
    		    list(browse 200:130 100:25)
    		    list(sep2 0:165 600:0)
    		    list(radio 0:190 600:0 200)
    		    list(sep3 0:205 600:0)
    		    list(userData 200:220 100:25)
    		    )
    	    )
    	; store the extra fields on the form, ready for later
    	oferExampleForm->extraFields=
    	    list(nil 'optionTwo optionTwo
    		    'optionThree optionThree)
    	oferExampleForm
    	)
        )
    
    /***************************************************************
    *                                                              *
    *                   oferCreateUserDataForm()                   *
    *                                                              *
    *                  Creates the user data form                  *
    *                                                              *
    ***************************************************************/
    
    procedure(oferCreateUserDataForm()
        let((userFilename userRadio)
    	userFilename=hiCreateStringField(
    		?name 'userFilename
    		?prompt "Filename"
    		)
    	userRadio=hiCreateRadioField(
    		?name 'userRadio
    		?choices list("a" "b" "c" "d")
    		?value "a"
    		?prompt "Another Radio"
    		)
    	; example - don't bother filling 
    	hiCreateAppForm(
    	    ?name 'oferUserDataForm
    	    ?formTitle "Ofer's User Data"
    	    ?fields list(
    		userFilename
    		userRadio
    		)
    	    )
    	)
        )
    
    /***************************************************************
    *                                                              *
    *                      oferSaveTemplate()                      *
    *                                                              *
    *              Callback code to save the template              *
    *                                                              *
    ***************************************************************/
    
    procedure(oferSaveTemplate()
        let( (fileName fport)
    	fileName=oferExampleForm->templateFile->value
    	when(fileName==""
    	    error("Must specify template filename")
    	    )
    	fport=outfile(fileName)
    	unless(fport
    	    error("Could not write to template file %s" fileName)
    	    )
    	fprintf(fport "oferKeys='(nil\n")
    	; output all of the main form keys 
    	foreach(key '(libName cellName viewName radio)
    	    fprintf(fport "  %s %L\n" key get(oferExampleForm key)->value)
    	    )
    	; output all of the user data form keys 
    	foreach(key '(userFilename userRadio)
    	    fprintf(fport "  %s %L\n" key get(oferUserDataForm key)->value)
    	    )
    	; end of the file
    	fprintf(fport ")\n")
    	close(fport)
    	)
        )
    	
    
    /***************************************************************
    *                                                              *
    *                      oferLoadTemplate()                      *
    *                                                              *
    *              Callback code to load the template              *
    *                                                              *
    ***************************************************************/
    
    procedure(oferLoadTemplate()
        let( (fileName fport)
    	fileName=oferExampleForm->templateFile->value
    	when(fileName==""
    	    error("Must specify template filename")
    	    )
    	; load it, and trap any errors. The file is just skill
    	; code, so can be loaded.
    	errset(load(fileName) t)
    	; the keys are all in a disembodied property list called oferKeys
    	; input all of the main form keys 
    	; use get(), because oferKeys->key won't work, because the key variable
    	; needs to be evaluated.
    	foreach(key '(libName cellName viewName radio)
    	    when(get(oferKeys key)
    		get(oferExampleForm key)->value=get(oferKeys key)
    		)
    	    )
    	; output all of the user data form keys 
    	foreach(key '(userFilename userRadio)
    	    when(get(oferKeys key)
    		get(oferUserDataForm key)->value=get(oferKeys key)
    		)
    	    )
    	)
        )
    
    /***************************************************************
    *                                                              *
    *                      oferSyncBrowser()                       *
    *                                                              *
    *                 Synchronise with the browser                 *
    *                                                              *
    ***************************************************************/
    
    procedure(oferSyncBrowser()
        ddsSyncWithForm(
    	oferExampleForm
    	'browse
    	'libName
    	'cellName
    	'viewName
    	)
        )
    
    /****************************************************************
    *                                                               *
    *                      oferRadioButtonCB()                      *
    *                                                               *
    *   Callback for the radio button on the form - this adds or    *
    *       subtracts the dynamic fields. The dynamic fields        *
    * are created at startup, and stored in a disembodied property  *
    * list on the form, and the form positions are calculated based *
    *        on the current positions of fields on the form.        *
    *                                                               *
    ****************************************************************/
    
    procedure(oferRadioButtonCB()
        let((radioVal newOffset newPosition oldPosition
    	    (currentOffset 0) (fieldHeight 30) newYcoord)
    	; determine the offset of the bottom fields at the moment
    	when(oferExampleForm->optionTwo
    	    currentOffset=currentOffset+fieldHeight
    	    )
    	when(oferExampleForm->optionThree
    	    currentOffset=currentOffset+fieldHeight
    	    )
    	; determine the offset that we want, based on the radio
    	; button value
    	radioVal=oferExampleForm->radio->value
    	newOffset=case(radioVal
    	    ("Two" fieldHeight)
    	    ("Three" fieldHeight*2)
    	    (t 0)
    	    )
    	; shift the two bottom fields by the appropriate amount
    	foreach(field '(sep3 userData)
    	    ; calculate the new position from the old, offset accordingly
    	    oldPosition=car(hiGetFieldInfo(oferExampleForm field))
    	    newPosition=xCoord(oldPosition):yCoord(oldPosition)
    			+newOffset-currentOffset
    	    hiMoveField(
    		oferExampleForm
    		field
    		newPosition
    		)
    	    )
    	; delete form fields if they're not needed
    	when(radioVal=="One" && oferExampleForm->optionTwo
    	    hiDeleteField(oferExampleForm 'optionTwo))
    	when(radioVal!="Three" && oferExampleForm->optionThree
    	    hiDeleteField(oferExampleForm 'optionThree))
    	; determine where the extra fields will be placed
    	newYcoord=yCoord(car(hiGetFieldInfo(oferExampleForm 'radio)))+10
    	; add the two fields if they're needed and not there already
    	when(radioVal=="Two" || radioVal=="Three"
    	    unless(oferExampleForm->optionTwo
    		hiAddField(oferExampleForm
    		    list(oferExampleForm->extraFields->optionTwo
    			0:newYcoord 600:30 200))
    		)
    	    )
    	when(radioVal=="Three"
    	    unless(oferExampleForm->optionThree
    		hiAddField(oferExampleForm
    		    list(oferExampleForm->extraFields->optionThree
    			0:newYcoord+fieldHeight 600:30 200))
    		)
    	    )
    	))
    	
    
    /***************************************************************
    *                                                              *
    *                  oferDisplayUserDataForm()                   *
    *                                                              *
    *  Display the user data form - callback from the main form.   *
    *                                                              *
    ***************************************************************/
    
    procedure(oferDisplayUserDataForm()
        hiDisplayForm(oferUserDataForm)
        )
    
    /****************************************************************
    *                                                               *
    *                    oferExampleFormCB(form)                    *
    *                                                               *
    * The form callback - doesn't do much except print out what has *
    *                         been entered                          *
    *                                                               *
    ****************************************************************/
    
    procedure(oferExampleFormCB(form)
        printf("You entered cellView %s/%s/%s\n"
    	form->libName->value
    	form->cellName->value
    	form->viewName->value
    	)
        printf("The radio button was set to %s\n"
    	form->radio->value
    	)
        printf("And the user data fields were\nfilename: %s\nradio: %s\n"
    	oferUserDataForm->userFilename->value
    	oferUserDataForm->userRadio->value
    	)
        )
    
    /***************************************************************
    *                                                              *
    *                        oferExample()                         *
    *                                                              *
    *                       Main entry point                       *
    *                                                              *
    ***************************************************************/
    
    procedure(oferExample()
        unless(boundp('oferExampleForm)
    	oferCreateForm()
    	)
        unless(boundp('oferUserDataForm)
    	oferCreateUserDataForm()
    	)
        hiDisplayForm(oferExampleForm)
        )
    

    Regards,

    Andrew.

    • Post Points: 20
  • Wed, Sep 9 2009 8:23 AM

    • ToMWUT
    • Top 150 Contributor
    • Joined on Mon, Apr 20 2009
    • Warsaw, Poland
    • Posts 48
    • Points 795
    Re: Adding elements to open form in SKILL Reply

     Thanks Adrew, your code was very helpful.

    ToM

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by ToMWUT at 09 Sep 2009 03:22 AM. Topic has 2 replies.