Copy link to clipboard
Copied
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)
1 Correct answer
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks Rob! That cleared the error.
Copy link to clipboard
Copied
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_

