Home > Community > Forums > PCB SKILL > How to use setVarWriteProtect to protect a defstruct variable?

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 use setVarWriteProtect to protect a defstruct variable? 

Last post Sun, May 6 2012 10:04 PM by eDave. 7 replies.
Started by Angeila 03 May 2012 07:29 PM. Topic has 7 replies and 2821 views
Page 1 of 1 (8 items)
Sort Posts:
  • Thu, May 3 2012 7:29 PM

    • Angeila
    • Not Ranked
    • Joined on Fri, May 4 2012
    • Posts 5
    • Points 70
    How to use setVarWriteProtect to protect a defstruct variable? Reply

    Hi Expert,

     I use defstruct to define a struct variable. For example:

     defstruct(mystruct aaa bbb)

     s1 = make_mystruct(?aaa 1 ?bbb 2)

     then I use setVarWriteProtect to make s1 write protected:

     setVarWriteProtect('s1)

     But when I change s1->aaa = 5, it still can be modified. Seems only s1 is write protected, but no its member variables.

     How to write protect the member variable s1->aaa? Is there anyway to do it in Skill if not by function setVarWriteProtect?

     Regards,

    Angelia

    Filed under:
    • Post Points: 5
  • Thu, May 3 2012 11:05 PM

    • Angeila
    • Not Ranked
    • Joined on Fri, May 4 2012
    • Posts 5
    • Points 70
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply
    Any one can help me out? thanks!!!
    • Post Points: 5
  • Sun, May 6 2012 7:49 PM

    • Angeila
    • Not Ranked
    • Joined on Fri, May 4 2012
    • Posts 5
    • Points 70
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply

    Help please...

    • Post Points: 35
  • Sun, May 6 2012 8:01 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 717
    • Points 15,550
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply

    Hi Angeila,

    We're not ignoring you. It's just that we don't know the answer or if it is possible. I think it might be a question for a Cadence person.

    Why do you want to protect it like this? I can't really think of a good reason.

     Dave 

    Dave Elder, Tait Communications
    • Post Points: 20
  • Sun, May 6 2012 8:12 PM

    • Angeila
    • Not Ranked
    • Joined on Fri, May 4 2012
    • Posts 5
    • Points 70
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply

    Hi Dave,

      Thanks for your kindly response:)

      I created a structure which will be shared by other team members after I initialize it, and it will be surved as read-only purpose as I don't want it to be changed by other team members by accident.

      I am a greenhand to Skill language, when I refer to skill user guide, I found setVarWriteProtect can meet such requirement, but it does not work a defstruct variable.

      Could you please share me any feasible way to do so?

    Thanks,

    Angelia 

    • Post Points: 5
  • Sun, May 6 2012 8:22 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 717
    • Points 15,550
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply

    Generally variables should be set to be local by including them in a let statement. Local variables cannot be changed by users.

    You may have to re-think your code if you want to protect the contents of a global variable. The documentation states that the behavior of this is not specified.

    Dave Elder, Tait Communications
    • Post Points: 20
  • Sun, May 6 2012 9:59 PM

    • Angeila
    • Not Ranked
    • Joined on Fri, May 4 2012
    • Posts 5
    • Points 70
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply
    eDave:

    Generally variables should be set to be local by including them in a let statement. Local variables cannot be changed by users.

    You may have to re-think your code if you want to protect the contents of a global variable. The documentation states that the behavior of this is not specified.

    Hi Dave,

      Thanks! Actually that is not a global variable, it(the defstruct variable) is passed as a function parameter.  it might be Skill limitation to write protect a defstruct variable. Not sure...

      Anyway, I will think about other way to protect it.

      Another interesting phenomena I found is that a local variable defined in parent function is visible in its child function.

      Please look at following example, cellName is visible in function testCell(), it can be printed out as "abc" when call function mytest().

      It behaves differently compared with that of C language, and other script language, like Tcl.  Is there any special purpose for SKILL to do so?

     procedure( mytest()
      prog( (cellName)
        cellName = "abc"
        testCell()
      )
    )
    procedure( testCell()
      prog( ()
        printf("cell name is %s ...\n" cellName)
      )
    )

    Thanks,

    Angelia 

    • Post Points: 20
  • Sun, May 6 2012 10:04 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 717
    • Points 15,550
    Re: How to use setVarWriteProtect to protect a defstruct variable? Reply

    Hi Angelia,

    Yes, I had noticed that behaviour - sometimes it's useful, but I think it's bad practice use it deliberately.

    Dave 

    Dave Elder, Tait Communications
    • Post Points: 5
Page 1 of 1 (8 items)
Sort Posts:
Started by Angeila at 03 May 2012 07:29 PM. Topic has 7 replies.