problem with words, sentences library?

I have a project that counts vowels and consonants in a phrase. It uses the words, sentences library. (See attached screen shots.) The error message complains that I’m trying to report first of an empty word, but I don’t see how that’s true. What am I missing? Or, is there a bug in the words, sentences library?

Thanks

-Michael

I cant seem to find the ([] contains? [] ::operators) block

Could you share the project please? Tnx.

Could you give us a project link?

the project is shared:

Here’s the problem:


Three problems:

  1. The big one: no base case. That’s why you’re getting the error message.
  2. Unlike Logo, Snap! doesn’t use the text strings “true” and “false” as Booleans; it has a distinguished Boolean type.
  3. A typo: ALL BUT LAST should be ALL BUT FIRST.

Corrected version:

On top of that, the block should be a predicate (pointy) shape. That doesn’t change the behavior, but it signifies that it returns a boolean.

A better category for this topic would be Help with Snap! > Snap! Editor

The base case is is the first line of the ANALYZE block. If the input is an empty word, it should STOP ALL. Why doesn’t this work?

In trying to find the source of the error I found that if I isolate the EXAMINE block from the rest of the program and run it with the character “a” as input it does not generate an error. CHARACTER-COUNT and CHARACTER-COUNT are both incremented. But with any other character as input, the error is generated. I don’t understand.

Thanks.

The base case has to be in the contains block because that’s being called recursively, and the base case in the analyze block will never be reached inside the contains block.

Here’s the working version of the project: Snap! Build Your Own Blocks

My confusion was that I regarded the blocks from the words, sentences library as primitives, so I didn’t try to edit them even though I suspected there was a problem in one of those blocks.

So the CONTAINS block was faulty, with pretty obvious errors, as BH pointed out. So now I have another question: If I open a new project and load the words, sentences library, the CONTAIN block is no longer there. What happened? (The fixed version of CONTAIN was saved in the CHARACTERS4 project)

Thanks

I don’t think you found the CONTAINS block in the word/sentence library. I’m not sure where you did find it. There’s a untitled script pic (10) block in the “Strings, multi-line input” library, but its code is very different from the one in your project. (It has “TEXT” in its name to distinguish it from the primitive untitled script pic (11) block.)

Now I’m not sure where I got the defective CONTAINS block. It’s possible that I created it, but I don’t recall doing so. The error of using the word “true” instead of the true/false block is something I might have done since I have a Logo head. But leaving out the empty word base case is not a mistake I would be likely to make, for the same Logo head reason. It remains a mystery, but now it’s fixed. Thanks for your help.