OpTaliX宏語言
OpTaliX包含一種宏語言,可以進行自定義分析和計算。宏語言包含以下領域:
在需要數字輸入項的任何地方使用算術表達式。
可以訪問各種鏡頭參數和性能數據,這些數據可以從程序的內部數據庫中檢索,並且可以在算術表達式中重複使用。
訪問最常見的數學函數(sin,tan,cos,sinh,cosh,tanh,asin,acos,atan,sqrt,exp,log,log10,logn,besj0,besj1,besjn,abs,min,max,aint, anint)
用戶定義的變量和函數
將參數傳遞給宏
在其他宏文件中包含宏,並通過基本宏或命令構建複雜的任務。
循環結構:DO-ENDDO和WHILE-ENDWHILE
條件構造:IF-ELSE-ELSEIF-ENDIF
文件和數據處理:OPEN,CLOSE,READ,WRITE /
PRINT
宏是存儲在文件中的一系列OpTaliX命令,算術表達式和數據庫項目。宏功能可在整個程序中使用,例如在命令行中,在優化優值功能的定義中以及在用戶定義的圖形中使用。宏可以從命令或GUI模式運行。
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
|