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 endI 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.
Last edited by joefarebrother (2012-12-27 17:36:12)
Offline
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?
Offline
Also, you can always do this to debug
say (join [TEST do command ] (item (1 v) of [command v])) broadcast (join [TEST do command ] (item (1 v) of [command v]))
Offline
I've found that using a space in a
<[] = []>doesn't work, so I always convert spaces to slashes (or whatever ) when I do something like that.
Offline
Oh thanks it works now
Reporting to be closed...
Offline