BUILD$ function

Purpose

Build or concatenate strings with very high efficiency.

Syntax

x$ = BUILD$(a$,b$,c$,d$...)

Remarks

In some cases, string concatenation using the classic string operators can be a slow process.  This is particularly true when there are many operands using longer strings.  The BUILD$ function passes all the typical bottlenecks to create a new string at the greatest possible speed.  The following 2 lines are functionally identical, but the BUILD$ version will execute substantially faster.

x$ = a$ + "bb" + c$ + y$(7) + y$(i&) + z$

x$ = BUILD$(a$, "bb", c$, y$(7), y$(i&), z$)

It's interesting to note that this string function could have been named APPEND$ or PREPEND$ because it performs these functionalities so well.  For example, to prepend a topic number to text$ while also adding a period at the end, you could execute:

text$ = BUILD$( "1) " & text$ & ".")

In order to extract the utmost efficiency, BUILD$() was designed to work with a very narrow definition.  The component parameters must be dynamic string variables, either scalar or array, string literals, or string equates.  They may not be expressions.  There is virtually no limit as to the number of parameters.

The BUILD$() function is most valuable when you are concatenating numerous strings all at the same time.  However, when you must add many string sections, in many separate operations, the StringBuilder object is much faster, and a more appropriate choice.

Generally speaking, the greater the number of parameters, the greater the increase in execution speed.

See also

LET, CHR$, CSET, CSET$, JOIN$, LSET, LSET$, REPEAT$, RSET, RSET$, STRING$, STRINGBUILDER, STRINSERT$, WRAP$