This repository has been archived by the owner on Mar 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Example 11
Stanislav Mikhel edited this page Jun 29, 2017
·
1 revision
Use has possibility to create its own type of elements using internal language for element description. Such description must be saved as a file '.t' it the same directory as the main script. File and type names are must be the same. String variable in the first line (if it is exists) will be a type description. Then connectors and parameters are should be described. Each section begins from the ellipses and a theme: IN - input connectors, OUT - output connectors, PAR - parameters. Lust section is started with '... FUNC' and it describes the element behaviour. It can contain variables, conditions and loops.
As an example let's create a generator for meander.
# meander.t
"Meander generator" # type description
... PAR
# parameters
amp, t # define amplitude and period
amp: "meander amplitude" # add description
amp: val = 1 # default value
t: val = %pi # default period
... OUT
# output connectors
out0: type = number # output for single number (default)
... FUNC
# data processing
# use sinusoid and time variable 'tau'
k = 2*%pi/t # internal variable
IF sin(k * tau) > 0 THEN
out0 = amp
ELSE
out0 = 0
END
User type can be used in the same way as all internal types.
&MEANDER a: t = %pi/4
&SYNC b
a -> b
Run %pi, 0.1