Skip to main content
Known Participant
August 12, 2010
Answered

?:0: attempt to call upvalue '?' (a nil value)

  • August 12, 2010
  • 1 reply
  • 3096 views

I can't seem to get rid of this error (' ?:0: attempt to call upvalue '?' (a nil value) ').  What is "?:0:" ?

Thanks in advance for any help!

script:

local LrApplication = import 'LrApplication'
local LrDialogs = import 'LrDialogs'
local LrFileUtils = import 'LrFileUtils'
local catalog = LrApplication.activeCatalog()
local LrTasks = import 'LrTasks'


    function searchNtag()
        local targPhotos = catalog.getAllPhotos()
        for _, photo in ipairs(targPhotos) do
            local status = photo:getPropertyForPlugin('com.jonathonlefaive.tagstatus', 'tagboolean')
            if status then
                if status == nil then
                    local location = photo:getRawMetadata('path')
                    if LrFileUtils.isDeletable(location) == true then
                        photo:setPropertyForPlugin('com.jonathonlefaive.tagstatus', 'tagboolean', false, 2)
                    else
                        photo:setPropertyForPlugin('com.jonathonlefaive.tagstatus', 'tagboolean', true, 2)
                    end
                end
            end
        end
    end

function task()
    catalog.withPrivateWriteAccessDo(searchNtag)
end

LrTasks.startAsyncTask(task)

This topic has been closed for replies.
Correct answer areohbee

catalog.func should be catalog:func (colon instead of dot)

i.e. all catalog functions are object methods not static functions.

PS - not sure the meaning of the cryptic error message but I think this is your problem.

Rob

1 reply

areohbee
areohbeeCorrect answer
Brainiac
August 12, 2010

catalog.func should be catalog:func (colon instead of dot)

i.e. all catalog functions are object methods not static functions.

PS - not sure the meaning of the cryptic error message but I think this is your problem.

Rob

Known Participant
August 12, 2010

Thanks Rob! That cleared the error.

areohbee
Brainiac
August 12, 2010

You're welcome Jonathon,

And, here's my wild guess as to the meaning of the error message:

When you use a dot, the function is still being called, its just that the first argument is nil (the expected 'self' argument), and

- There are no symbols for it - thus the question mark instead of a name.

- The value is zero - thus the zero (nil == 0).

Summary: Not sure what an "upvalue" is, but it makes sense to me in this context that its referring to the missing 'self' argument.

Just a guess.

_R_