Skip to content

unexpected loop behavior when using for #185

@disgustipated

Description

@disgustipated

perhaps this is my lack of knowledge of lua, but im having trouble getting reliable output as im working on a script with the end goal of applying tags to files.
i have the following script outputting to log while im getting familiar

function applyTags(nodes, tags)
  log(" incoming tag ")
  log(json(tags))
  for i, node in ipairs(nodes) do
  	if( is_file(node) )then
      log("node is a file " .. i)
      log(json(node))
      --for t, workingtag in ipairs(tags) do
      --  log(json(workingtag[t]))
      --end
    elseif( is_folder(node) )then
      --loop through list var and apply tag to each file directory_listing(node)
    end
  end
end

applyTags(get_input_files(), get_input('PrintSize'))

that produces the log output like this, but doesnt list the second file
image

and this

function applyTags(nodes, tags)
  log(" incoming tag ")
  log(json(tags))
  for i, node in ipairs(nodes) do
    log("before file check " .. i .. " " .. node.name)
  	if( is_file(node) )then
      log("node is a file " .. i .. " " .. node.name)
    elseif( is_folder(node) )then
      --loop through list var and apply tag to each file directory_listing(node)
    end
  end
end

applyTags(get_input_files(), get_input('PrintSize'))

produces the log output "before file check" but seems the is_file doesnt happen and the "node is file" log doesnt get output.
im not sure if im troubleshooting log output or my lack of knowledge of lua and could use some help understanding whats going on

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions