Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

lua length command # :

DMM6500 6½-Digit Touchscreen Multimeter
Post Reply
[email protected]
Posts: 5
Joined: January 7th, 2019, 1:02 pm
Country: Belgium

lua length command # :

Post by [email protected] » March 9th, 2019, 5:37 am

When using the lua length command '#', I get error unexpected symbol near '#' :

Code: Select all

function fft(vect)
  local n=#vect
The variable n should get the lenght of the parameter vect.

The error shows in the script builder and also when I try to load the script on my DMM6500.

[email protected]
Posts: 5
Joined: January 7th, 2019, 1:02 pm
Country: Belgium

Re: lua length command # :

Post by [email protected] » March 9th, 2019, 6:34 am

I get this error when using these constructs:


#:

Code: Select all

function fft(vect)
  local n=#vect
...:

Code: Select all

function complex.new( ... )
   return setmetatable( { ... }, complex_meta )

%:

Code: Select all

local function next_possible_size(n)
  local m = n
  while (1) do
    m = n
    while m%2 == 0 do m = m/2 end

Brad O
Keithley
Keithley
Posts: 28
Joined: February 3rd, 2018, 10:43 am
Country: United States

Re: lua length command # :

Post by Brad O » March 11th, 2019, 8:01 am

TSP is based on Lua 5.0, so some of those constructs aren't present. You can find the Lua 5.0 Reference Manual here: https://www.lua.org/manual/5.0/.

So to get the length of a table you would use table.getn(). For modulus, I would use

Code: Select all

function mod(a, b)
    return a - (math.floor(a/b)*b)
end
The vararg construct"..." should work though. I believe the syntax is different in 5.0 compared to later versions. In 5.0, all other parameters are placed in a table named "arg" and are callable with arg.parameter_name or via their index in the arg table. Look in section 2.5.8 of the Lua Reference Manual for details.

[email protected]
Posts: 5
Joined: January 7th, 2019, 1:02 pm
Country: Belgium

Re: lua length command # :

Post by [email protected] » March 11th, 2019, 1:49 pm

The .getn() and mod approach work nicely. Thanks.
I'll check the variable arguments construct later - I'm currently getting by by commenting it out, it was just a logging function.
Thank you for the link.

Post Reply

Return to “DMM6500 Bench/System DMM”

Who is online

Users browsing this forum: No registered users and 2 guests