StrCat
Jump to navigation
Jump to search
Function:
result:StringID StrCat first:StringID second:StringID
Example:
long foostring long barstring long foobarstring set foostring to StrNew "Hello" set barstring to StrNew "World" set foobarstring to StrCat foostring barstring strprint foobarstring ; this prints "HelloWorld"
Sets the contents of the first string to the second two catenated together.
StrCat creates a brand new string and passes the new StringID, which means you shouldn't reuse the same longs for the input and output, as it would leave the input string with no reference to it.
Note about memory use[edit | edit source]
Don't do this:
long str1 long str2 set str1 to "A string " set str2 to "is lost" set str2 to StrCat str1 str2
If you do this, the string "is lost" will be unaccessible, but remains in the memory for a looong time.
Do this instead:
long str1 long str2 long str3 set str1 to "No string " set str2 to "is lost" set str3 to StrCat str1 str2 StrDel str2 ; now you can reuse str2 without problems