Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

removing character space from a btn lable to create an object with the name (without any spaces in the object name)
Started by angemccall Dec 29 2018 06:46 AM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

angemccall

[GLOBAL: userInfoPane.html]
angemccall
  • Observer

  • 3 posts
  • Corona SDK

Hi all.

I've a table array being sent to a function.
I want the function to turn the button lable as shown below into an object name.

    local btnLabels = {
        [1] = "Start Game",
        [2] = "Instructions",
        [3] = "Game Options",
        [4] = "Store",
        [5] = "About"
        }

 

then in my function...

 

        local createBtnName = "btn"..fontStyle.text

 

For items in [2], [4] and [5] this apends the lable with "btn" at the start. All is good.
But for items in [1] and [3] there are two words with a space. How do I remove this space?


eg I need something like...

 

        local createBtnName = "btn"..(removeSpace(fontStyle.text))

is there a function that does this already? whats its name?

 

I goal is that I want to end up with these object names:

 

btnStartGame

btnInstructions

btnGameOptions

btnStore

btnAbout

 

Thanks



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,780 posts
  • Corona SDK

https://stackoverflow.com/questions/10460126/how-to-remove-spaces-from-a-string-in-lua




[topic_controls]
[/topic_controls]