Common syntax:
#def {macros_name}$({arguments})
{body}
#end def
The full equivalent one-line syntax (possible only if {body} contains one line):
#def {macros_name}$({parameters}) = {body}
Calling:
{macros_name}$({arguments})
{macros_name}$
- must satisfy the same rules as variable naming, but must ends with $
, for example: macro_1$
, MACRO1$
, β$
, a,0$
, e.t.c.
{parameters}
- parameters list, must satisfy the same rules as simple function parameters, but no parameters is allowed.
{arguments}
- arguments list. Several arguments must be separated by semicolon ;
. Arguments can be: variable names, function names, equations, assigments, macros names (with $).
{body}
- one or several lines, processing like a flat calculation code, but variables/functions that eponymous with parameters are replaced by arguments
#def CHECK$(σ; IσI)
#if σ ≤ IσI
'<font color="green">The condition is satisfied</font> ('σ'≤'IσI')
#else if σ ≤ IσI*1.05
'<font color="orange">The condition is satisfied</font> ('σ' exceeds 'IσI
#val
' by '(1 - IσI/σ)*100'%)
#equ
#else
'<font color="red">The condition is satisfied</font> ('σ'>'IσI')
#end if
#end def
τ=100MPa
IτI=150MPa
CHECK$(τ; IτI)
Output:
τ=100MPa
IτI=150MPa
The condition is satisfied (τ=100MPa≤IτI=150MPa)
One-line #val
/#equ
#def VAL$(v)
#val
v
#equ
#end def
τ = 100MPa
VAL$(τ)
VAL$(τ = 300MPa)
VAL$(τ + 10MPa)
τ = 200MPa
Output:
τ=100MPa
100
300
310
τ=200MPa
Expample of nested #hide
/#show
#hide
hide.depth = 0
#show
#def HIDE_OPEN$()
#hide
hide.depth = hide.depth + 1
#end def
#def HIDE_CLOSE$()
#hide
hide.depth = hide.depth - 1
#if (hide.depth ≤ 0)
#show
#end if
#end def
#def EXAMPLE$(a)
HIDE_OPEN$()
x = a
HIDE_CLOSE$()
'There x: 'x
#end def
EXAMPLE$(100)
'---
HIDE_OPEN$()
EXAMPLE$(200)
HIDE_CLOSE$()
'---
EXAMPLE$(300)
Output:
There x: x = 100
---
---
There x: x = 300
σ_y=100MPa
σ_u=200MPa
#if σ_y/σ_u > 0.7
#def STEEL$() = 'Strange steel
#else
#def STEEL$() = 'Normal steel
#end if
'Steel type: 'STEEL$()
Output:
σ_y=100MPa
σ_u=200MPa
Steel type: Normal steel
Main idea is to replace parameters on every macro calling at RUNTIME and then execute it as NORMAL CODE. If this NORMAL CODE agan contains macros calling - we replace variables again and execute it as NORMAL CODE.
Text passing in arguments
#def CHECK$(σ;IσI;condition)
#if σ ≤ IσI
'<font color="green">The condition is satisfied ('condition()')</font> ('σ'≤'IσI')
#else
'<font color="red">The condition is not satisfied ('condition()')</font> ('σ'>'IσI')
#end if
#end def
τ = 100MPa
IτI = 150MPa
#def text$() = 'for production
CHECK$(τ;IτI;text$)
'---
τ_test = 120MPa
IτI_test = 180MPa
#def text$() = 'for test
CHECK$(τ_test;IτI_test;text$)
Output
τ=100MPa
IτI=150MPa
τ_test=120MPa
IτI_test=180MPa
The condition is satisfied (for production) (τ=100MPa≤IτI=150MPa)
The condition is satisfied (for test) (τ_test=120MPa≤IτI_test=180MPa)
Inverse calculation order
#def INVERSE_ORDER$(F1;F2)
#hide
F2()
#show
'<center>'F1',</center>
'where:
F2()
#end def
'Perimeter:
#def ARGS$()
'  'a = 200mm' - width;
'  'b = 10mm' - height.
#end def
INVERSE_ORDER$(P = 2*(a + b);ARGS$)
'Area of round is:
#def ARGS$()
'  'd = 50mm' - diameter.
#end def
INVERSE_ORDER$(A = π*d^2/4;ARGS$)
Output
Perimeter:
P = 2·(b + c) = 2·(200mm + 10mm) = 420mm,
where:
a = 200mm - width;
b = 10mm - height.
Area of round is:
A = π·d²/4 = 3.14·50mm²/4 = 1963.5mm²,
where:
d = 50mm - diameter.
Thank you! This is very useful. I am already back on this and advancing. I will send you a pre-release for testing soon. :)