🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.borland
Article #177

Re: Assigning & concatenating strings

#177
From: Osmo Ronkanen
Date: Wed, 12 Jul 2000 00:00
43 lines
2324 bytes
In article <8khf2d$7g4$1@nnrp1.deja.com>,
Robert AH Prins  <prino@bigfoot.com> wrote:
>Hi all,
>
>How do you put a literal in a string?
>
>Uh, what's wrong with "myline:= 'This is an example';"
>
>Nothing, but now assume that you're doing this many times in a program,
>and look at the code generated to make this assignment, you'll see that
>it comes to 18 bytes, excluding the string itself.
>
>How do you concatenate a string with a literal?
>
>Uh, what's wrong with "myline:= myline + 'This is an example';"
>
>Nothing, but now assume that you're doing this many times in a program,
>and look at the code generated to make this assignment, you'll see that
>it comes to 39 bytes, excluding the string itself.
>
>Wouldn't it be nice if you could shorten this? Faced with 20 of such
>assignments, and 18 concatenations in a program, I came up with this,
>but be warned that it _does not contain any error checking_, in other
>words, you have to know what you are doing!

Why not just write two procedures:

Procedure AssignString(var st:string; st2:string);
Procedure ConcatStr(var st;string; st2:string);

The implementations are trivial. That is just 13 bytes per call. Now if
you want to use open strings, it is 16 bytes per call. Those are for
near calls, fars use more.

No need to write any ASM code as the procedure code is included only
once no matter how many times it is used.

>var myline: string; {must be global}

Do you realize what nightmare these "must be global" things cause. Also
even if one adds to a global variable one still can use Pascal.

Osmo
Technical Details
Message-ID: <8ki2oa$a64$1@kruuna.Helsinki.FI>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8khf2d$7g4$1@nnrp1.deja.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111659,429640dfcaaf13a8
X-Google-Attributes: gid111659,public
X-Google-Thread: 108ebd,429640dfcaaf13a8
X-Google-Attributes: gid108ebd,public
From: ronkanen@cc.helsinki.fi (Osmo Ronkanen)
Subject: Re: Assigning & concatenating strings
Date: 2000/07/12
Message-ID: <8ki2oa$a64$1@kruuna.Helsinki.FI>
X-Deja-AN: 645512493
References: <8khf2d$7g4$1@nnrp1.deja.com>
X-Complaints-To: usenet@news.helsinki.fi
X-Trace: oravannahka.helsinki.fi 963415627 18284 128.214.205.14 (12 Jul 2000 15:27:07 GMT)
Organization: University of Helsinki
NNTP-Posting-Date: 12 Jul 2000 15:27:07 GMT
Newsgroups: comp.lang.pascal.borland,borland.public.turbopascal