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