Home > Community > Forums > PCB SKILL > Create a simple form with SKILL code

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: *

 Create a simple form with SKILL code 

Last post Fri, Jul 31 2009 5:44 AM by aCraig. 1 replies.
Started by Alice 30 Jul 2009 11:45 PM. Topic has 1 replies and 2403 views
Page 1 of 1 (2 items)
Sort Posts:
  • Thu, Jul 30 2009 11:45 PM

    • Alice
    • Top 500 Contributor
    • Joined on Wed, Oct 8 2008
    • Bayan Lepas, Pulau Pinang
    • Posts 20
    • Points 355
    Create a simple form with SKILL code Reply

    Hi,

    I am trying to understand how the form works in SKILL. Hence, I read thru the agroskill.pdf and tried to run the 2 sample skill, myExtractViews.il and formpop.il. However, I got those errors:-

    Skill > load "myExtractViews.il "
    function myExtractViews redefined
    function _extract redefined
    function _formAction redefined
    function myExtract redefined
    t
    Skill > myExtract()
    E- *Error* axlFormTitle: argument #1 should be any user-defined (other) type (type template = "ot") - nil
    ERROR
    Skill >

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

    Skill > load "formpop.il"
    function _popAction redefined
    function myPop redefined
    t
    Skill > myPop()
    "Error! Could not create form."
    E- *Error* axlFormTitle: argument #1 should be any user-defined (other) type (type template = "ot") - nil
    ERROR

    Can anyone help? how to solve the error? also, any sample of the skill using form for me to learn ?

    Thanks a lot =)

    Regards,

    Alice

    I cannot fine the attach icon, so I am copying the skill code as below:-

    ; myExtractViews.il
    ; -- Displays a form with a selection list of
    ; the available extract definition files
    ; -- Lets the user select any of the files on
    ; the list as the “View file”
    ; -- Starts Allegro extract process with the
    ; user-selected View file when
    ; the user picks Done from the form.
    ; Function to extract user selected view to the output file.

    (defun myExtractViews (viewFile outFile)
    axlExtractToFile( viewFile outFile)
    ); defun myExtractViews
    ; Function to start the view extraction

    (defun _extract ()
    myExtractViews(
    buildString(list(cadr(parseString(
    axlGetVariable("TEXTPATH"))) selectedFile) "/")
    "myextract.dat")
    ); defun _extract
    ; Form callback function to respond
    (defun _formAction (form)
    (case form->curField
    ("done"
    (axlFormClose form)
    (axlCancelEnterFun)
    (_extract)
    t)
    ("cancel"
    (axlFormClose form)
    (axlCancelEnterFun)
    nil)
    ("view_file"
    (if form->curValue
    (progn
    ; Accept user input only if on list
    if(member( form->curValue fileList)
    then axlFormSetField( form
    "view_file" form->curValue)
    else axlFormRestoreField(
    form "view_file"))))
    t)
    ("file_list"
    (axlFormSetField form "view_file"
    form->curValue)
    selectedFile = form->curValue
    t)); case
    ); defun _formAction
    ; User-callable function to set up and
    ; display the Extract Selector form

    (defun myExtract ()
    fileList = (cdr (cdr (getDirFiles
    cadr( parseString( axlGetVariable("TEXTPATH"))))))
    form = axlFormCreate( (gensym)
    "extract_selector.form" '("E" "OUTER")
    '_formAction t)
    axlFormTitle( form "Extract Selector")
    axlFormSetField( form "view_file" (car fileList))
    selectedFile = (car fileList)
    foreach( fileName fileList
    axlFormSetField( form "file_list" fileName))
    axlFormDisplay( form)
    ); defun myExtract

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

    ; formpop.il - Create and display a form with a popup
    ; Form call back function to respond to user selection of any field in the form
    (defun _popAction (form)
      (case form->curField
            ("done"
              (axlFormClose form)
              (axlCancelEnterFun)
              t)
            ("change_pop"
              (case already_changed
                  (0;Use display/dispatch string pairs
                      axlFormBuildPopup(form "my_popup"
                      list(
                      list("NewPopup A" "mynewpopup_a")
                      list("NewPopup B" "mynewpopup_b")))
                    axlFormSetField(form "my_popup"
                        "My First Popups")
                    )
                  (1;Display string/dispatch integer pairs
                      axlFormBuildPopup(form "my_popup"
                        list( list("NewPopup 12" 12)
                        list("NewPopup 5" 5)))
                        axlFormSetField(form "my_popup"
                            "My Second Popups")
                    )
                      (t;String is both display and dispatch
                          axlFormBuildPopup(form "my_popup"
                          list( "MyPopNValue1"
                                  "MyPopNValue2"))
                          axlFormSetField(form "my_popup"
                                   "My Third Popups")
                          )
                          )
                          already_changed++
                          t)
              ("my_popup"
                  printf( "Got my_popup event:
                      form->curValue %s", form->curValue)
                  if( form->curValue
                    (progn
                     axlFormSetField( form "my_popup"
                          form->curValue)))
               t)
          ); case
        )
    ; defun _popAction
    ; User-callable function to set up and
    ; display the Extract Selector form

    (defun myPop ()
      form = axlFormCreate( (gensym) "popup.form"
              '("E" "OUTER") '_popAction t)
             if( axlIsFormType(form)
                then (print "Created form successfully.")
                  else (print "Error! Could not create form."))
            axlFormTitle( form "Try My Popup")
            mypopvalue = "my_start_popup"
            axlFormSetField( form "my_popup" mypopvalue)
            axlFormDisplay( form)
            already_changed = 0
    ); defun myPop

    • Post Points: 20
  • Fri, Jul 31 2009 5:44 AM

    • aCraig
    • Top 50 Contributor
    • Joined on Sat, Aug 16 2008
    • Pepperell, MA
    • Posts 132
    • Points 2,070
    Re: Create a simple form with SKILL code Reply

     Alice,

     It looks like you should execute  "myExtract()" not "myExtractViews()" . Make sure you have the .form file in your FORMPATH or the current working directory.

    There are other form examples at $CDSROOT/share/pcb/examples/skill/form. One of my favorites is "axlform" in the basic directory. It has an example of all the basic form features. 

    • Post Points: 5
Page 1 of 1 (2 items)
Sort Posts:
Started by Alice at 30 Jul 2009 11:45 PM. Topic has 1 replies.