 And hello, everyone, welcome to basic programming, getting started. And by basic, I don't mean basic, I mean basic, as in beginners, all-purpose symbolic instruction code, which is one of the classic computer languages that many people of my generation started out with and learned to code. So before we get started, let me give a quick shout out to our members. Thank you so much for supporting the channel. If you're interested in joining, click the join button down below, get some perks, and support more, hopefully, great content. Thank you to everyone who has subscribed. Now, basic, what is basic? Basic, as I mentioned, is beginner's all-purpose symbolic instruction code. It was a computer language, or still is a computer language, invented, or I say released at least, in 1964 at Dartmouth College. Now you can see kind of an example over here on Commodore Basic, and that's one thing to get into kind of your head about. Basic is that, well, basic was a computer language, but there were so many different versions of it, and basically none of them were compatible. So a program that ran on Commodore Basic would not run on Apple II, for example. So it was kind of annoying, you had to like, you know, you could port stuff, it wasn't hugely impossible to do, but you had to be aware of the fact that they were incompatible. And certain languages had certain features. For example, I think Apple had more graphics features, whereas the Commodore Basic had no graphics features. So it's really, it really, really varied. And I started out with what's called Sinclair Basic on what our British friends would call ZX81. It was a Timex Sinclair 1000 in the United States. Then I had a couple Commodore computers. And later I learned about QBasic, and there is still a version of that floating around as well. There was also Visual Basic that came along later and just really expanded what the language could do. So today what I want to do is just kind of give you a real quick overview of what classic old school basic was like. And you'll see that it, you know, while it was easy in some ways for beginners, it was also taught a lot about habits and had a lot of limitations. So what I'm going to do is I'm going to click over to here, and I'm using a website, R-E-P-L dot I-T, so Replicit. And this is a great website. You can create a free account. You do have to sign up though, it's, it doesn't, it used to let you just kind of program without an account, but now they require you to sign up. And it's definitely worth doing. So once you get into Replicit, you should see something up here like New Replicit. And if they click that, you can choose a language. Now this does Python, it does, well you can see it does basically, practically every language conceivable. Now of course it doesn't do everything in the browser because that's just wouldn't be possible, but it does do quite a lot of things. It's really an amazing website and probably well worth the, I guess, four or five bucks a month to join, but you can still use it for free as long as you create an account. Now you can see I've already been doing Python and BASIC. So if you haven't done BASIC, just go ahead and type BASIC, and you'll see three choices. QBASIC, which is something from the DOS era, and again, still exists. There's still an active user base making, I think it's called QB64 now. And then there is BASIC, which is just some people made and they have integrated here into replets. So let me go ahead and try that out. And this is going to be, you can go ahead and create your repl. And if you don't have a paid account, it's going to be public. So anybody that has this link can come in and see what you've been doing. They can't, I don't think they can change it, but I think they can see it. So this is called PGBASIC, and this is version 0.1 by Amjad and Ferris Massad. So thank you very much to those people for creating this and sharing it with the world. And I'll see if I can get a link to that down below as well. So let me talk to you about BASIC. And again, this is old school BASIC. There are newer updated versions that are more modern, have more modern features, but this is the old school BASIC that people used, like I said, my generation, late 70s, early 80s, the 8-bit golden era. So BASIC started out with something called line numbers. So you had to actually number every line of your program. And the general convention was to do your line numbers every 10, and I'll show you why in a second. So the first thing I'm going to show you is how to do a comment. So I'm going to say, you know, intro to BASIC programming by at Tokyo EdTech. Now if I run this, you'll see nothing happens. So this is a comment. So if this was a Python program, it would be a hashtag, but it is a BASIC program. And we use REM, and this is just a note for the programmer. So it doesn't actually do anything. So the first command I'm going to do is print. So print, and then you don't need parentheses or anything, just type. I'm going to put BASIC programming for beginners by at Tokyo EdTech. Now you'll notice I'm capitalizing all of the basic keywords. This was just kind of the way it was done. Now this particular interpreter doesn't care. You can do lowercase, you can do uppercase, it doesn't matter. But I'm going to do it uppercase just to keep it kind of old school. So now if I run this, and you can see now BASIC programming for beginners by at Tokyo EdTech. So this is our print statement. And this is very similar, of course, to how Python does it. And you just do print. Again, this interpreter I can do lowercase if I want. But I'm kind of had a little walk down memory lane here, so I'm going to do it in capitals. And yeah, so that's the statement. Now notice I'm skipping every 10. I don't have to do that. But I am doing that, because the reason being that if I go back and I go, oh my gosh, I forgot to put something, then I can go ahead and put line 15 in the middle, and then I can add something above and below that. That was kind of the logic behind that. Now there is, in most versions of BASIC, there is a command called, so let's say I wanted to clear the screen. And that was going to be line 15. But I'm going to leave that out. It doesn't actually work in this one, at least I don't think it does. Or I haven't noticed it does. But let's just leave that out for now. We don't really need that. But there is a clear screen command. So let's move on and do integers and floats. So again, if you're a Python person, you know what a float is. So in BASIC, we do let, so for example, let x equal 42. Now in this case, x would be an integer. Now this is one of those areas where the programming language, this programming language or version of BASIC differs from, say, common or BASIC. So if this was common or BASIC, I think you had to do, what was it? I just actually looked at it and of course forgot. In common or BASIC, you had to do something with, to let it know it was an integer or a float. Where is it at here? BASIC. Yeah, the dollars. I remember that part. Ah, OK. That's it. OK, got it. So I didn't know what I was doing. OK, OK. So in common or BASIC, which is what I used, if you don't put anything with the variable, it's going to assume it's an integer. Now in this particular version of BASIC, it doesn't matter. But it does matter in other versions. So then I can go ahead and type 50, print x. Or I could say 60, print, quote, the answer is, quote, plus x. And I could add maybe a little period at the end there. So let's go ahead and run that and see what we get. OK, so we can print it out just by itself. Or we can print it out as I did here. And this is kind of like Java, the way Java does it. And notice I didn't have to convert this to a string. It automatically converts it for us. So we have a space here. So so far so good. It's probably very similar to what you've done before. And then I'm going to go ahead and do a float. I'm going to say let a y equal, let's say 1.21. And then now we can see that this is a float. Again, in common or basic, I'd have to add a percent. And I wonder if that's going to work. Let's try that. So let's, sorry, print, quote, I should say y percent plus gigawatts. And see if that works. So we cannot do the percent with this particular version. And of course, it doesn't know what percent is there. So go ahead and run. And you can see we got 1.21 gigawatts. I'll put a space in there so it looks a little bit better. All right, so far so good. Again, in different versions of basic, you'd have to name your variables slightly differently. And but in this version of basic, it's a little bit more forgiving. So thank you to the developers who were kind enough to make it easy for us. Now, there are a number of math functions built into this programming language. So I'm just going to go ahead and do a few for you. So abs, and we could do absolute value of y. We could do print, what else can we do, int y. And in a lot of the older versions of basic, you would actually use floor instead of int. And what this does is it chops off the decimal point. So I go to run, and you'll see 1.21 gigawatts. The absolute value of 1.21 is still 1.21 because it's positive. And you can see here how int chops that off to a 1. However, if we wanted to round it, we could do, oops, round y. And now, of course, that's still going to be 1 because 1.21. But let's say if we change this to 7, we'll get a different result. So you can see how that rounded up to 2. But I'll put that back to 1.21. Gigawatts, a very important number in cinematic history. So let's see. We also have square root. So 1.10 print sqr of y. We have random. So I'm just going to go ahead and print random. This isn't necessarily about the variables, but it's something you'll use with these things. I'm going to go ahead and run it. Line number 1.10, repeat it so you cannot repeat a line number. So go ahead and run. And you'll see over here that we've got 1.1 is the square root. Apparently, the square root of 1.21 is 1.1, at least very close to that. And then we get a random number. So this rnd is a random number between 0 and 1, and which we can use later, you'll see, to get a random number, a random integer. And so one more thing we can do is we can do print val. And what that does is it converts a string, 3.141.59, into a float. So then what I could do is then I could multiply that. So this is a case where you're inputting something and you need to convert it to a number. You would use that. And then finally, for this section, we would want to do something along the lines of, if we wanted a random number, say, from 1 to 10, we would say print int rnd. Remember, that's from 0 to 0.99999. And we're going to multiply that by 10 and then add 1. Because what happens is the int cuts off the decimal part. And so it would normally give us 0 to 9, but we want 1 to 10, so we add 1. So we go ahead and run that. And you see we got 9. I'm going to try it again. Now we got 1. So you can see we get random values every time. So moving on, let's go ahead and do strings. So I'm going to go ahead and do 160. I'm going to say, R-A-M, strings. So 170. So I'm going to go ahead and create a string. Now again, I'm going to use let. Now in this particular version of basic, let is optional. But in a lot of them, it is not. So I'm going to say name equals. And I'm going to say Tokyo and tech, because that's me. Now again, in Commodore Basic, you would have to add a dollar sign at the end of that to tell the computer it's a string. And that may apply to other versions of basic. Actually, Commodore Basic was actually made by Microsoft. Little interesting little story there. How Jack Tramiel got a great deal on that. It's very interesting you should look it up sometime. So I can do things like print the length of name. So that hasn't really changed since the old days. And you can see the length of that is 11. So 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. 11, there we go. That's good. That's what we wanted. 190, we can go ahead and just print, you know, hi. I said, you know, hi, my name is. Notice I'm adding plus and then name and plus. But the period at the end. I don't need the parentheses. That's just a habit from doing mostly Python. Let's go take a look. And there we go. So we can print that out. So so far it's very, especially if you're coming from say Python or something like that, it's probably very, very similar. Now you notice how just as a habit, I did not capitalize print here. But go ahead and kick it old school and make it capitalize. Again, on an older computer, that might not work. But this is a kind of a modern interpretation of basic. So what I want to do next is I want to do some string functions. So there are a few string functions built into basic, most basic versions. And we've got three that we want to go over here. So I'm going to say print, print left, oops, capital. So print left, name two, I'm going to do 220, print right, name two, and 230, I'm going to say print mid name. And we'll do 2 comma 5 to see what that. Well, actually, yeah, let's do that one. Let's see if we can get that. So 2, 1, 2, 3, 4, 5. We'll do 5 and 6 and see what comes up. Let's try that. So I'm going to go ahead and run that. And again, if this was a Commodore, it would be left dollars, right dollars, and mid dollars. But it's not. OK. So you can see here we got tow because it's left. So the left two characters is tow. The right two characters is ch. And then we got edtech. So we started at 5. So we went from 0 as t, 1, 2, 3, 4, 5 as e, and then 6 characters. So if I just wanted ed, I would make it like this. And you can see we got ed. So now we could use mid as like substring. Or if we want to just pull out a single character, we could do like mid 5, 1. So that would give us e, because e is the fifth character, and we only want one character at a time. I'm going to put that back to 2. So that would be like a slice in Python. Yeah, that's pretty cool. Next up is we want to go ahead and do conditional statements. And these are if statements. So for example, watch what I do here. I'm going to say if. And this is very similar to what we've been doing. If I say if x equals 42. Now notice it is a single equal sign. So in basic, when you assign a value, it's one equal sign. When you compare values, it's one equal sign. Python, it's one for assignment and two for comparison. So here is the format. If something, then something else. So I'll say print, 42. And I can say else, print, that's print, not 42. So you can see how we got if, then else. And it's all one line, which is kind of interesting. So I'm going to go ahead and run that. And so x was 42. Let's go ahead and just change it just to see what happens and make sure it's working as expected. Not 42. Now in basic, I'm going to put that back to 42 because that's a more important answer. In basic, not equals looks like this. That is the old school kind of basic way of saying not equals. In Python, it would be exclamation point equals. But in basic, it's like this. You can also do greater than, you can do less than. You do greater than or equal to or less than or equal to. So it's very similar to modern programming languages, except for the not equal to is a little bit different than probably what you're expected to. Okay, move it on. This is a quick overview. So 60, or 260, we're going to do loops. And again, depending on the basic variant, you may or may not have while loops. I think a lot of the early basics just had four loops. But so I'm going to go with that. So I'm going to say 270. I'm going to say four I equals one, two, 10. I'm going to go ahead and hit enter. 280, let's say print I, I'm going to try I times two and just see what happens. I haven't tested that one yet. And then 290 is going to be next I. So a loop, so a for loop at least. So a definite for loop starts here. So we have a variable. We have a starting value and an ending value. We can also add step if we wanted to, like step two, for example. But let's try that and see what happens. Okay, you can see two. So print I comma I times two. Okay, that part didn't work. So what I think I have to do is print I plus quote, quote plus. And I'm going to put times two equals just for fun. Go ahead and see what happens. Okay, one times two is two, two times two is four, et cetera, et cetera. Notice it stops at nine. Okay, so that's just the way Python works as well. It will stop at one minus the maximum value here. And then you can see here I just used a print statement to kind of print that out nicely. And then you need the next I to tell it where the end of the for loop is. Python you would indent or in Java you would have a curly brace, but in basic you do not. So you can see how basically all these same concepts exist. Well, not all of them, but the basic concepts exist, but they're just done a little differently. And again, these line numbers are a little bit weird. We haven't really used them yet. We're going to in a little bit. Basic also has arrays. So this would be like a list in Python or an array in Java. So go ahead and do arrays. Now this is something that's varies widely from programming language or from basic version to basic version. In the old school kind of basic you had to do something called dimension. So you would have to do like dim, you know, x and then I forget the exact syntax and like say 10. So you would say, okay, I'm going to have an array called x and it's going to have 10 spots. So zero through nine. This particular version of basic doesn't require that. It has its own command called array and I'm going to call this scores. Also just, you know, like a lot of the early versions of basic you couldn't do like multiple, like the really early versions. I don't think you could do multiple characters in a variable name. Everything was like A, B, Z, D, E, F, G. I think, don't quote me on that. So, yeah, so I made an array called scores and then what I can just do is just probably what you're used to. Scores zero equals 75. Scores two, oops, I missed the zero. Scores one equals 85 and scores two equals, let's say 95. And then what I could do is just like we're used to probably in other languages, print, that's a hard habit to break. Scores, that's print, scores, let's say I wanted to print scores one and I should see 85 and we do see the 85. And this is where I could use a loop. I could say for I in range zero to three and print out all the scores just like I would with a list, say a list in Python. So, yeah, that's kind of the basic, basic stuff. So probably if you're thinking to yourself, well, what about functions? And this is where this is a really big difference between like old school basic and say modern programming languages. Something you may have noticed here is that all variables in old school basic, now there are new, there are modern versions that don't follow this, but this old school ancient type of basic, all variables were global. Okay, so, yeah, just think about that. I'll leave with that thought. So we couldn't really make functions, but what we could do was make subroutines. So for example, I'm gonna make a subroutine. And what kind of standard practice was to put it way down farther in the line numbers? And so for example, I can say print, this, you know, this is a subroutine. And then after you did a subroutine, you put return. So how this worked was I would do 360, I'm gonna say RAM subroutines. And I'll say 370, go sub 1000. So this line number here, so this means go to the subroutine located at 1000. So think of this as a function. Okay, I jump down to here and then when the function is done, I return. Now note, I am not returning a value. This is a very different statement. All this does is when the subroutine is finished. A subroutine can have 100 lines, doesn't matter. When it's done, jump back to where we started. And then what I'll do is here, I'll say 380, print, back to the main program. And then what I'll do is I'll go ahead and put line 990 in there and so it ends the program. So we gotta run that. You guys make that a little higher. Sorry, I should have done that earlier. So you can see we printed our 85, we got to go sub 1000. So the program jumps down to 1000, prints, this is a subroutine, returns back, goes to the next line, prints back to the main program and then we end it. Now if I didn't have this end in here, it would print this as a subroutine again. We'd probably get an error because there's nowhere to return to, okay? So that is how subroutines work, which is the modern or the old school equivalent to functions. But as you noticed, you can't pass a value to that because as I mentioned, all variables are global. So yeah, it's just, so this led to what was called spaghetti code and we'll talk a little bit more about one of the other jumping statements called go to in just a minute. So the last thing is, or one of the last things is user input. So how do I get input from the user? It's 390, R-E-M, I'll say user inputs. So what I might do is ask the user for their name, okay? So if I wanna do something like that, I could say 400, say name, sorry. Input, okay, what is your name? And I always like to put that little thing in there. And then watch, it's a semicolon and then the variable name. Again, on common words, this would have to be a dollar sign until it's a string. And then 500, oh sorry, 410, I could just say print, you know. Hi, name, very nice to meet you. And then, yeah, let's go ahead and run that. So what'll happen is the program stops just like it does like said in Python or some other program languages. Usually we have an input and you input whatever it is. So I'm gonna put my name is Tokyo EdTech and it's gonna say something nice. Hello, Tokyo EdTech, nice to meet you. And then what I can do here, and the last thing is I can use the same concept. I can say something like 420, 420. Input, would you like to continue? And usually you put like yes, no. And then I might say, you know, continue. That might be a keyword, so like C-O-N-T, continue. And then I might say 430, if cont, like continue equals Y, then go to, I'd say instead of continue, maybe try again, but go to it. And then basically what I'll do is I'll go back to the start. And so what I wanna do is I need a line number. So I would say go back to 20. If it's not, then we'll just go ahead and end. So it's gonna ask me for my name. I'm gonna say Tokyo EdTech. And hi, nice to meet you. Would you like to continue? I'm gonna type yes. And what should do is jump all the way back up to here. So this is how you would do like a while true loop essentially, you just do a go-to statement. Okay, you see it did it again. And Tokyo EdTech. And this time I'm gonna type no. And the program ends. And I think that pretty much covers the basic ideas of basic. Again, there's more to it. Now, if you look over here, this particular basic has a lot more functions than at least especially common or basic had. So there's a pretty good explanation of all these different commands and what everything does. And especially you'll see that there are, if then else, which we did, we did for two, we did step and next. We talked about step, we didn't really do it. Go sub and return, which we just talked about. This also has plot, display, draw. There's a bunch of different commands that are specific to this version of basic. So you can actually play some sounds and things like that. So it's pretty cool. And then there's some built-in functions. We talked about ABS. I didn't talk about cosine sign, but it's there as well. So you can kind of look at this page and see some different things that work. Yeah, it's pretty cool. Yeah, I guess whoever made this was really, really amazing. And yeah, thank you for making this. And there's a few things probably that I left out, but I think that covers it. Either there's an uppercase, which I don't recall common or basic having that. I think that wasn't common to all of them, but it's a very useful function. And then you can do some things with colors and getting characters and et cetera, et cetera. So yeah, check that out for more details, but that's basically a nice overview of classic, basic in, yeah, on replica. It's really nice of them to have this. Again, you do have to make a, how can I put it, you have to make an account, but you can go ahead and play with this. Now what I'm gonna do is I'm gonna go ahead and copy this and I'm gonna save this somewhere. And I'll put this into, I'll put a link to this down below somewhere. And I'm gonna save that as basic intro basic. It's really unfortunate that the color coding doesn't work, but this is what the color coding looks like in Genie. Unfortunately, in Genie, I can't run this because I don't have a basic interpreter on my computer. So what I wanna do, I'll tell you what, I'll just make a quick separate video for that. I was gonna do rock, paper, scissors, but let's stop this one and I'll make a quick separate video for that. Okay, so yeah, thanks for watching. Hope you enjoyed this little trip down memory lane and you can see how coding used to be done. This was, again, this was the basic, this was the Python of my era. This is what my generation grew up on. This is how most of us learned to code and we developed some bad habits, trust me, but this was it. It made computing accessible to the average person. And back in the day, like even math textbooks used to have basic programs. You could run and try out. There were all kinds of text-based games you could do. It was really, really a fascinating time and I was very lucky to have that opportunity and here I am, years and years later, talking to you guys about Python, Java and other things. Anyway, thanks again for watching. Click like if you're able to join. If you haven't subscribed, subscribe, click that bell and join the members. We'd like to see you, take care. And as I like to say, keep on coding.