Page 1 of 1

Getting error [string "line"]:4: attempt to call global 'rank' (a nil value)

Posted: Saturday 05 June 2021 0:04
by Deepak
Can someone please let me know the reason behind this error? I am punching ranking grid question to hidden multi punch question.

Error: [string "line"]:4: attempt to call global 'rank' (a nil value)

Programming code:
rank = tonumber(rank)
q11_1=tonumber(rank("Q11_001"))
print(q11_1)
sel={}

if in_array("1",q11_1) or in_array("2",q11_1) or in_array("3",q11_1) then
print(option1)
table.insert(sel,"1")
end

print(sel)
setvalue("MRK_Q11",sel)

Any help would be really appreciated! Thank you.

Re: Getting error [string "line"]:4: attempt to call global 'rank' (a nil value)

Posted: Saturday 05 June 2021 8:44
by waaren
Deepak wrote: Saturday 05 June 2021 0:04 Can someone please let me know the reason behind this error? I am punching ranking grid question to hidden multi punch question.
Error: [string "line"]:4: attempt to call global 'rank' (a nil value)
In line

Code: Select all

rank = tonumber(rank)

You made the script variable rank a number (or nil if rank could not be converted to a number.

In the next code line you try to all rank as a function.

Code: Select all

q11_1=tonumber(rank("Q11_001"))