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

#1 2009-03-09 17:56:50

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

String comparison

How can I check to see if a specific member of a string list is equal to a specific string?

If < [item 1 of MyList] = "BoltBait" >
...
else
...


The equals operator doesn't seem to take strings.  sad


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#2 2009-03-09 18:38:10

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

Re: String comparison

Alas, there's currently no support for string comparison or manipulation. Hopefully coming soon, but not sure if our Scratch overlords are even working on this or not.

Offline

 

#3 2009-03-09 18:40:28

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: String comparison

OK, thanks.

Switching my list to number codes instead of a list of strings. *sigh*

/me thinks... No wonder all the hangman games on this site are lame.  smile

Last edited by BoltBait (2009-03-09 18:41:01)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#4 2009-03-11 18:22:20

ManaUser
Scratcher
Registered: 2009-03-11
Posts: 100+

Re: String comparison

That's not quite true. You can do this:

Set (Temp) to BoltBait
If <(item (1) of MyList) = (Temp)>
...

A little sloppy but it works.


http://i.imgur.com/SPYSM.gif http://i.imgur.com/t9k1Z.gif http://i.imgur.com/OwYVa.gif http://i.imgur.com/0qlZq.gif

Offline

 

#5 2009-03-11 18:35:09

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: String comparison

Thanks, ManaUser.  I just verified that it works as you show.

That's good to know.

Of course, there isn't much you can do with strings in Scratch, so I don't know what good it will do...  big_smile


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#6 2009-03-11 22:17:05

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

Re: String comparison

Yeah, it's kind of strange that the boolean comparison works when checking against a variable containing a string, but not a string on its own. Could come in handy, I'm sure.

Offline

 

Board footer