Author Topic: Very basic question about strings, I'm sorry in advance  (Read 57 times)

0 Members and 1 Guest are viewing this topic.

Offline claudehuggins

Very basic question about strings, I'm sorry in advance
« 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.


A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Offline troflip

Re: Very basic question about strings, I'm sorry in advance
« Reply #1 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)
)
« Last Edit: February 08, 2017, 04:17:45 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition


SMF 2.0.11 | SMF © 2015, Simple Machines
Simple Audio Video Embedder

Page created in 0.197 seconds with 21 queries.