Download and watch the episode here:
Coding 101 3
Shannon: Today in coding 101 we are getting into some Mac love and as well as while loops, we are going to review those as well as relational operators four loops.
This is TWIT, Bandwidth for coding 101 is provided by cachefly at cachefly.com
Fr. Robert: This episode of coding 101 brought to you by Lynda.com, learn what you want, when you want, with access to over 2000 high quality online courses and training videos. All for one low monthly price. To try it for free for 7 days visit lynda.com/c101 that's Lynda.com/c101.
Fr. Robert: welcome to Coding 101, it's the twit Show that's gives you the knowledge to live the in the wonderful world of the programmer, I am Father Robert Ballecer.
Shannon: (Laughing) And I am Shannon Morse. And for the next 30 min we are going to get you all theorized up, and all researched up on the code.
Fr. Robert: The key to learning anything is repetition right, you have to learn a lot in order to learn a little.
Fr. Robert: Is there anything we need to go over?
Shannon: Actually, yeah.
Shannon: we got a lot of feedback on all sorts of different things. So I decided we should show some mac users some love and well as review while loops.
Fr. Robert: oh yes, good call. Brothers and sisters rejoice cause snubs compiled is gonna drop the knowledge on you. Right now
Shannon: go ahead and check out Microsoft visual studio express, on my windows s 7, Acer aspire 7, I wanted to get back while loops. Just to a quick review of what we learned last week as far as those goes
Shannon: so I went over to the get hub and I am using the same exact program as last week. This is my visual studio all set up I just copied and pasted what Lou taught us, as well as all his notes and everything else that is included in there, and ran start and we see that the program works
Fr. Robert: there, kaboom. To remind everyone what we did with wild loop was, we had it output to the screen, the number that was in the counter, then it would decrement the counter and then continue until it hit zero.
Shannon: exactly. So there is a lot of information in here. so I also wanted to share one of my very very simple while loops so I took your example from last week and I created my own up here, and I also just figured two files show up u here so you can switch between the two.
Fr. Robert: wha hoo
Shannon: Very easy to do, all you do is go to file, open file, if you have already saved it. And then choose your file from the list right here. So I have my wild loop 2 and Lou’s example both opened up next to each other.
Fr. Robert: Which is nice because it is just like tab browsing, you can go back and forth between the safe code the one you know that works and the one that you are going to try and break.
Shannon: Yeah, so I can see what kind of errors I’ve been making and see if I can fix them myself.
Fr. Robert: mmhmm
Shannon: so I used this example right here so I have really high counter, I called counter, and then my while loops starts with well the counter is greater than then 5, continue with right line, of the counter
Fr. Robert: mmhmm
Shannon: So that starts with 1000
Fr. Robert: And remember that cause the right is different than the right line, so counsel that right, will just output the number and then the next number will be right behind it, and right behind that one. Right line....
Shannon: Yes, right line will give us an enter so that it goes down to the next line
Fr. Robert: Yes, exactly
Shannon: Ahhh, Hence line, so next on the next line ahh we have counter which is 1000 equals 1000 minus 1, every time this is still true, as far as being greater than being then 5 is loo
Fr. Robert: Right
Shannon: It will continue this loop. So if I run this right now I get, Notice the last number on here is 6.
Fr. Robert: Ahh Snubs that's interesting why doesn't it go to 5?
Shannon: I don't know, maybe because 5 is not greater than 5.
Fr. Robert: Oh wow that's going to lead us into when we talk about relational operators, but that’s a good little foray
Shannon: Exactly, isn't it?
Fr. Robert: A lot of people, ok folks, you’re going to get confused at least a couple of times, when your programing when you start doing these loops, because it's not going to run as many times as you think, that, that’s what Snubs just demonstrated is why it’s not running as many times as you think. Just remember have in the back of your mind every time you check that condition. So wither or not that is true, if you’re not using the greater than or equal to or the less then equal too it's going to stop a number ahead or a number behind the number you set as your trigger
Shannon: Exactly, Now I also wanted to a little bit of review about how to open the same program or kind of the same program, in Mac OSX, so I have a MAC book Air over here, I am going to just shove this over. SO I can show you what this looks like, and I have the same program running on this one, except this one is called Zameron Studio, so you can download this at monodevelop.com/download, I choose the stable release, Mac OSX, Zameron Studio installer, so you click download and it will also tell you, if you just click download it's not gonna work, you also have to have a couple of extra packages to include with that, to install this release you also need to download the following packages. When you click on this it will bring you to this page and you choose MAC OSX, so the same operating system that you were using and you choose. This was kind of weird, so it says until MAC runtime or SDK, and I was Like, I am not really sure which one I need to download.
Fr. Robert: mmm huh
Shannon: Because there are no directions as to what is the difference between the two, so I downloaded both of them ( laugh) and I installed both of them
Fr. Robert: Safe Choice, Ok put them both on
Shannon: it worked just fine. So after you install those three different devices you can open up Zammeron studio. Zammeron Studio is just a regular application for Max OSX and it looks like this when you first open it up. I clicked on new and I go to C sharp and choose the same the same thing console project.
Fr. Robert: wahoo
Shannon: Down at the bottom you can choose a name for it. I will call this episode 3 and click ok, and it will open up your brand new project.
Fr. Robert: And this is the nice thing. We told people about this before, right look we are doing visual studio, but you can do this in other environments
Fr. Robert: Here is proof you can take the code we are giving you and can drop it into this, this id, this id on a Mac and it will work just fine
Shannon: Exactly, and it works just fine, um it looks very similar to the version of visual studio express that we are using on the windows machine, so it’s very similar, and if you want to use the same kind of wild loop on this one you just copy and paste thee entire wild loop over too, console right line, and include your wild loop. So very very easy to use and it runs as well. So I could copy it over right now. Let’s find it ok
Fr. Robert: And we should mention, that this studio IDE is cross platform you can use it on windows you can use it on mac and yes for you Linux folks out there you can use it on Linux so you could download this, install it on your operating system of choice and use it as a one stop shop for playing with c sharp code
Shannon: it is so Fun! Ok so I am going to. All rght I deleted my quotes, cause when I copy and paste it gives me little quotes, I don't need those. SO I am going to hit build all. Let’s see if it gives me any errors, build successful, ok so we are good, woops, my bad, then I go over to run, and I am going to start debugging, so it will give me any bugs if it runs into any. And down here is my program. So it looks a lot smaller it’s a little bit smaller a little bit harder to read on the big screen but it’s the exact same line of code. Press enter
Fr. Robert: Ahh... How about that! Which is what we want. It’s the same code, same output, which is what we want. That tells us it’s the same studio
Shannon: So Cool, It works, Yay
Fr. Robert: we know theoretically it should work but tell me it kinda feels nice right. It does
Shannon: it stills feels very exciting whenever these things actually work and nobody sat there and sat over by shoulder and said ok press this button. I just figured it out myself.
Fr. Robert: the magical moment of discovery where you’re like, oh gosh, I don't know, it worked
Shannon: Yeah, I love that feeling
Shannon: So, Moving on.
Fr. Robert: Yeah, I’m thinking maybe we need to do some ivy tower, yeah
Shannon: yeah, I’m think so
Fr. Robert: yeah so last time we talked about while loops, I’m thinking maybe we should talk a little bit about that condition, you know that thing in parenthesis right after a while.
Shannon: conditions? Is this like what I put in my hair?
Fr. Robert: Yeah you know it keeps you nice and flaky, actually not flaky, soft
Fr. Robert: Unflaky, I really don't know what condition it does, No but it's the thing that is bolding expression right it's either true or false. So in our example we use we use the while statement, and a while loop looks like this, while and then I have that, and then I have my brackets. and what it means is it will run this piece of code, whatever I got down here, be it a right line, reline or whatever it's going to be, as many times as this is true
Shannon: () Yes
Fr. Robert: as long as this condition is true
Shannon: Use this code inside of these brackets
Fr. Robert: Exactly, now I could do something like this, I use these relational operators, This relational expression, I could say, one equal to one.
Shannon: fill that in it looks like kinda like a semi colon at the end there, there we go, and that’s prettier
Fr. Robert: oh yeah sorry, now this is true correct one is equal to one
Shannon: one is equal to one yeah
Fr. Robert: here is the problem; this loop will never stop running
Shannon: because it's always going to be true
Fr. Robert: 1 it doesn't matter how many how many times this thing loops through one will always be equal to one, so this is a relational operator, this is a relational expression, this is a condition but it is a horrible condition. It's not something we would ever use in programming because it doesn't make sense. A four loop doesn't work if it always runs or never
Fr. Robert: Runs, so for example if I did this, let’s say I did this 2 is equal to 3 that's false.
Shannon: It's Pointless
Shannon: that’s never true which means whatever is in the brackets will never run
Fr. Robert: will never run, and if it's never going to run, why would I actually write it
Fr. Robert: So what we do, do we have, reach back to your bag oh tricks Ms. Snubs, do we have concept that we talked about on the show that maybe is a placeholder that could have different kinda values
Shannon: oh I know
Fr. Robert: oh
Fr. Robert: Bang, Exactly, We talked about this before, we covered variables on the show, let’s just, my favorite x, so we have x greater than 0
Fr. Robert: Now, this could change cause we don't know what the value of x is, the value of x could be changed within here, if did x equals x plus 1, just like you did in your example where is was x equals x minus 1, I’m doing plus 1. so if I say integer x starts at 100, actually I am going to use minus 1 here, starts at 100 its going to hit here
Fr. Robert: 1 the first time, 100 is greater than zero, then it's going to subtract one and it's going to run it again and it's going to get to 98, 97,96,
Shannon: yes, True, so it's very similar to what I did in my while loop
Fr. Robert: 1 Exactly, this is just a standard while loop, but what we want to focus on is this, this condition, this relational operator is key, because you see this in programing all the time, remember what we talked about in the first episode.
Shannon: True we do, Yeah
Fr. Robert: Binary, Right, binary works. Programing works on binary it either true or false, it’s either going to run or it’s gonna not. In order to do this
Fr. Robert: we need to know what kind of relational operators we can use, and again I know you told me never to do this
Fr. Robert: but we are going to have to go back to high school math, are you ready for this?
Shannon: alright I'm ready
Fr. Robert: Ok so we have already seen this, we've seen greater then and less than
Shannon: Greater than & less than
Fr. Robert: so we know if this is true as long as what’s on this side is bigger then what's on this side
Fr. Robert: this is true less then what's on that side
Fr. Robert: now I also have this
Shannon: Ahh Is
Shannon: is that greater than or equal to
Fr. Robert: exactly greater than or equal to, Less than or equal too
Shannon: Ok Got it
Fr. Robert: Again, Regular Math, This math, this will be true as long
Shannon: I almost forgot this stuff it's been so many years
Fr. Robert: But it comes back it's like riding a bike, you fall off and you skin your knee and you go crying. No but this will be true as long as what is on this side is either greater than or equal to what's on that side and this will be true less than or equal to what's on that side
Shannon: so for my example when I said counter minus 1, or counter minus 5, all the way down to when it hit 6, if used I used the greater than or equal to it would actually hit 5.
Fr. Robert: Five. It would rune one more time, because it would run with that five
Shannon: that’s cool
Fr. Robert: here are two more that you’re going to have to know and that is this, you saw me use this briefly.
Shannon: Equal too
Fr. Robert: Equal too. It's not just standard equal. You can't just put equal, the way that we use it.
Shannon: that’s what I figured you could do
Fr. Robert: yeah yeah, it’s equal, so this will be true as long what's on this side is the same value as what on that side that’s true, and then there, I’m sorry about this
Shannon: what’s that one never equal too
Fr. Robert: it’s the bang, not equal too.
Shannon: not equal too.
Fr. Robert: 1 So it's the opposite of this, so this will be true as long as what's on this side is equal to what’s on this side this will be true as long as what's on this side is not equal to what’s on that side.
Shannon: got it
Fr. Robert: Now. This is just math, so everything you could do with this in a math question, you could do with program
Fr. Robert: the reason why we have all these different types of relational operators is because we need different ways to express what is going on inside your computer program.
Fr. Robert: Yeah. Exactly
Shannon: I’m ready
Fr. Robert: Yeah you’re ready. If we only had the greater then we'd be fudging our code to make sure it incremented every time or decremented ever time
Fr. Robert: that would be freaking, horribly, terribly annoying, and no we don’t want to do that
Shannon: But that would just be annoying for the programmer, we don't want to do that
Fr. Robert: Alright, so last time talked the while loop, and you had a really good example of the while loop, and you had to create a variable that acted as the counter and the counter was decremented every time the loop.
Fr. Robert: Ran and so eventually the loop would stop, but that is only one type of loop.
Fr. Robert: snubs so you want to know about another one?
Shannon: so there is more than one
Fr. Robert: Lets learn about the four loops.
Shannon: four loop
Fr. Robert: the four loop, is, this is the loop that I use more often than anything else
Shannon: Oh really
Fr. Robert: this is, Not the while loop, it’s the four loop
Shannon: not while loop?
Fr. Robert: the reason why the four loops is a little bit different, the while loop had to have this, remember you had to have some sort of variable that was initialized outside of the loop. Correct?
Shannon: 100, ok
Fr. Robert: Because, Remember If we just use static numbers the loop either always run or never run.
Fr. Robert: initialized a variable outside of the loop, then we need to make the loop, use that variable, x say greater than zero, and then we need to do something within the loop to make sure we change the value of x. right
Fr. Robert: 1 Cause otherwise, if this was true the first time, and I never change it, it’s always true, if it's false the first time, it never runs, so I would say x equals x minus 1.
Shannon: yes, ok
Fr. Robert: ok, so this is a simple loop, this actually won't output anything to the screen, but it will run until x is no longer greater than zero.
Shannon: that makes sense.
Fr. Robert: that makes sense. There is a different way to do this, I don't have a initialization of a variable outside the loop, I don't have to have the condition, and then I don't have to do here the step or what’s called the step
Fr. Robert: I don't have to do a step, I could have everything
Shannon: But that’s gonna break it.
Fr. Robert: it should right? Unless I have something like this, Four, x equals oh sorry, integer, x equals 100
Shannon: uh huh
Fr. Robert: x greater than zero, x minus one
Fr. Robert: what a four loop lets me do, is it lets me put its initiator, its own condition and its own step within the structure itself
Shannon: so that actually looks like it's going to save you a lot of time.
Fr. Robert: It is, It is, Right
Shannon: Cause you don't have to use different lines for every bit of the command.
Fr. Robert: 1 Exactly, one of the nice things about the four loop, is I don't have to worry about, well did I initialize the variable, am I using the step, is the step inside the code, no it's all contained right here, I initialize and initialize my variable, I set my condition, and I do my step all in one line.
Shannon: that’s cool
Fr. Robert: it’s very cool. Right and then I could do anything here and this would continue to run every time this four loop runs it will x minus one.
Shannon: that’s awesome. So down in between your brackets when the actual command runs you could make just say hello world a hundred times.
Fr. Robert: Yeah
Shannon: I guess that would be 99
Fr. Robert: Yeah
Fr. Robert: Gotta Love it. Now the four loop is one these things that once u start using it, it’s hard not to use it, because it is so useful, it does pretty much permeate every bit of code that anybody ever writes. What people normally do is, I love to use the plus increment, I’m kinda addicted to that and oh man.
Shannon: what does that say. Plus Plus
Fr. Robert: Plus, Plus You know we need to get a bigger board, x, plus, plus
Shannon: or just push the board over
Fr. Robert: Plus plus is the same thing as saying add one. So every time the loop runs it would be one and then I’d have to change the condition to say, as long as it, ahh start at one x is uh less than 100
Shannon: less than 100
Fr. Robert: so, there we go
Fr. Robert: so do you understand four loops?
Shannon: I do, yeah. That’s pretty easy to understand given that we already learned while loops.
Fr. Robert: Yeah, exactly
Shannon: it makes sense
Fr. Robert: and this is where we want to be Shannon, we want our code monkeys, we want our code warriors to start understanding all of these concepts are going to start building up on each other.
Shannon: yeah, yeah
Fr. Robert: so integers, variables, conditions, relational expressions, loop
Shannon: all of this can be used together and all of it will happen again.
Fr. Robert: and you know what we should do is bringing in the man who's going to show us how to use it together
Shannon: I'm gonna guess this is our awesome friend Lou
Fr. Robert: Lou our code warrior comes in. Lou are you there?
Lou Maresca: I'm here, how you doing, guys.
Fr. Robert: Pretty good how are you
Lou: I'm doing fantastic, thanks for having me again.
Fr. Robert: Now you were tasked with giving us a program that would show off four loops for the boys and girls at home. You want to break that bad boy out?
Lou: You bet
Fr. Robert: 1: alright, how about this, let’s do something a little bit different. Because we've sort of been cutting your time short because we didn't want to confuse the people at home
Shannon:: That’s true
Lou : Am I that confusing?
Fr. Robert: No, you’re just too smart for us. not but what we'd like for you to do now is go ahead and step through every line of code, ignore the includes, because we haven't gotten to the includes yet, but step through the lines of codes to show us what’s going on inside your program, especially when you get to four loops.
Lou : You be, so Obviously the first thing we have here is, if you show my screen here, is the normal console program that we have seen before, that Stubs has shown, that I have shown to you and and we have, ignore name space for now in the class but we can obviously go down here, this is the beginning function, we call main function, every console application has it. So what we want to do is what Padre said, we want to ask the user for them to basically write a piece of text and then we want to loop the text a bunch of times, and we are going to ask them how many times they want to loop it. So again we go back to the using console. We're going to write out, and were are going to ask them what would you like to write today, what would you like to repeat a bunch of times, and then that will basically write to the user. Then we want to ask the user, we want to say hey, you know, why don't you go ahead and type that in for us, so we will do that using the console read, so we have seen this all before, this is console read, I have all my little comments in here. Sorry about that.
Shannon: we like your Comments
Lou : And we can store that, and we have what we call a string variable again called text and that's where we are going to store it for the time being.
Shannon: Text, Got it.
Lou : Yep, Yep. and then, so now we want to ask them how many times you want to repeat this, because you can do the four loop and you can statically set it, like Padre was saying hey I can do it 100 times or you put a 1000 times on yours. and so I want to ask them, I want to actually ask the user how many times do you actually want to repeat this, and so I am going to ask them again how many times do you want to repeat it, again console outright I’m going to ask the user, again I am going to have them input it. And so next line would be hey give me the number. SO now you'll notice that it's actually um, another string variable because the user is entering a bunch of text and we need to store it somewhere and that is where this string variable comes in, but we really want this to be a number, because right now it's just a string. So we have to do this fancy smancy, conversion that we have to do, say hey give me the text and convert it to a number. So I am going create a variable to store in there, so I call it ent-repeat number and then I’m going to do the conversion. This conversion will not only have the conversion code, but will also have a check to make sure the user isn't entering garbage inside console application.
Fr. Robert: 1: right so when we talk about sanitizing inputs that’s exactly what you are doing here.
Lou : This is a lot of code, this has a bunch of text to the user saying hey I did this check and we don't have to worry about what this check is doing right now, but I did this specific check to make sure it's a number, and you didn't enter a number to me, so I am just entering a console, and I am actually changing the color of the console to be red. So this way the user understands that they made a problem, had an issue
Shannon: ahh Ok User Error
Lou : User Error Exactly
Fr. Robert: What we got here for the folks at home is so far you've asked someone on the other side of the screen what they would like to repeat. Then you've also asked them how many times they would like to repeat it. Lou: that's right
Fr. Robert: And then you got a function in there that says, let’s look at that string and make sure it's in the right format for us to be able to do this program.
Shannon: : Sanitizing
Fr. Robert: Before we go on, so we are going to tease them, but you know what
Lou How about this, why don't we take a break to let the folks at home know who supports know how, and how they can find out more about what we are talking about.
Shannon: : Know How
Fr. Robert: Coding 101
Shannon: wrong show, man
Fr. Robert: I know wow this is not known how this is coding 101, bang how about that. Ok now Lou have you heard about Lynda.com?
Lou : I have.
Fr. Robert: Lynda.com it is the source for everything that we need to know about everything we need to know. It's how geeks learn on the internet. The cool thing about Lynda.com is it’s an online learning company. That can help anyone learn creative software and business skills. To achieve both personal and professional goals. Now with a Lynda.com subscription the members can receive unlimited access to a vast library of current and engaging video tutorials across a wide virility of subjects. Anything from creative and software skills to business negotiations and programming. Now Lynda.com you ;all learn how to create code, how to build applications, from the foundations of object oriented programing, and c and c plus plus, to desktop, and mobile apps for today’s popular operating systems. You'll explore the fundamentals of programming, building web applications with dot.net, php, MySQL. Managing data with sql databases, connecting to cloud services and so much more. Now Snubs we've talked about that this before right.
Shannon: Yeah, we have.
Fr. Robert: When building coding 101 we said we want to show people the exciting bits of code, but then they have to get poke at things, they have to break things, and they have to find how things work right.
Shannon: That's right, absolutely
Fr. Robert: That's what Lynda.com is for, this service will allow you to say guide you through a c plus plus course. To look at the fundamentals of object oriented programming. To fill in the blanks, the things that we don't teach on the show, cause we don't have time. Well at Lynda you got the time, you got all the time you need, you get to learn at your pace, anything, anytime, anyhow. Now you can improve your skills learn new software, keep up with new software, keep up with technology with Lynda.com. They have over 2000 courses, with more added each day. There popular courses right now include topics like the foundations of programing, html, php with my sql, objective seed java java script, and word press. There instructors are working professionals at the top of their fields and expert teachers. They have high quality video productions, from state of the are studios. Stubs you know this. This ain't the guy at home, that who's really nervous and really doesn’t know how to be in front of a camera, this is someone who knows how to teach you.
Shannon: Yes absolutely
Fr. Robert: Lighting and sound and so that everything looks and sounds great. They have curated course content, each Lynda.com course is carefully structured so that users can learn from start to finish or jump to a specific chapter. They also have easy to follow videos that can help you find the answers you need and searchable transcripts that let you search within a video. This is key, it’s not just chapter headings, you can look for specific question you need answered and jump to that part of the video. It’s a great feature. They have courses for all experience levels, beginner, intermediate, and advanced. Covering a wide range of technical skills, creative techniques, business strategies, and more. You can watch from computer, tablet, or mobile device. You can switch and pick up on the chapter where you left off. You get to learn at your own pace on your own schedule. So how about this we want you to try lynda.com. It's only twenty five dollars a month for access to Lynda’s entire course library, or for $37.50 a month, you can subscribe to the premium plan, which includes exercise files that let you follow along with the instructors projects using the exact same assets. You can try Lynda.com right now with a free 7 day trial visit Lynda.com/c101 to access the entire library. That's over 2000 courses for 7 days. That's l y n d a. C o m / c 1 0 1 and we thank Lynda for their support of coding 01. Shannon: We love them. FR : I love them Shannon: Love FR : even though I did mention the wrong show Shannon: That's ok FR : GO figure. Now Lou now that we know where they can go after the show to find all the little things we aren't telling them right now you want teach us a bit more about your code. You just showed us how you’re going to output to ask the user to input both the string and the number of times it should be read, where we go after this.
Lou : Basically, we're just showing you stuff you’ve already seen before and some of the other examples we've given. So the next thing we want to do is output, or actually print to the screen the text you've entered a certain amount of times, and the number of times is going to be the repeat number. So I am going to do a quick four loop here. Just like Padre has shown, and let me explain the pull up real quick. So what I have done is, I have, we call this the initiate the condition and the update, and so the initialize is we have a count variable we created, saying this is how many times I want to do it. I am starting at one and then I am incrementing that count using this fancy plus plus operator that Padre showed or I could just do plus one, make it easier.
Fr. Robert: oh no but what fun is that Lou: I like the Plus Plus.
Shannon: So plus plus is the same as Plus one?
Lou : yep that’s right, it's basically saying count.
Shannon: Always Lou: count equals count plus one is basically what plus plus means
Fr. Robert: you could also put like count equals count plus five although that would be a very rare case.
Fr. Robert: You could make it any count by anything you want
Fr. Robert: It's a count
Lou : That's right.
Lou : you can minus, you can plus, you can multiply, or whatever you need to do over here. SO basically then I am checking to say hey after the count does plus added one to it, is it less than the amount of times you've asked me to repeat, less than or equal to in this case.
Shannon: Ahh, Ok
Lou : So then basically output the text that they have to screen in this loop, and then it should pretty much, the program should just end after I do it this many times. So if I run it real quick.
Shannon: So what is this console right here in green, it has a zero in the middle of a couple paragraphs.
Lou : oh yeah sure. Yeah so what that is called is basically just a replacement, basically you can do it, there is a couple ways you can do it. I can just do, I can do text, like this, or I can do,if I want to actually say something in here I can do text plus hi.
Shannon: Oh LR : which is a concatenated string Lou:or there is another way to do it, and I actually prefer it this way, is where you can put these little tokenizers they call them. That means hey this is a placeholder for some piece of text I want to put in here, and the text I want to put in here is the one after the comma.
Shannon: ah that's weird
Lou: So you can put anything you want in here and then it will always say text and then this little stuff right here.
Lou : So it's called a tokenizer. It's really easy. It's up to you what you want to do, I can make it even simpler and just do this. So now say hey output text to the screen.
Fr. Robert: Lou is doing it the professional way.
Fr. Robert: Tokenizer
Lou : The reason I put that, is because I can have like a space after it and you can actually see the word. So this, this is a little space right here
Shannon: oh I see I'm going to have to break into that and start messing with it
Lou : yeah it's fun. So let me. If I do this real quick, and I show you pretty big text, but we say, I want to say hi. Then it says, this is really big, how many times do you want to output to the screen and I say I want to enter 100 times and then, there, enter enter inputs 100 times with a little space in-between there.
Shannon: Ahh cool
Fr. Robert: and that's because you put a little space after the tokenizer, if you didn’t put a space it would just be hi, hi, hi, hi, hi, hi Lou: Forever
Lou: So the last thing I want to show, is real quick is what we call, an out of scope variable, and what this is, is a very similar to a while loop because basically I am initializing my count outside the four loop. Then I am saying ignore this first parameter because I don't need to initialized anything and then use the rest. What this allows me to do when I am done with the loop I can actually say hey, this is how many times I have actually ran the loop. SO I can actually output the count to the screen.
Shannon: That's cool
Lou : What this will allow the user to do they can switch around this little operator up here to basically see how many times they can get the loop to go based on the operator. So if the change this to just equal will it actually do the amount of times they expected. So if I run this and I do 100, 200 times, hey actually count the count is actually 201, so we need to figure out why the operator is doing it that way.
Shannon: Oh weird
Fr. Robert:This gets back to your interesting demonstration with counting down five.
Shannon: Yes, that is interesting. Ok
Lou : so this is a little easy way, you can pretty much, you can pretty much not put any of the parameters in the four loop and that becomes and what they call an infinite loop, and then you would have to somehow break out of the loop in here somewhere and put a break statement and then it will break out otherwise you will sooner or later run out of memory or something and the program will crash.
Fr. Robert: Which is what we talked about, you know having a while loop without anyway to increase or decrease the counter.
Fr. Robert: You’re either always going to run or never going to run. What Lou is saying is, you know what how about this. We've seen these programs before right, the looping, I’m thinking of the doe song
Fr. Robert: Imagine that but in programming technology. We could say hey you know what just keep running this until they tell me to stop.
Fr. Robert: So that's what Lou adding here. He is adding a little break to say ok, check to see if they want to get out of this.
Shannon: Looks like this could be really handy and save you a ton of time
Fr. Robert: Yes absolutely,. Yeah Lou do you want to talk about that. One of the things we like to bring to our audience is a higher level of looking at code. Obliviously the examples that you write for us, and by the way thank you for being our code warrior, they are rudimentary. I don't think Microsoft you'd ever have one of your managers come to you and say we'd like you to write a four loop to say hello world. Have you had that? Is that a current project of Microsoft?
Lou : We build a lot of internal tools and some of them are pretty much as simple as that, they just do a very simple task. They delete a file or something, so we have done that before.
Shannon: Oh wow
Fr. Robert: Yeah Yeah. I mean, I don't know about, I probably slant towards four loops. I say 60%
Fr. Robert: 60% of the time I am using a four loop, what would you say the ratio is for you
Lou : For four loops, I think I use four loops for everything, cause I can pretty much make it look, feel like a while loop, make it feel like four each loop, or do wah, or there is also do while loop as well. So I can make them kinda do similar things. Four loops kind like you know universal like that. So I like to use it the most. Then of course there is another one four each which we will get to later, but and that one..... Over things but those are the two I use the most.
Fr. Robert: Actually maybe you can help us with a question we got in the chat room. Wait a minute, I know you’re going to talk about four loops in the next episode, if four loops are so useful why would you teach us any other kind of loop? Shouldn't you just teach us all the things about four loops? What would your answer be to that?
Lou : So while loops, specific types of loops allow you to do things more efficiently. So like what happens is when the while loop gets compiled down to potential machine code, it does, it's compiled down to a specific piece of machine code. So sometimes while loops are potentially more efficient than four loops depending on what you are doing. So like when you are just basically outputting stuff and doing some conditions sometimes while loops are more efficient. If you need to like increment a counter a bunch of times and then do a check like you were showing on the board then it makes more sense to a four loop because that gets consolidated when it gets compiled down and more efficient and so it runs faster and more efficiently.
Fr. Robert: Lou, is there any parting knowledge you can give to our aspiring code warriors, all the code monkeys who might be in the chat room saying. Ok I’m starting to get this but ah, maybe haven’t clicked. What advice would you give to the young code monkey?
Lou : Honestly, Try stuff out. Mean use the. Go out msdn articles, or even there stack overflows and other great websites, there are great websites out there that gave you some great examples. You know, change the program to do something for you. Let's say, like for instance I did a superbowl thing where I did the squares and you got to put everyone’s name in the square and we had to pick a random square. So I built a really simple console application that generated a random number and then we put that number in the square. So build your applications that will help you, maybe even change the applications we give to you. Just do something for you, and then it will actually will hit more home for you and you'll relate to it more. You'll be able to change it, you'll learn more from it by actually relating it to yourself Fr. Robert: Lou thank you so very, very much. I'm going to say this. Snubs we've been wanting for a while to get some homework form our audience right.
Shannon: Yes, Absolutely, and I am always up for seeing what viewers are bringing in to, cause I want to feature you guys on the show as well. So I’ve been asking about that on the google plus community as well. Fr. Robert: how about this, take a snapshot of your code. Do like what Lou suggested. Make the code work for you, you don't have to use our examples. You know what the code does. We’ve been poking you into the code, the last four weeks. So how about this, jump in there change something to make it fit you. I don’t' know maybe you can make a draw, maybe you can make do something fun across the screen, take a shot of your screen, take a shot of your code, take a shot of your output,....., that's it, that's the challenge. Get in there and do some askie art. Take a shot of your askie art, make sure ends up on our g plus page and who know maybe we will feature you on the show.
Shannon: Wonder if that would work.
Fr. Robert: Hmmm Lou again, thank you very much for coming onto the show. Do you want to tell the folks at home where they can find you?
Lou: Definitely, twitter.com @Loumm and you can about.me@Loumm as well Fr. Robert Ballecer, 1: Don't forget you can always find the code.
Fr. Robert: You can find it in our show notes specifically we have a link in the show notes to our get hub page. There you will be able to copy the code exactly as Lou gave it to you. He's giving you the assets so that you can go ahead and play around with it. Don't forget to visit that show page at twit.TV/code and subscribe also make sure that if use iTunes, if you are an I device user jump into iTunes and subscribe to coding 101. Believe it or not I believe we are in the top 10 of podcasts.
Shannon: Last I checked we were
Fr. Robert: Go figure, Please we love you.
Shannon: why are people watching the show? I’m so confused. But you can also check us out on utube. We are at utube..com/twitcoding101 so you can watch all of our episodes and catch all the updates about google hangouts, because I defiantly want to do that. We also just started up our google plus community; I finally made an image for our profile.
Fr. Robert: whoop
Shannon: Profile picture, so we've been getting in there and asking you guys for your ideas, what you want to see on the show as well as getting some really good feedback. So thank you to everybody that's doing that. You can either search for us its twitcoding101 or you can use the tiny URL, its tinyurl.com/ coding101
Fr. Robert: Yeah. and if you’re not into that group you can also find us on twitter, that's a really good way to talk to us, maybe ask us a couple of questions, suggest things you want on the show. You can find me on twitter.com/padresj and snubs
Shannon: I'm Snubs@snubs FR: WOW I love things that are simple
Fr. Robert: That's what I get for making it in 2005 FR : I like it, I love it, it's a great name. Don't forget we do this show every week live. Right here Thursdays at 1:30pm PT you can drop over to live. Twit.TV find out what we are doing before and after the show. Also we have a chat room right?
Shannon: Yep irc.twit.TV and we have tons of you guys down there right now and we've been reading your feedback as it comes in. So thank you so much for talking with us while we've been doing this live show. We appreciate it.
Fr. Robert: We really do. Folks that’s the end of our show! I am Father Robert Ballecer,
Shannon: Shannon Morris, Snubs
Fr. Robert: End of line.
Shannon: BOOOOOR, you went there!