Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:49:48+00:00 2026-06-13T03:49:48+00:00

Basically, I have several devices I need to pull data from. I get multiple

  • 0

Basically, I have several devices I need to pull data from. I get multiple emails when the temperature measures are under or over the set limits. I would like to have a for loop to include all current devices states that are under or over limits into one email.

body = for device_name, 1 do 
  device_name++ -- I get error here because unexpected symbol near 'for'
  "Device Name: " ..device_name.. "\nDevice Location: " ..device_location.. 
  "\n--------------------------------------------------------------" .. 
  "\nCurrent Temperature: " ..temperature.." F".. "\nTemperature Limit: ("..
  t_under_limit.. "-" ..t_over_limit.. " F)" .."\n\nCurrent Humidity Level: " .. 
  humidity .. "%".. "\nHumidity Limit: (" .. h_under_limit.. "-" ..h_over_limit.. "%)" 
  .. "\n\n-------Time Recorded at: " ..os.date().. "-------"})
end, -- end for
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:49:49+00:00Added an answer on June 13, 2026 at 3:49 am

    As previously noted, there is no ++ operator in Lua. Also, the syntax for the for loop is different from what you wrote.

    I would like to add that the big concatenation afterwards would be much more readable using string.format. Here is an enhanced version of your code, in the form a a function taking a table devices parameters in input, each element being a subtable:

    local report_model = [[
    Device Name: %s
    Device Location: %s
    --------------------------------------------------------------
    Current Temperature: %d °F
    Temperature Limit: (%d-%d °F)
    Current Humidity Level: %d %%
    Humidity Limit: (%d-%d %%)
    
    -------Time Recorded at: %s-------]]
    
    function temp_report(devices)
      local report = {}
      for i=1,#devices do 
        local d = devices[i]
        report[i] = report_model:format(d.name, d.location,
          d.temperature, d.t_under_limit, d.t_over_limit,
          d.humidity, d.h_under_limit, d.h_over_limit,
          os.date())
       end
       return table.concat(report)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several laptops in the field that need to daily get information from
I have several methods that I need to wrap in new methods in basically
I have several question about MSISDNs. I understand: MSISDN is the basically the phone
I have several Code Analysis CA1704:IdentifiersShouldBeSpelledCorrectly warnings that I want to suppress. Basically, they
Basically I have a TableLayout with several TableRows, each containg 5 cells (Name, Price,
I have a .NET application available in several different language. i basically load and
Basically, if I have a method (or several methods) that I want to expose
I basically have a program that filters records from one excel file to another
Basically I have several divs, each contains a question. This question could be presented
I have several classes that are basically interfaces to database rows. Since the class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.