This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-02-01 03:54:23

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

String manipulation

I keep finding myself running into the wall that is the lack of string manipulation in Scratch, as I'm sure many others have. To the powers that be: Could you, at the very least, make the [(  ) + (  )] block concatenate two strings? (Or am I totally missing something here? What do the rest of you do with your strings?)

Thanks!

Offline

 

#2 2009-02-01 09:56:47

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: String manipulation

mrweston wrote:

What do the rest of you do with your strings?

We sit around and wish there were string functions! 

Actually, you can do a crude concatenation by using Lists.  Make list items with all the parts you want concatenated, then you can reference the entire array with the array name and your items will be concatenated - only there will be a space between them (bummer).

Add "Cat" to A_List
Add "Dog" to A_List
Set A_Variable to A_List

will give the variable A_Variable a value of "Cat Dog"

I think Chalkmarrow actually figured out a way to tear "space concatenated" strings apart using string comparison...only I'm not sure it worked online.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2009-02-01 12:57:20

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: String manipulation

I really do wish there was string concatenation. There is in every programming language... but Scratch. C'mon!! You can concatenate strings via the list function (and that's how I do typing), but that space gets SO annoying. Please, concatenation?

(PS: it's hard to type the word concatenation)

Offline

 

#4 2009-02-01 13:37:28

ScratchScripter
Scratcher
Registered: 2008-08-21
Posts: 73

Re: String manipulation

If you do it with lists, there's always a space between the both texts...

Offline

 

#5 2009-02-01 14:17:00

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: String manipulation

Yeah, the space can be a deal-breaker, alas. I'm wondering why they chose to insert it in the first place, when assigning an array to a string -- are there cases in which that's really useful? Indicates that it would be an extremely trivial programming tweak to get true concat: just don't append the spaces.

Does anyone from the programming team visit the forums? Or are all these discussions passed on to them by other team members?

Offline

 

#6 2009-02-01 18:58:31

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: String manipulation

mrweston wrote:

Yeah, the space can be a deal-breaker, alas. I'm wondering why they chose to insert it in the first place, when assigning an array to a string -- are there cases in which that's really useful? Indicates that it would be an extremely trivial programming tweak to get true concat: just don't append the spaces.

Does anyone from the programming team visit the forums? Or are all these discussions passed on to them by other team members?

The space is handy if all you are trying to do is make a printer-friendly method to dump the contents of a list.    I think that was the original intent of the space; so that the list could be placed in a Say block.  And it works well for that purpose.

As for whether anybody from the programming team visits the forums...I know Jens does from time to time and he is on the programming team.    I have been forwarding Scratch and Java Player bugs to the Known Bug List but I have not been forwarding all the Forum discussions.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#7 2009-02-05 07:09:43

Mike_W
Scratcher
Registered: 2009-02-05
Posts: 100+

Re: String manipulation

And something to split a string

Even just the mid function, and string length should allow us to do everything a

left right would, instring would be nice but we could code that if BYOB becomes part of 1.4

Offline

 

Board footer