# 10. cschem implementation - forge

{imp10:0} The most common example of for forge is the generic power (rail) symbol. The power symbol has a single terminal, usually named 1. This terminal should be connected to the rail network named, within the symbol, e.g. to VDDQ. This can be done using the connect attribute with value 1:VDDQ.

{imp10:1} But VDDQ also needs to be printed as a dyntext. Dyntext can not address the first element of an array and especially can not remove the "1:" section. If the text object contains simply "VDDQ" without dyntext, it means this information is stored twice, once in the connect attribute, once in the text object. Such setup is prone to errors in case of a generic power symbol where the user needs to change the rail text. (It is okay to hardwire things like that in a Vcc-like symbol where the user can not change rail value.)

{imp10:2} An easy solution with the forge plugin is to store "VDDQ" in an custom attribute, which is printed using dyntext and not specify the connect attribute at all. Instead specify forge that creates connect from the custom attribute.

{imp10:3} Example forge script for the above, assuming the custom attribute is called rail and terminal name is 1:

    delete,forge/tmp
    scalar,forge/tmp
    sub,^,1:,forge/tmp
    suba,$,rail,forge/tmp
    array,connect
    append,connect,forge/tmp

{imp10:4} The first two operations ensures an empty scalar attribute called forge/tmp. The next two use regex to build 1:rail in forge/tmp (rail is substituted with the value of attribute rail, because of suba). The last two operations ensure connect exists as an array type attribute and appends the new connection to it.