Skip to main content

if .. else

if .. else statement

An expression is evaluated and when it is true, the block within the if statement will be executed. Otherwise the block within the else statement will be executed.

Multiple if .. else can be defined to create a circuit graph based on different conditions.

Here is an example:

import lib

vcc = supply("VCC")
gnd = dgnd()

use_resistor = false

at vcc
wire down 100
branch:
wire right 200 down 100

if use_resistor:
add res(10k)
else:
add cap(100n)

wire down 100
to gnd

wire down 100
add res(10k)

wire down 100
to gnd

VCC12C1100nGND12R110kGND