Electric has the Bean Shell built into it. This enables you to load Java scripts that access the Electric database.

The Bean Shell is not part of the default Electric distribution. You must add it as a "plug in" (see Section 1-5 for more on plug-ins).

To run a script, use the Run Java Bean Shell Script command (in menu Tool / Languages). Here is an example script that searches the current cell for exports starting with "a".

`import com.sun.electric.database.hierarchy.Cell;
import com.sun.electric.tool.user.ui.WindowFrame;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
// read library with test setup
Cell lay = WindowFrame.getCurrentCell();
// find all exports
com.sun.electric.database.hierarchy.Export e;
List aList = new ArrayList();
for(Iterator it = lay.getPorts(); it.hasNext(); )
{
e = (com.sun.electric.database.hierarchy.Export)it.next();
if (e.getName().startsWith("a")) aList.add(e);
}
String aOut = "Exports that start with 'a':";
for(Iterator it = aList.iterator(); it.hasNext(); )
{
e = (com.sun.electric.database.hierarchy.Export)it.next();
aOut += " " + e.getName();
}
System.out.println(aOut);`

Notice that Electric's "Export" object must be a fully-qualified name, because the name "Export" is used for other reasons in the Bean Shell. This also applies to Electric's "EPoint" class.

For more information about accessing the internals of Electric, read the Javadoc in the source code.