Home > Community > Forums > PCB SKILL > How to keep your variables in the design?

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

 How to keep your variables in the design? 

Last post Thu, Aug 16 2012 4:11 AM by pcbnagaraj. 25 replies.
Started by Silver John 11 Jul 2011 08:08 AM. Topic has 25 replies and 8093 views
Page 1 of 2 (26 items) 1 2 Next >
Sort Posts:
  • Mon, Jul 11 2011 8:08 AM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    How to keep your variables in the design? Reply

    Hi, All.

    I have a script that creates a form with several fields. I want to save the contents of these fields in design, and the next time when I open the design and launches the script I have already configured the form.

    There are functions for including the file or string to .brd-file, there are functions for working with the properties of the design...

    What is the best way to save my settings?

    Maybe someone has an example code?

    Thank you.

    Filed under:
    • Post Points: 50
  • Mon, Jul 11 2011 8:38 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 291
    • Points 4,640
    Re: How to keep your variables in the design? Reply

     I woud look at using Skill's disembodied property list and the save the list in the database as an attachment (see axlSetAttachment).

    On read you can eval the attachment return (axlGetAttachment) which will give you free parsing and the disembodied prop list gives you some future profing if you need to latter on you need to extend what you are storing.

    • Post Points: 20
  • Mon, Jul 11 2011 3:47 PM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    Re: How to keep your variables in the design? Reply

    It does not work. axlCreateAttachment () does not accept the list.
    It is necessary to print the list to a string?

    • Post Points: 20
  • Tue, Jul 12 2011 4:39 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 291
    • Points 4,640
    Re: How to keep your variables in the design? Reply

     You need to convert the disem prop list to a string and pass it as the argument t_data. Also s_dataFormat needs to be set to a value of 'string, To convert a disembodied prop list to a string just do:

          dataString = sprintf(nil " '%L" myDisembodyPropStruct)

    while it might be hard to see the single quote (') immediately before the %L is important for "Get" part of the process.

     To convert back from a string do:

      str = axlGetAttachment(... 'string)

      myDisembodyPropStruct = errsetstring(str)

    • Post Points: 35
  • Tue, Jul 12 2011 11:27 AM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    Re: How to keep your variables in the design? Reply

    Thanks. It works.

    Do you think this is a good solution for storing these data in design file? Or it may be better to save them in a separate file? Why?

    • Post Points: 5
  • Mon, Jul 18 2011 2:10 PM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    Re: How to keep your variables in the design? Reply

     For a better understanding of the issue: we are talking about additional editing tool for aligning objects on the board. The default tools are stored individual settings for each design (probably in the design).
    But would not it be negative consequences if I save my data in the design? Maybe in the next version of the editor, this feature will be unavailable or even break down the design? Or perhaps these data will be conflict with other programs?
    Does anyone have an opinion on this issue? How do you keep your variables, in the design or in a separate file?

    • Post Points: 20
  • Mon, Jul 18 2011 4:18 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 717
    • Points 15,550
    Re: How to keep your variables in the design? Reply
    I just add properties to the design. Just take care to suitably name the properties to avoid conflicts.
    Dave Elder, Tait Communications
    • Post Points: 20
  • Tue, Jul 19 2011 10:56 AM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    Re: How to keep your variables in the design? Reply

    Thank you, Dave.

    How long you use this method? Wasn't problems?

     

    • Post Points: 20
  • Tue, Jul 19 2011 1:04 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 717
    • Points 15,550
    Re: How to keep your variables in the design? Reply
    I have used this method for several years without a problem.
    Dave Elder, Tait Communications
    • Post Points: 5
  • Thu, Aug 25 2011 11:14 AM

    • Ejlersen
    • Top 10 Contributor
    • Joined on Mon, Jul 28 2008
    • Aalborg, Copenhagen
    • Posts 556
    • Points 9,795
    Re: How to keep your variables in the design? Reply

    Hi fxffxf

    I've been trying to get this to work using the desribed method but don't seem to be able to go back to an disembodied property list.

    I have the following simple example

    mylist = ncons(nil)
    mylist->ccw = t
    mylist->middle = nil
    mylist->cx = 0.12
    mylist->cy = 10.192
    mylist->layer = "TOP"
    mylist->stype = "LEFT"

    dataString = sprintf(nil " '%L" mylist)

    axlCreateAttachment("_ns_planar_settings" nil 0 'string dataString)

    The above does create my attachment. I can easily read it using

    a_id = axlGetAttachment("_ns_planar_settings" 'string) which returns an attachment id

    mylist1 = errsetstring(a_id->data) will return a list, but I cannot access the data using -> syntax

    typing mylist1 at the skill development window works. but still how do I access the list?

    I would expect mylist1->layer but that returns nil

    Skill > mylist1
    ((nil stype "LEFT" layer "TOP"
        cy 10.192 cx 0.12 middle
        nil ccw t
        )
    )

    Best regards

    Ole

    Best regards Ole
    • Post Points: 35
  • Thu, Aug 25 2011 12:10 PM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    Re: How to keep your variables in the design? Reply

     Find two differences ;)

    Skill > mylist1 = errsetstring(a_id->data)
    ((nil middle nil ccw t))
    Skill > mylist
    (nil middle nil ccw t)

    Yes, I too faced with this problem.
    You can use: mylist1 = car(errsetstring(a_id->data))

    Also, I store the data without " ' ", and add an apostrophe at the time of restoring:
    sFormData = sprintf(nil "%L" _formData)
    ...
    sFormData = attachment->data
    formData = car(errsetstring(strcat("'" sFormData)))

    • Post Points: 20
  • Thu, Aug 25 2011 12:23 PM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 291
    • Points 4,640
    Re: How to keep your variables in the design? Reply

    You are missing one last car since errsetstring returns a list which has a list, add

         mylist1 = car(mylist1)

    then you can do

         mylist1->stype

    • Post Points: 5
  • Thu, Aug 25 2011 1:05 PM

    • Ejlersen
    • Top 10 Contributor
    • Joined on Mon, Jul 28 2008
    • Aalborg, Copenhagen
    • Posts 556
    • Points 9,795
    Re: How to keep your variables in the design? Reply

    Hi

    thanks for your help, my mistake i missed the extra paranthesis.

    This is really an excellent way to store skill program settings inside a database file

    Best regards

    Ole

    Best regards Ole
    • Post Points: 35
  • Thu, Aug 25 2011 1:21 PM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 291
    • Points 4,640
    Re: How to keep your variables in the design? Reply

     Summary of this technique:

         This uses an attachment to store in the database a list of variables. For
         example, you design a form where the user enters in their preferences and
         you manage them in Skill via a disembodied property list. You would like to
         store the user's preferences with the design.

         ; create an attachment name, DO NOT USE "fxf". I would suggest using an
         ; underscore, company name and application to make it unique. For example:
         ;   _acme_bom_rpt
         ; would be a good attachment name.
         attachName = "fxf"

         ; A typical disembodied property list
         mylist = ncons(nil)
         mylist->ccw = t
         mylist->middle = nil
         mylist->cx = 0.12
         mylist->cy = 10.192
         mylist->layer = "TOP"
         ; NOTE:
         ;    Do NOT Store dbid's in the disembodied list or make sure to remove
         ;    them before storing as an attachment.

         ; Store list in current design (assuming user saves design)
         dataString = sprintf(nil " '%L" mylist)
         axlCreateAttachment(attachName nil 0 'string dataString)

         ; Next time user runs your Skill code, here is how to init the list:
         attach = axlGetAttachment(attachName 'string)
         if( attach)  then
               mylist = car(errsetstring(attach->data))
         else     ; no list stored in design so init to default settings
              mylist = ncons(nil)
              mylist->ccw = t
         )

    • Post Points: 20
  • Thu, Aug 25 2011 1:36 PM

    • Silver John
    • Top 150 Contributor
    • Joined on Sun, Apr 10 2011
    • -, Belarus
    • Posts 50
    • Points 965
    Re: How to keep your variables in the design? Reply

    Yes, excellent. Thanks again fxffxf.

    Ole, you can see the implementation for the storing to attachment, to property or to a file in Align tool (storeFormData() and restoreFormData()).

    fxffxf, how long you use the save as attachment? There were no problems?

    PS I already feeling paranoid with this reliability.

    • Post Points: 20
Page 1 of 2 (26 items) 1 2 Next >
Sort Posts:
Started by Silver John at 11 Jul 2011 08:08 AM. Topic has 25 replies.