Maker of the Optical Design Software OpTaliX

Home  | Download  | Prices  | About Us  | Sign-In  | FAQ  | Links

OpTaliX Macro Language

OpTaliX includes a macro language to allow custom analysis and computations. The macro language encompasses the following areas:



A macro is a sequence of OpTaliX commands, arithmetic expressions and database items stored in a file. Macro features can be used throughout the whole program, e.g. in the command line, in the definition of the optimization merit function and in user defined graphics. Macros can be run from either command or GUI mode.


Examples:

The following examples indicate some of the macro capabilities, with increasing complexity from top to bottom. The macro "mymacro.mac" is executed from the command line by

run mymacro.mac 3 0.546

In the sample command above, two parameters are passed to the macro. the macro may also executed (run) from the menu. Here are some commented sample entries in a macro file:

! Example macro The character  !  indicates a comment. This line is not executed.

$x = 15 Defines a user-defined variable and assigns a value. User-defined variables always begin with the $-character.

@xxx = sqrt($x)+[efl] Defines a user-defined function. User-defined functions always begin with the @-character.

res c:\temp\demo.otx Restores an optical system

lis ; vie; fan Multiple commands/expressions can be entered in a single line, separated by semicolons.

sca sa 2*pi Use previously defined constants in expressions. This command scales all surfaces (sa) by 2p.

wl w%1 %2 Use parameters (%1, %2), which have been passed to the macro from the command line. From the parameters given above, the command translates to:  wl w3 0.546

print 'Radius of surface 2 is:' [rdy s2] Retrieve lens parameter or performance parameter and use it in other expressions. Here  rdy s2  is the radius on surface 2.

thi s3 sqrt(2)*[thi s2] Use lens database items in more complex expressions and assign it to other lens parameter.

print 'Square root of 2: ' 2*sqrt( &
2)
Span expressions over several lines. Continuation is defined by the & character.


do $x = 1,9,2
   print $x sqrt($x)
enddo
DO-loop construct. Nesting depth is 20.




if ($a > 3) then
   print '$ a is greater than 3'
else
   print '$ a is less than or equal to 3'
endif
IF construct. Nesting depth is 20.

Intrinsic Functions:

There exist also an extensive set of intrinsic functions, which may be used in the command line, in macros, in defining optimization constraints or in specifying lens description parameters:

sin(r) sine of angle in radians
cos(r) cosine of angle in radians
tan(r) tangent of angle in radians
exp(x) ex
log(x) natural logarithm
log10(x) common logarithm
logn(n,x) logarithm base n
sqrt(x) square root
acos(r) arccosine
asin(r) arcsine
atan(r) arctangent
cosh(r) hyperbolic cosine
sinh(r) hyperbolic sine
tanh(r) hyperbolic tangent
besj0(r) Bessel function 1st kind, order 0
besj1(r) Bessel function 1st kind, order 1
besjn(n,x) Bessel function 1st kind, order n
aint(x) truncate to a whole number
anint(x) real representation of the nearest whole number
abs(x) absolute value
min(a,b) minimum value
max(a,b) maximum value


The macro capability in OpTaliX makes use of the Function Parser Module of Stuart Midgley.