Say It generated code faulty?
Miltos
Posts: 16
I've just generated the portion of code underneath with the Say It module:
I don't know why but only the first group of i.e CASE G0_BOE is executed. The code ignores all other cases. Am I doing sth wrong?
VR_Action: DEBUG "got ", DEC VRCOMMAND SELECT VRGROUP CASE GROUP_0 SELECT VRCOMMAND CASE G0_BOE PAUSE 0 '-- write your code here ENDSELECT CASE GROUP_1 SELECT VRCOMMAND CASE G1_FORWARD PAUSE 0 '-- write your code here CASE G1_BACKWARD PAUSE 0 '-- write your code here CASE G1_RIGHT PAUSE 0 '-- write your code here CASE G1_LEFT PAUSE 0 '-- write your code here CASE G1_STOP PAUSE 0 '-- write your code here ENDSELECT ENDSELECT RETURN
I don't know why but only the first group of i.e CASE G0_BOE is executed. The code ignores all other cases. Am I doing sth wrong?
Comments
Sorry I'm away from my pc
See how much more readable your code is?
Anyway, your 'problem' is that you have a set of nested CASE statements. The first, working with the VRGROUP variable splits the program in TWO blocks, and only one of those can be executed.
(GROUP_0 or GROUP_1 )
Drawing a flow diagram can also help.
Sorry that I can't write more clearly, but I think it's something like this you want...
(I haven't programmed a BS2 in a couple of years... )
It always helps to write your program in 'pseudocode' first, then transfer it to 'proper' code afterwards.
Another thing I like to do is to print the code, then use a couple of underliners, draw large '[', starting at the beginning of the IF/CASE/DO/Whatever 'Flow control' command, towards the margin, down, and out to the ENDIF/ENDSELECT and so on. With another line out to the start of every ELSE/Select, you can see more clearly what is and isnt executed when a certain condition exists or not.
http://forums.parallax.com/showthread.php?132551-generating-functional-code-Sayit-Module-and-Parallax-Digital-I-O-Board
see post #six
This is the portion of the code, I am talking about. Unfortunately only the command BOE turns the LED on (is executed). All the rest (FORWARD, BACKWARD, TURN_LEFT etc) are ignored...
Thanks for your help anyway!
Sounds like you need to use the BOE word to change the GROUP from 0 to 1. This is what I did with my Speaking, Voice-Recognizing Home Automation System. See Voice Recognition code from my project below. Saying "Computer" changes the code vrom VRGROUP10 to VRGROUP1 - meaning it stops listening for Computer once it hears it and starts listening for teh commands to actually do stuff. Here's the code:
Let me know if that helps. This is just a piece I have as a subroutine in my full program. Search for that Speaking, Voice-Recognizing Home Automation System thread to see FAR more details...
Here's your code with the requisite line included:
Good luck,
Dave
I will make the change from GROUP 0 to GROUP1 (i.e VRGROUP=1) and I will let you know...Thanks again!