Appending text to a string

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Post Reply
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Appending text to a string

Post by Susan Smith »

Hi all,

Can someone point me to the spot in the wiki where it discusses appending text to the END of a string? I think that this is new with either 4.18 or 4.2, and I THOUGHT I saw it in the wiki at one point, but no search seems to take me there (I tried "assignment statements" and "LET", but that didn't help.)

I thought it was something like LET A$(X:0)="MORE STUFF". The 'zero" seemed significant, but I can't figure out the proper syntax. I see that let A$(0:0) will "pre-pend" the text to the beginning of the string, moving everything else over.

-- Susan
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

To add to the end of a string simply
LET a$(inf:inf)="Stuff to append"

just like

LET a$(0:0)="Stuff to prepend"

FNGeorge
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

Thank you George, I would have never guessed about the "INF"

-- Susan
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

and if you look up the work "append" or "prepend" on the br wiki - you'll find the article.
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

interestingly enough I did a few speed test with the different methods over 99,000,000 cycles and the method:

x$(inf:0)='text to append'
and
x$(32767:0)='text to append'

we're exactly the same speed (2 minutes,4 seconds).

while
x$(inf:inf)='text to append'
was only slightly slower (2 min,7 seconds)

They're all good. Luis says that (32767:0) is more backwards compatible with older versions of BR!/WB.

I added the inf methods to the Append page on the wiki for future reference.

-John B.
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

Thanks for adding this to the wiki John. But we might want to put a link to it on the "assignment" page. At the time I was searching, I didn't think of the terms PREPEND or APPEND. Perhaps some others wouldn't either. I was thinking that the LET statement (which has it's own page) was the most logical place for a reference to the append/prepend page.
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

I added a "See also: [[Append]]" to the "Let" page... "Assignment" currently isn't a page, but it should probably be a redirect to somewhere... you think to "Assignment Statements"? And do you think that that the "Append" page should be a member of the "category:Assignment Statements"? Currently I have only actual statements as members of that category and "Append" isn't a statement, it's currently a member of the categories "Basics" and "Terminology".

-John
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

Oh, I'm sorry! I must have missed the "see also" on the LET page. It's great. That's exactly what I meant. No need to do anything further. Thanks John. Perfect.

-- Susan
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

:D hehehe - I just added it... Actually I just made the whole "Let" article *much* longer by combining two seperate "Let" articles.
Post Reply