This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

While Loop for reading values
#11
In this example each fault object has the next middle group (shift = 256, 1/1/123 => 1/2/123). Change as needed, shift can be negative.
Code:
function tag_max(tag, shift)
  local objects = grp.tag(tag)
  local result = -math.huge

  for _, object in ipairs(objects) do
    local fault = grp.getvalue(object.id + shift)
    if not fault then
      result = math.max(result, object.value)
    end
  end

  return result
end

max = tag_max('my_tag_name', 256)
log(max)
Reply


Messages In This Thread
While Loop for reading values - by tomnord - 06.01.2021, 09:10
RE: While Loop for reading values - by admin - 06.01.2021, 13:12
While Loop for reading values - by tomnord - 06.01.2021, 13:27
RE: While Loop for reading values - by admin - 06.01.2021, 13:33
RE: While Loop for reading values - by Daniel - 19.01.2021, 13:07
RE: While Loop for reading values - by admin - 19.01.2021, 13:30
RE: While Loop for reading values - by admin - 19.01.2021, 14:43

Forum Jump: