.:: Quick BASIC Beginner's Guide ::. By: infinite_reality aka `uN[In$tall]` Released under (T)he (G)oon (S)quad; April 2004; www.TGS-Security.com Contact: clientside@hotmail.com IRC: irc. zoite.net//#Hackerlounge//6667 Find me at: http://HackerLounge.no-ip.com http://lnx.hackerscenter.com/forums/index.php http://www.Brain-Hack.org/forum/index.php http://www.anomalous-security.org Shoutouts: To the fellas: R@v3n, asTHma, Mr.Mind, DJSplit, NoUse, Subby, Enjoi, D@MN3D, Shamus, sn4k3, Kevin, wkd, Messiah, Messiah's Mum, GluTuk, VBFavre69; all the good people at HackersCenter.com, Brain-Hack.org, AnomalousSecurity.org, and HackerLounge Forums; all my homies from {Dark`Nexu$}; and to The Goon Squad, TGS. Phuck you: To all those twats on Battle.Net that really believe they're going to send me a virus through the fucking game server; all those media-loving dickheads that deface webpages for no reason and then brag about it; all those monopolistic, greed-oriented companies that provide shit products for their shit customers, such as Micro$oft; G.W.Bush and his right-wing legion of fuckarse hypocrites. Lamers of the Week: [12:06:15 AM] i can get ip's and mess some1s pc up by sending them paketts [12:06:18 AM] << SocialEngineer >> Crash0verRide, you do realise that it was _just_ a movie, right? [3:16:25 AM] tell him if he dont stop im sending him a 9 year virrus ---- Contents: 0.0--Random shit 0.5--Getting QuickBASIC 1.0--Easiest Shit, CLS and PRINT (output) 2.0--Easy Shit, LET and INPUT (assignment and input) 3.0--Continued next episode... ---- 0--Random shit Since I have 6 hours before my next class today, I'm going to write about Quick BASIC, also known as QBasic. It's been a while since I've used this, about 4 or 5 years, so if there are any errors just let me know and I'll fix them up wicked quick. Or I'll rummage around for the old books in the crawlspace. Before we begin, let me warm my up with some background on Quick BASIC (QBasic, QB for short). QB is a programming language developed for 'puters back in 1975, by the infamous Bill Gates and Paul Allen--now the fellas at Micro$oft. It has been the accepted standard ever since for a few reasons: 1) it's not too hard to learn/use, 2) the syntax isn't too much like computer-jibberish language (unlike Assembly language, for example), 3) it's relate power under Micro$oft/Windows. QB stands for (Q)uick (B)eginner's (A)ll-Purpose (S)ymbolic (I)nstruction (C)ode. As you'll see through this guide, some of the commands are purely English, such as LET and PRINT. It has simple structure for the code: the lines are numbered in ten's (10, 20, 30...), and the code is executed (logically), down the list, line by line, in exact order. Sounds easy enough :) Some people choose to learn QB for no other reason than a starting point in programming (such as me and a mate). When you learn QB, you learn alot of the fundamental basics of other programming languages, and some of the same principals and even syntax (although nothing is _exactly_ the same). Other people learn it because it is not as hard as some other languages, and is relatively easy to make programs in. The last thing I like about it, is it's fun, and that's what's important-- enjoying yourself. ---- 0.5--Getting QuickBASIC Ok, time to begin. Unless you're running an older 'puter (like my P166mhz :D), with MSDOS and early Windoze (3.1/95/98), then you'll need to download a copy of QBasic because modern computers don't come with MSDOS (like they used to) or QBasic. This link has a few versions of QBasic: http://muratelic.sitemynet.com/qbasic/qb13.htm For this I'll be using QBasic 4.5. To run QBasic, open up the installed file QB.exe. The rest is pretty simple from there on: you should be able to see the menu accross the top, and blah blah etc. Just have a look around it to get a feel for it, then read on. ---- 1.0--Easiest Shit, CLS and PRINT (output) Who wants to say Hello to the World? Once you open up the QB.exe, you will be able to type in the big, empty screen. To start with, I'll give you HelloWorld!... just to be traditional :) To start a new program, just go to FILE|NEW. Just like you would with any other Windows document, use NEW, OPEN, LOAD, SAVE, SAVE AS..., etc, etc to do your functions. Now just type in the code to begin: [code] CLS PRINT"HELLO WORLD!" PRINT PRINT"And that's all..." PRINT [/code] And to run the code, press F5 (no need to save anything yet), and the output will be something like [quote] Hello World! And that's all... [/quote] Easy eh? So let me explain what's going on so you understand better. CLS basically stands for CLear Screen--which is what it does. That command will remove any outputted data above it, or, clear the screen when the code is run. PRINT should be pretty self-explanatory, as seen with the above code--it prints (outputs) data to the screen. A similar command for this would be cout (C++) or print (perl). One thing to note about PRINT, you must always have " around whatever you want to be outputted (is that a word?) to the screen. You don't need any "newline" commands, such as \n (C++, perl), or any "code block ends", such as } (C++, perl) to show the end of the code. Like I said, QB is a simple language. ---- 2.0--Easy Shit, LET and INPUT (assignment and input) Now on to QB variables, LET and INPUT. Like all variables, these ones are the same--blocks of memory that we can store specific data in (data being things such as $1.25, WordupG, 8420, etc, etc). And, as with all programming languages, QB has certain variables we can use: numbers and strings. Strings: A string is a set of characters--this guide uses lots of strings, or in not-quite-politically-correct-terms, words. Numbers: (similar to C++...) Numbers include four types: [short] integer, long integer, [short] floating-point, and long floating-point. [short] integer: integers require no symbol to introduce, but can be followed by a %. They range from -32,768 to 32,767. You don't need to use "short" in front of it either--if there is nothing in front of "integer" we just assume "short" is already written there (same as in Algebra, where x is really 1x, you just don't write the 1 in front). long integer: These integers are "longer", and range from -2,147,483,648 to 2,147,483,647. Big eh? Long integers are "introduced" with a & symbol. Now the question comes, as with all integer discussions, of why not just make everything "long", if "long" holds more data. The answer to that is, you should only use what memory space you need. If you don't _need_ to use "long", don't. Back when computers had small amounts of memory (not like today), and when QB was first out, memory preservation was key to using programs--so the rule has always stuck, to only use what you need. Floating-Point: Floating-point integers are able to use decimals. They can hold long deimal values, such as 3.14... or w/e pi is. And yes, there are [short] floating-point (introduced with a ! symbol) and long floating-point (introduced with a # symbol). Floating-point isn't used very often, unless you are doing very specific, need-to-be-accurate mathematical calculations involving decimal places. Now to use these integers, we use the commands LET and INPUT. I'll start with LET: [code] CLS PRINT"This will demonstrate the LET command :)" PRINT LET number = 1337 [/code] What this does is assigns the short integer variable "number" a value of 1337. You can also do such things as mathematical equations using LET. For example [code] LET haxxor = 1336 + 1 [/code] would assign the short integer variable "haxxor" a value of 1336 + 1, which is 1337. THe mathematical symbols are: * = multiply / = divide - = subtract + = add You can also do such mathematical functions as [code] LET number = number + 1 PRINT"and also use two variables in an equation like this" LET number = number + 1 - number [/code] Follow so far? Obviously now that you've got data in memory, the variables are assigned value, you want to be able to output it to the screen to see it. To do this you just simply use your regular output command, PRINT. For example [code] LET number = 1337 PRINT number PRINT PRINT"Or like this" LET haxxor = 1336 + 1 PRINT haxxor [/code] The output to the screen, after you press F5 to run the code, will be [quote] 1337 Or like this 1337 [/quote] If you want to make the variable show with it's value, you use the PRINT command like this [code] LET number = 1337 PRINT"Your number is"; number PRINT LET haxxor = 1336 + 1 PRINT"Haxxor's are"; haxxor [/code] Which outputs [quote] YOur number is 1337 Haxxor's are 1337 [/quote] Yes, that's all really simple stuff once you mess around and get a feel for it--so why don't you do that. Mess around and print different variables, try the different integer's, and see how you can use the code. After you're done, read on... To use the INPUT command, you do it similar to PRINT""; number. For example [code] INPUT name PRINT"Hi, my name is"; name$ INPUT age PRINT"Hi, my age is"; age [/code] The INPUT name would prompt the user for to input a string, in which case he/she would type in a name. NOTE: When using strings, or characters, you put a $ at the end of the variable name--you can see this in the code, with ; name$. You don't need to do this with any numeric values for a variable, which can be seen in the code with : age. Remember those two things, and the other symbols I mentioned up the top, and it'll all be fine. To make things look even snazzier, you can supply a prompt for the INPUT, like this [code] INPUT"Please enter your name.." name PRINT"Hihi, "; name$; "!" [code] You can see I did something a little different there that time--I put the variable in the middle of the sentence O.O! If you wish to do this, you must break the ouput with [code] PRINT"[output"; [variable[symbol]]; "[output]" [/code] And you can also see, when you run the code on this one, the output should look like this [quote] Please enter your name.. > Infinite Hihi, Infinite! [/quote] Yay, it said HiHi to me. So, that's the INPUT command and some ways to use it. Have a mess around with the INPUT, LET and PRINT commands to get used to them. I'll write the next guide up sometime in the week, and then we can all have more old-skool QBASIC MSDOS style fun. ---- 3.0--Continued next episode... More to come: - Arrays, and using: DIM, FOR...NEXT, STEP, GOTO, IF...THEN, and COLOUR - Using DO...LOOP, INT, RANDOMISE TIMER, SELECT, END SELECT, OPEN, CLOSE, RND, INPUT#, PRINT #, and INKEY # - Might do one or two more, not sure. Depends if I get a case of the L4ziEs or not 0.o ---- (c) Infinite, The Goon Squad (TGS), April 2004. http://www.TGS-Security.com Any questions, comments, shit like that, contact me at clientside@hotmail.com, or SystemAdmin@spymac.com