22:13:31 for (i=10; i>0; i--) { // limits the amount of commands user can enter in for the robot 22:14:25 When will the loop stop? 22:14:32 it would end of q=true. 22:14:47 No, that's what we want it to do. 22:14:52 It doesn't do that now. 22:15:04 We have to make that happen. 22:15:58 As it is right now, what makes the for loop stop running? 22:16:03 If we just let it run its normal course? 22:16:11 10 commands. 22:16:45 And where is that behavior defined? 22:17:00 (i=10) || (q=true) 22:17:13 What? 22:17:33 It's defined within the for loop. 22:17:43 Within the ( ) 22:18:03 Okay, do you remember which parts do what? 22:18:13 for ( A; B; C) { 22:18:19 what does part A do? 22:18:22 B? 22:18:23 C? 22:18:42 A sets the value 22:18:52 C sets the change 22:19:29 B sets the parameter 22:19:57 Okay, but what does that really mean? 22:20:03 In english. 22:20:18 for (i=10; i>0; i--) 22:20:32 It might be easier to explain an actual example like that. 22:21:16 a is set to 10 commands, each command has to be greater than 0, and after each command is entered you have one less command to enter 22:21:28 Hmm. 22:21:49 Well I'd say that's a little abstract. 22:21:54 It quite literally means: 22:22:11 i = 10; 22:22:27 while ( i > 0 ) { 22:22:32 i--; 22:22:41 22:22:56 Well that's code translation anyway. 22:23:39 OK. 22:23:48 In english, "Start with i at 10. _As_long_as_ i is greater than 10, add 1 to i." 22:23:53 Err. 22:24:00 "Subtract 1 from i" 22:24:25 The part I underlined is the important part. 22:24:43 Now, in english, what do we want the code to do? 22:24:47 Ok. 22:24:55 We want the code to quit when a q is entered. 22:25:00 the program, rather. 22:25:50 So, "Start with i at 10. As long as i is greater than 0, and q is not true, subtract 1 from i." 22:26:12 Does that sound right? 22:27:13 I suppose really, "Start with i at 10. As long as i is greater than 0, and q is not true, subtract 1 from i, then do the rest of the stuff in the brackets." 22:27:37 That makes sense. 22:27:45 Okay, so now turn that into code. 22:27:48 But I'm still unsure how to translate that into code correctly. 22:27:59 Well most of it's already done. 22:28:07 for (i=10; i>0; i--) 22:28:30 "start with i at 10" --> i=10; 22:29:01 "as long as i is greater than 0" --> i>0 22:29:14 Now the new part. 22:29:23 "and q is not true" --> ?? 22:29:42 Well how do you say "q is not true"? 22:29:51 I'm thinking. 22:31:03 q=false is all I'm coming up with 22:31:24 Well you're setting q to false. 22:31:42 17:53:22 Do you know the difference between saying x = 0 and x == 0? 22:31:42 17:54:00 Yes, the first would be x gets the value of 0, and the second is x equals in the integer 0. 22:32:18 So, just q==false? 22:32:37 Yup. 22:33:11 But remember, we're translating "and q is not true" 22:33:19 Right. 22:33:24 You've done the "q is not true" part. 22:33:34 There's the "and" at the beginning to worry about. 22:33:44 && 22:33:47 Yup. 22:34:09 And then the last part i-- is the same. 22:34:16 So put those pieces back together. 22:34:58 for (i=10; i>0; i-- && q==false) 22:35:02 Does that work? 22:35:05 No. 22:35:15 I didn't think it would. 22:35:18 Remember parts A, B, and C. 22:35:38 Part B is the conditional. 22:35:49 for ( A; B; C) { 22:35:58 i=10; q==false; i-- 22:36:09 Right. 22:36:17 But now you're loop doesn't count to ten anymore. 22:36:24 You want it to do both, right? 22:36:30 Ideally. 22:36:51 You want part B to be "As long as i is greater than 0, and q is not true" 22:37:04 22:29:01 "as long as i is greater than 0" --> i>0 22:37:32 Hmm. 22:38:12 We've been literally chopping that phrase "As long as i is greater than 0, and q is not true" up into code pieces. 22:39:07 If that part of the code wasn't in there originally, the program wouldn't know to count down from 10, right? 22:39:07 If we replace the first part of that english phrase into code, it turns into, "i > 0 and q is not true" 22:39:20 What part? 22:39:26 i>0 22:39:30 No. 22:39:44 Counting down is the i-- part. That's part C. 22:39:48 What does that part of the code mean in english, then. 22:40:06 Which part? 22:40:08 C? 22:40:11 No, B. 22:40:14 The conditional. 22:40:28 "As long as i is greater than 0" 22:40:35 Ahh. 22:40:46 We want B to say "As long as i is greater than 0, and q is not true" 22:41:01 Yes. 22:41:21 Well the first part is already done. 22:41:46 Take "i is greater than 0" out of that phrase and replace it with code. 22:42:01 It's already been done. 22:42:10 What do you mean, i>0 22:42:24 i is greater than 0. 22:43:44 Bear with me through these steps, I'll try to make it as mechanical as possible. 22:44:05 Right now, B is "as long as i is greater than 0" 22:44:18 We want it to say "As long as i is greater than 0, and q is not true" 22:44:40 Well we've already done the "i is greater than 0" part, right? 22:44:49 So cut that part out and replace it with code. 22:44:56 In the original sentence. 22:47:05 Come on, it's easy. 22:47:43 "As long as i is greater than 0, and q is not true" --> "As long as , and q is not true." 22:48:16 Replace the with code, and you get, "As long as i > 0, and q is not true." 22:50:40 That's the problem. 22:50:44 It's easy and I have no idea. 22:50:56 Did you see what I just did? 22:51:37 Okay, here's what I want you to do. 22:52:11 Type out "As long as i is greater than 0, and q is not true" somewhere. 22:52:18 You can do it in IRC if you want. 22:52:47 a>0 && q==false 22:52:59 nice, but it's i, not a. 22:53:10 Woops. 22:53:15 Good. 22:53:31 Okay, now remembe what part of the for statement this is? 22:53:47 Yes, the conditional part, B. 22:53:59 So put that in there. 22:56:26 for (i=10; i>0 && q==false; i--) { 22:56:34 It works. 22:56:38 Thanks for being so patient. 22:56:45 You were right, it was something incredibly simple. 22:57:10 Too bad you didn't know about the break keyword though. 22:57:20 But it was a worthy exercise. 23:01:35 You actually don't even need q. 23:01:40 At all. 23:02:45 http://pastebin.com/m1272b344