Jump to content


Photo

Concatenate String


  • Please log in to reply
4 replies to this topic

#1 SoloJoe

SoloJoe

    GMC Member

  • GMC Member
  • 18 posts

Posted 02 March 2007 - 10:47 PM

I want to create a string that starts with "wall_", and I want to add the value of a global variable to it.

I have tried several variations similar to the below example:



str = 'wall_' + global.wall



Essentially, if global.wall = 3 I would like my string to be "wall_3"

Any help would be appreciated. Thanks.
  • 0

#2 SoloJoe

SoloJoe

    GMC Member

  • GMC Member
  • 18 posts

Posted 02 March 2007 - 11:09 PM

Hey,

I figured it out on my own, so I thought I'd share just in case it would be useful to anyone else.


num = string(global.wall);
str = 'wall_' + num;
  • 0

#3 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5586 posts
  • Version:GM:Studio

Posted 02 March 2007 - 11:10 PM

need to turn the real number into a string.. that's all
str = 'wall_' + string(global.wall)

EDIT: oh solved allready ^^ ok

Edited by FoxInABox, 02 March 2007 - 11:11 PM.

  • 0

#4 joko1999

joko1999

    GMC Member

  • New Member
  • 2 posts
  • Version:Unknown

Posted 04 April 2013 - 06:37 PM

can i add 2 strings linesin 1 message ???


  • 0

#5 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Retired Staff
  • 15413 posts
  • Version:GM:Studio

Posted 04 April 2013 - 08:51 PM

s1 = "Hello ";

s2 = "World";

 

s3 = s1+s2;

 

or s3 = "Hello " + "World";

 

or

s3 = ""

s3+=s1;

s3+=s2;


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users