0

I am using scratch.mit.edu version 2.0 on the internet and writing a program to evaluate a postfix expression. As I iterate through the input string such as: "23+" (postfix) letter by letter using the letter..of...block, it works fine.

I then add a letter.. of.. block to identify a spacebar character so the user can insert blanks in the expression eg "2 3 +"

However, there seems no way to recognize a blank character. I tried

1) Lookahead = ""
2) Lookahead =' '  
3) Lookahead ='' 

None of which pick up that a space has been encountered.

Here is the project: https://scratch.mit.edu/projects/77653712/

Scimonster
  • 32,893
  • 9
  • 77
  • 89
Timothy Lawman
  • 2,194
  • 6
  • 24
  • 33

2 Answers2

5

In Scratch, the box is the string literal - no quotes, unless you're looking for literal quotes. Just put a space in the box.

Just set it to check <(Lookahead) = [ ]>: (brackets are the symbol for the box)

screenshot of script

(That black line is me pressing ctrl+a to highlight and show that it exists.)

Scimonster
  • 32,893
  • 9
  • 77
  • 89
1

OK, I have found the solution. There is no character to represent a blank. You simply press space bar once!

enter image description here

You can see the letter nextChar of blanks is an empty space but, you must add space using the spacebar for it to work!!

Timothy Lawman
  • 2,194
  • 6
  • 24
  • 33