discuss-gnu-electric
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Electric cell parameters in Java version


From: Steven Rubin
Subject: Re: Electric cell parameters in Java version
Date: Fri, 03 Dec 2004 08:06:19 -0800

At 08:45 PM 12/2/2004, you wrote:
Hi,

I've been trying to include Java code as the value for an attribute. I intend to use other parameter values as variables. The Java documentation, in Section 6-8-6, says that it can be done, but without an example, I'm quite lost. The C documentation, in Section 11-4, gives several code fragments, but they are not accepted when I try them.

Specifically, there is no Electric class, so how would I name the parameters I want to use in the expression?

Parameters have always been confusing in Electric, and although we tried to change them to be a bit simpler in the Java version, they are still difficult.

The first thing you need to do is to "declare" the parameter in the lower-level cell. This is done with the "Edit / Properties / Attribute Properties" command. At the top of the dialog, make sure "On Current Cell" is selected. Now you are editing the attributes for the current cell. Type a name and a default value, then click "Create New". This creates the parameter on the cell. Each instance of the cell that you create will have that parameter. I noticed that there is a bug in 8.00 which doesn't display the actual parameters on instances of the cell. But if you look at instances with the "Edit / Properties / Object Properties" command (^I) and choose the "Attributes" list at the bottom, you will see the parameter.

Each instance of the parameterized cell can have a different value for the parameter. That value can be a java expression, a number, or a string. If you use a Java expression, be sure to change the "Code" field to "Java".

Inside of the cell, you can retrieve the value of the parameter by using its name with an "@" in front of it inside of a Java expression. So, for example, if you want to use the parameter and place twice its value on an arc, double-click the arc to get its Properties dialog, click the "Attributes" button, and create a new attribute with the value "@test" (assuming that you called the cell parameter "test"), set Code: to Java, set Show: to name=value), and click "Create New". You will now see the parameter value. Try going up and down the hierarchy, into different instances of the cell with different parameter values on the instances.

   -Steven Rubin

P.S. A newer Java version of Electric is due out, hopefully this month.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]