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 9143509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:02:33+00:00 2026-06-17T10:02:33+00:00

I am trying to concatenate all the values and append them to the same

  • 0

I am trying to concatenate all the values and append them to the same variable, then write the content of the string. I keep getting the error: “attempt to concatenate global ‘arglist’ (a nil value)”

  eo_device = {}

  eo_device[1] = {node = "ME", t_object = "AV1", h_object = "AV2" }
  eo_device[2] = {node = "ME", t_object = "AV3", h_object = "AV4" }
  eo_device[3] = {node = "ME", t_object = "AV5", h_object = "AV6" }
  eo_device[4] = {node = "ME", t_object = "AV7", h_object = "AV8" }
  eo_device[5] = {node = "ME", t_object = "AV9", h_object = "AV10" }
  eo_device[6] = {node = "ME", t_object = "AV11", h_object = "AV12" }
  eo_device[7] = {node = "ME", t_object = "AV13", h_object = "AV14" }
  eo_device[8] = {node = "ME", t_object = "AV15", h_object = "AV16" }
  eo_device[9] = {node = "ME", t_object = "AV17", h_object = "AV18" }
  eo_device[10] = {node = "ME", t_object = "AV19", h_object = "AV20" }
  eo_device[11] = {node = "ME", t_object = "AV21", h_object = "AV22" }
  eo_device[12] = {node = "ME", t_object = "AV23", h_object = "AV24" }
  eo_device[13] = {node = "ME", t_object = "AV25", h_object = "AV26" }
  eo_device[14] = {node = "ME", t_object = "AV27", h_object = "AV28" }
  eo_device[15] = {node = "ME", t_object = "AV29", h_object = "AV30" }


-- Generate string with all arguments to be written to CSV
for deviceindex = 1,#eo_device do

 device_name = scl.nodes[eo_device[deviceindex].node][eo_device[deviceindex].t_object .. "_Object_Name"].value -- point to Object Names
 description = scl.nodes[eo_device[deviceindex].node][eo_device[deviceindex].t_object .. "_Description"].value -- point to Description of all objects     
 temperature = scl.nodes[eo_device[deviceindex].node][eo_device[deviceindex].t_object .. "_Present_Value"].value -- value of temperature object
 humidity = scl.nodes[eo_device[deviceindex].node][eo_device[deviceindex].h_object .. "_Present_Value"].value -- value of humidity object


 buflist = device_name .. "," .. description .. "," .. temperature .. "," .. humidity 

 arglist = arglist .. "," .. buflist  

 end -- end for

--then once outside of the loop:
arglist = arglist .. "," .. buflist 

buffer = os.date() .. arglist .. "\r\n"

file, info = io.open("trend.csv", "a+") -- write to CSV
if file then
file:write(buffer)
file:close()
end -- end if
  • 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-17T10:02:34+00:00Added an answer on June 17, 2026 at 10:02 am

    I keep getting the error: “attempt to concatenate global ‘arglist’ (a nil value)”

    Because you’re attempting to concatenate arglist (a nil value) on line 31 of your code:

    arglist = arglist .. "," .. buflist  
    

    arglist is never initialized, so when you attempt that concatenation on the right hand of the =, you get that error.


    Side note about this loop:

    for deviceindex = 1,#eo_device do
    
        description = scl.nodes[eo_device[deviceindex].node][eo_device[deviceindex].t_object .. "_Description"].value
    

    Lua has an ‘generic’ for loop which will allow you to iterate over all the elements of eo_device, giving you the indices and values, so you don’t have to index inside your loop. This will clean your code up a bit:

    for deviceindex, device in ipairs(eo_device) do
    
        description = scl.nodes[device.node][device.t_object .. "_Description"].value
    

    Side note about this code:

    buflist = device_name .. "," .. description .. "," .. temperature .. "," .. humidity 
    

    Building strings like this is incredibly inefficient. Doing this in a loop will result in thousands of string concatenations and generate tons of garbage. A better approach is to add all the string parts to a table, then join them into a single, comma-delimited string via table.concat.

    For example, to create a comma-delimited string containing all the strings in your eo_device table:

    local buffer = {}
    
    for i,device in ipairs(eo_device) do
        table.insert(buffer, device.node)
        table.insert(buffer, device.t_object)
        table.insert(buffer, device.h_object)
    end
    
    devices = table.concat(buffer, ',')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to concatenate the values from a column from all levels of a
I'm trying to return all possible permutations of values in a String array. I've
I'm trying to concatenate two properties into one string like so: public class thing
I am trying to concatenate image url (string) with img tag but i am
I'm getting a TypeError: cannot concatenate 'str' and 'list' objects. I'm trying to pass
I am trying to write a app.config / web.config error correcting app which will
I have 14 dictionaries all containing the same keys of information, but varying values.
I'm trying to search the SRC of a set of images then return all
I'm trying to search the SRC of a set of images then return all
I am trying to concatenate two date columns, putting a - between the values.

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.