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

#1 2012-12-27 17:30:45

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

I don't know what's wrong

I'm not sure if this should be in help with scripts or bugs and glitches as I'm not sure if it's a problem with scratch or with my code. If it's misplaced, please report it to be moved.
I'm working on implementing a programming language in scratch. I decided to write some debugging scripts to help me test weather what I've got so far is working. However, It won't work. I traced the problem to this script:


when I receive [ready v]

forever  

delete (all v) of [command v]

ask [Next command] and wait

set [word v] to []

set [index v] to [0]

repeat (length of (answer))  

change [index v] by (1)

if <(letter (index) of (answer)) = [ ]> // that's a space by the way

add (word) to [command v]

set [word v] to []

else

set [word v] to (join (word) (letter (index) of (answer)))

end

end

add (word) to [command v]

broadcast (join [TEST do command ] (item (1 v) of [command v] )) and wait

end

I typed in "say 3", which is supposed to, er, say the number 3. However, It appears to ignore the command and continue. (it appears to ignore ALL commands and continue) I tried it in single stepping mode, and found the broadcast block isn't running the join block. The script that had the hat block
 when I receive [TEST do command say v]
didn't flash white. I have no idea what it DID broadcast. It is times like this when I wish scratch had a (most recent broadcast) block. Are you meant to put reporters in the broadcast block? If you are, scratch should evaluate it properly. If you're not, scratch should not make it possible.

Can someone tell me what's wrong???

Last edited by joefarebrother (2012-12-27 17:36:12)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#2 2012-12-27 18:06:15

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: I don't know what's wrong

Well I just tested using a join block in a broadcast, and it worked perfectly for me. So, what I think is happening is that you're broadcasting "TEST do commandsay" and not "TEST do command say", unless you had (word) originally set to a space. So, if this is true, then you might just want to add a space at the end of the first string of your last join block. So, is it working now?


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2012-12-27 21:27:50

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: I don't know what's wrong

Also, you can always do this to debug  tongue

say (join [TEST do command ] (item (1 v) of [command v]))
broadcast (join [TEST do command ] (item (1 v) of [command v]))


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#4 2012-12-27 21:45:23

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: I don't know what's wrong

I've found that using a space in a

<[] = []>
doesn't work, so I always convert spaces to slashes (or whatever  tongue ) when I do something like that.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#5 2012-12-28 15:08:27

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: I don't know what's wrong

Oh thanks it works now  smile

Reporting to be closed...


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6 2012-12-28 16:38:31

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

Re: I don't know what's wrong

Closed by request of the topic owner.


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

Offline

 

Board footer