How do you pass a parameter to a function in a module.

Starting with the following in my scene

                            print(“going in”)----> going in

                            print(pwValue[3].value) ----> 2014

                            

                            if util.leapyear(pwValue[3].value) 

in utility module

function M:leapyear(year)

    print(“you are in”)----> you are in

    print("year is "…year)

    local yr = tonumber(year)

    print(tostring(yr%4))

    print(tostring(yr))

    local leap = “No”

    if(yr%4)  == 0 and (yr%100~=0 or yr%400==0)  then

        leap = “Yes”

    end

        print(leap)

    return leap

    

end

results in 

going in

2014

you are in

Runtime error

/Users/rvergin/Library/Application Support/Outlaw/Sandbox/11/utilityfunctions.lua:237: attempt to concatenate local ‘year’ (a nil value)

Why is it nil? 

even adding tostring

    print("year is "… tostring(year))

I get 

year is nil

Can you provide more code? Specifically the pwValue[n].value. 

                local pwValue = pickerwheel1:getValues()

provides the values and index 3 is the year as you can see in the print statements and the log.

have you already tried simplifying it to the point where you are explicitly declaring the passed variable? Something like this:

local yearVal = 2014 util.leapyear(yearVal)

same error yearval is nil.

I have set up a global variable and set its’ value without passing it and the math works.

even adding tostring

    print("year is "… tostring(year))

I get 

year is nil

Can you provide more code? Specifically the pwValue[n].value. 

                local pwValue = pickerwheel1:getValues()

provides the values and index 3 is the year as you can see in the print statements and the log.

have you already tried simplifying it to the point where you are explicitly declaring the passed variable? Something like this:

local yearVal = 2014 util.leapyear(yearVal)

same error yearval is nil.

I have set up a global variable and set its’ value without passing it and the math works.