Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

concatenation object to array corona
Started by vanderlei_quintino Mar 26 2020 03:25 PM

4 replies to this topic
concatenation object to array

Best Answer vanderlei_quintino , 27 March 2020 - 11:10 AM

Ohhhhh! 

Wonderful, this program really surprises me.

 

Sory this is my question! in for loop. I need to replace the number in the tn_1.text object. Not in newobejct.

your help was very good. My problem is this below. I would like to exchange the direct value on the object below. Is it possible. Color red question and return color green.

 

for b = 1, 68 do

   
"tn_"..b..".text="..ta[j]  --   i need to return this -->> tn_19.text = ta[j]  
 
b = b + 1
 
end

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

vanderlei_quintino

[GLOBAL: userInfoPane.html]
vanderlei_quintino
  • Observer

  • 4 posts
  • Corona SDK

Hi,I need concatenation object to array corona

 

 

tn is  a OBJCT text

 

i need to creat 68 return object same:

 

 

--[[
tn_1.text =  ta[1]
tn_2.text =  ta[2]
tn_3.text =  ta[3]
tn_4.text =  ta[4]
tn_5.text =  ta[5]
tn_6.text =  ta[6]
tn_7.text =  ta[7]
tn_8.text =  ta[8]
tn_9.text =  ta[9]
tn_10.text =  ta[10]
tn_11.text =  ta[11]
tn_12.text =  ta[12]
tn_13.text =  ta[13]
tn_14.text =  ta[14]
tn_15.text =  ta[15]
tn_16.text =  ta[16]
tn_17.text =  ta[17]
tn_18.text =  ta[18]
tn_19.text =  ta[19]

--]]

 

 

 

ITS PART OF MY PROGRAM

 

local tn_19 = display.newText( options_tn_19)
tn_19:setFillColor( 0, 0, 0, 1 )
tn_19:rotate( 49 )
tn_19.anchorY = 0
-- Align object to top alignment axis
tn_19.y = tn_18.y 
 
 
ta[j] =  row.nome_tn
 
 
My program loop for don't work propert. erro send exemple color red i need return  color green object.
 
for b = 1, 68 do
   
"tn_"..b..".text="..ta[j]  --   i need to return this -->> tn_19.text = ta[j]  etc... this don't work
 
b = b + 1
 
end
 
 
HOW TO CONCATENATION ON NAME OF OBJECT AND INSERT VARIAVEL INTO IT. AND RETURN
"tn_"..b..".test=  and return   any object  tn_1.txt = ta[j].   any laguage is possible, in Lua it is possible?
Tanks!
 
 
 
 
 
HELP!

Attached Files

  • Attached File  err.png   35.6KB   0 downloads


[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,666 posts
  • Corona SDK

Question:  Is there a reason you want these local variables... tn_1, tn_2, etc?

 

I'm not clear why you don't just keep a table of object references instead.

 

Whatever the case, you can't create local variables on the fly as the result of string catenation.

 

 

Also, I know it is a bit of work, but it would help us a lot if you could give us a piece of code (or better yet a tiny downloadable project with just a small amount of code in it) that shows us what you're trying to do.

 

I know you posted some snippets, but seeing the code in context would help a lot.

 

This code (please use code formatting in future posts):

local tn_19 = display.newText( options_tn_19)
tn_19:setFillColor( 0, 0, 0, 1 )
tn_19:rotate( 49 )
tn_19.anchorY = 0
-- Align object to top alignment axis
tn_19.y = tn_18.y 

could be expressed like this instead:

local tn = {}
local options_tn = {}

then later...


tn[19] = display.newText( options_tn[19] )
tn[19]:setFillColor( 0, 0, 0, 1 )
tn[19]:rotate( 49 )
tn[19].anchorY = 0
tn[19].y = tn[18].y 

  • vanderlei_quintino likes this

[TOPIC: post.html]
#3

vanderlei_quintino

[GLOBAL: userInfoPane.html]
vanderlei_quintino
  • Observer

  • 4 posts
  • Corona SDK

  Best Answer

Ohhhhh! 

Wonderful, this program really surprises me.

 

Sory this is my question! in for loop. I need to replace the number in the tn_1.text object. Not in newobejct.

your help was very good. My problem is this below. I would like to exchange the direct value on the object below. Is it possible. Color red question and return color green.

 

for b = 1, 68 do

   
"tn_"..b..".text="..ta[j]  --   i need to return this -->> tn_19.text = ta[j]  
 
b = b + 1
 
end


[TOPIC: post.html]
#4

vanderlei_quintino

[GLOBAL: userInfoPane.html]
vanderlei_quintino
  • Observer

  • 4 posts
  • Corona SDK

Ohhhhh! 

Wonderful, this program really surprises me.

 

Sory this is my question! in for loop. I need to replace the number in the tn_1.text object. Not in newobejct.

your help was very good. My problem is this below. I would like to exchange the direct value on the object below. Is it possible. Color red question and return color green.

 

for b = 1, 68 do

   
"tn_"..b..".text="..ta[j]  --   i need to return this -->> tn_19.text = ta[j]  
 
b = b + 1
 
end


[TOPIC: post.html]
#5

vanderlei_quintino

[GLOBAL: userInfoPane.html]
vanderlei_quintino
  • Observer

  • 4 posts
  • Corona SDK

How do I add options in an array. In your example, the newText options tn[19] = display.newText( options_tn[19] ) are in an array options_tn[19]. but I couldn't put it on.

 

tn[19] = display.newText( options_tn[19] )

How do I put this in an array

options_tn_68 = { text = "", x = tn_67.x -5, width =125, font = native.systemFont, fontSize = 7, align = "center", -- Alignment parameter }

 

 

Tanks!

 

tn[19]:setFillColor( 0, 0, 0, 1 )
tn[19]:rotate( 49 )
tn[19].anchorY = 0
tn[19].y = tn[18].y 

How do I add options in an array. In your example, the newtext options are in an array. but I couldn't put it on. Tanks




[topic_controls]
[/topic_controls]