<-- back to the index of scripting examples

voltage divider calculator

Select two resistors that form a voltage divider and calculate output voltage or tune resistor values when output voltage is changed. Can modify resistor values on the drawing.
Example implementation
divider.fawk
Explanation, step by step
Select two resistors that form a voltage divider and calculate output voltage or tune resistor values when output voltage is changed.

The script picks up exactly two resistors from the selection and presents a dialog box where the user can change values. The calculator will recalculate the resulting value upon changes. If the user clicks on "set & close", the script writes back resulting resistor values.

Note: +0 in fawk (and in awk) triggers a conversion to numeric value. This is used to make sure arrays are indexed with numbers and numeric widgets are loaded with numbers.

How to test: