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.

Email synax: messeage depending on the value of a group value
#1
Sending emails with my W4K is working. Once a day, I'd like to send an email. The message should depend on the vealue of the group values. This message should be list, of all values, which are below a certain limit - in this case 85. I tried the following code - synax error. Any idea? 

Code:
for i = 0, 30, 1 do
  SP = grp.getvalue('35/1/' ..i)
  if (SP < 85) then
    message = 'Alert: ' '35/1/' ..i '<br>'

end
end
Reply
#2
(17.04.2024, 21:36)cgn Wrote: Sending emails with my W4K is working. Once a day, I'd like to send an email. The message should depend on the vealue of the group values. This message should be list, of all values, which are below a certain limit - in this case 85. I tried the following code - synax error. Any idea? 

Code:
for i = 0, 30, 1 do
  SP = grp.getvalue('35/1/' ..i)
  if (SP < 85) then
    message = 'Alert: ' '35/1/' ..i '<br>'

end
end

...missing string concat after Alert: string...

Code:
for i = 0, 30, 1 do
  SP = grp.getvalue('35/1/' .. i)
  if (SP < 85) then
    message = 'Alert: ' .. '35/1/' .. i '<br>'
  end
end
Reply
#3
'35/1/' ..i '<br>' Must be '35/1/' .. i .. '<br>'
Reply
#4
Corrected version that will alert all objects that are below the threshold instead of only one:
Code:
message = ''

for i = 0, 30 do
  addr = '35/1/' .. i
  value = grp.getvalue(addr)
  
  if value < 85 then
    message = message .. 'Alert: ' .. addr .. ' = ' .. value .. '<br>\n'
  end
end

if message == '' then
  message = 'OK'
end
Reply


Forum Jump: