Hello, I am new an have a simple question:
what is the command that the same as
wert = wert + wert1 in other programming languages:
sample: the string wert has the value "a", wert1 has the value "b", wert is now "ab"
next step
wert = wert + wert1, wert now "abb" and so on
connect text strings
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: connect text strings
Hi - and welcome to LC.Walther wrote: ↑Thu Mar 07, 2024 11:58 amHello, I am new an have a simple question:
what is the command that the same as
wert = wert + wert1 in other programming languages:
sample: the string wert has the value "a", wert1 has the value "b", wert is now "ab"
next step
wert = wert + wert1, wert now "abb" and so on
The concatenation operator equivalent in LC is "&"
Note that "&&" introduces a space between concatenated items, so if a space is needed it does not need to be added to the variable or separately.
Other operators that concatenate : before, after
Typically the verb used is "put into|before|after" instead of the assignment operator "=".
For your example:
Code: Select all
put a into wert ; put b into wert1
put wert & wert1 into wert // wert now contains "ab"
put wert & wert1 into wert // wert now contains "abb"
// or alternatively for same result
put wert1 after wert
-
- VIP Livecode Opensource Backer
- Posts: 9752
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: connect text strings
Walther.
What Stam said.
The "&" operator becomes invaluable in certain situations. For example, if you want to create the string "a", and by that I mean that the quotes are part of that string, one can:
Since "quote" is a constant in LC, the only way to make such a string is by using the "&" operator. You can see how the previous few lines of my text uses quotes to identify and isolate strings. This is different than having quotes embedded in those strings.
Craig
What Stam said.
The "&" operator becomes invaluable in certain situations. For example, if you want to create the string "a", and by that I mean that the quotes are part of that string, one can:
Code: Select all
on mouseUp
put "a" into wert
answer wert --just one character
put quote & "a" & quote into wert
answer wert --includes the appended and prepended quote characters
end mouseUp
Craig
Re: connect text strings
Tank you very much. It works.
Walther
Walther
Re: connect text strings
Hi Walther,
welcome to the forum!
Sounds like you are german, there is also a german LC forum here:
https://www.livecode-blog.de/forums/for ... ode-forum/
Best
Klaus
welcome to the forum!
Sounds like you are german, there is also a german LC forum here:
https://www.livecode-blog.de/forums/for ... ode-forum/
Best
Klaus