Skip to content

LUA Scripting Examples 3

The context is:

$ROICIIndex contains index of ROI sampling point
$ROICIIndexMin = 1
$ROICIIndexMax = 7
$ROICIIndexMin <= $ROICIIndex <= $ROICIIndexMax

This example shows the mix between Internal and LUA Scripting.
Note: Internal Scripting includes the commands to execute LUA Scripting.
Note 2: LUST() is the Internal Scripting method to use LUA Scripting to return string.

Block(Set("value"; M2!Scalar);LUST("
local x=1
local y=0
while x < 10 do
  x = x+1
  y = y+$value
end
_luareturnvalue='Test at ' .. x .. ' value ' .. y

print(_luareturnvalue)
"
))

The function 'print' outputs the following information from _luareturnvalue:

Test at 10 value 1.063003256088
Test at 10 value 1.465934553949
Test at 10 value 1.3363623062945
Test at 10 value 2.0741435856034
Test at 10 value 1.3205236056529
Test at 10 value 1.9750611850204
Test at 10 value 1.7541142763036
Test at 10 value 3.1620365589769