Community

SCI Programming => SCI Syntax Help => Topic started by: claudehuggins on February 08, 2017, 03:31:49 PM

Title: Very basic question about strings, I'm sorry in advance
Post by: claudehuggins on February 08, 2017, 03:31:49 PM
Time for what is possibly my dumbest question yet.

I'm using SCI1.1 Sierra script.

Let's say I have three strings set up, string 1 is "B", string 2 is "E", and string 3 is "N".
How do I make string 4 "BEN", referring to the other strings?
I thought it was obvious, but all my original attempts to get this syntax right (various types of addition etc) were incorrect.
Title: Re: Very basic question about strings, I'm sorry in advance
Post by: troflip on February 08, 2017, 03:41:42 PM
Being able to add strings to concatenate them is a trait of a more advanced runtime (helped by dynamic memory allocation and garbage collection). SCI is pretty primitive :P.

It's very much like in C, you create a buffer and copy/concatenate the strings into it. Then pass around an address to the buffer.

(local
    [buffer 40]
)

Code: [Select]
(procedure (SomeFunc)
(StrCpy @buffer {b})  ; The first one, you need to StrCpy instead of StrCat (or you can just StrCpy an empty string to it)
(StrCat @buffer {e})
(StrCat @buffer {n})
(Printf @buffer)
)