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

#1 2008-03-03 00:27:02

jblumen
Scratcher
Registered: 2008-03-03
Posts: 1

Reading user input

Does scratch have the ability to prompt a user and then read user input?

I'm looking for the scratch equivalent of this in perl:

# greeting - read the user name and
# echo it back in a greeting!
# input
print "please enter your name: ";
$users_name = <STDIN> ;
# output
print "This is a program to greet ";
print $users_name;
print "on this course\n";

Offline

 

#2 2008-03-03 00:30:57

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Reading user input

Unfortunately, you can't prompt a user to enter in words like in your example code.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-03-03 01:50:55

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Reading user input

You can, however, get individual letters but it is very fiddly.

You need a sprite with 26 costumes (letters), key-press detection and unless they are being typed directly onto the screen, you need an ordered way of storing the key-presses to replay back later.

It can be done, but (unlike other programming languages) it isn't a "simple starter project".

For a simple starter project around a name, the students would be better off making sprites of the letters of their name and then animating them/applying special effects.  Check out the examples that come with Scratch.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2008-03-03 05:43:25

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

Re: Reading user input

Scratch has no character string data class at this point.  Chalkmarrow has implemented short character strings in numbers though, check out this project

http://scratch.mit.edu/projects/chalkmarrow/97399


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

Offline

 

Board footer