Go Back   Gaming Gutter > Non-Gaming > Programming


Programming - All general programming discussion in here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post a game you wish they...
11-04-2008 12:37 AM
Last post by the_mrs
Today 02:25 PM
27 Replies, 165 Views
Go to first new post Fav Football Team?
11-19-2008 03:58 PM
by shep
Last post by the_mrs
Today 02:23 PM
17 Replies, 73 Views
Go to first new post When Should Kids Be...
09-11-2008 09:45 PM
Last post by Aethean
Today 02:22 PM
84 Replies, 844 Views
Go to first new post What's your weather?
11-08-2008 04:43 PM
by reirei
Last post by the_mrs
Today 02:22 PM
64 Replies, 384 Views
Go to first new post Trivia
11-19-2007 05:06 PM
Last post by girlikecupcake
Today 02:21 PM
413 Replies, 30,902 Views
Reply
 
LinkBack Thread Tools Display Modes

 [TRUE BASIC] Lesson I - Very basic functions
Old 09-26-2006, 01:57 PM   #1 (permalink)
Banned

Male Carnage is offline
 
Join Date: Sep 2006
Location: Saco, Maine
Age: 18
Posts: 1,879
GPoints: 380
iTrader: 1 / 100%
Carnage Is Popular
Rep Power: 0
[TRUE BASIC] Lesson I - Very basic functions

In this lesson, I will covor a few functions that are used in the program True Basic. This lesson will be covering VERY basic functions to get you started in this program.

First off, I would like to discuss the "Print" function. The print function is used to make your compiler show text in your output window. The proper way to use Print is when you are using a mathematical expression such as "4+1" or "4^2". When programming in True Basic, the variables you use to create a mathematical expression are as follows:


* - Multiply

/ - Divide
^ - To the power of
- - Subtract
= Equals (used when writing "Let" statements)
+ -Addition

When writing a mathematical expression, True Basic uses the order of operations, also known as "PEMDAS" (Perenthasis, Exponents, Multiplication, Division, Addition, Subtraction). When you are writing your code, you will need to use the order of operations if you want to use a long algebra problem. An example is this:

If you use the following code:

Quote:
Print 4+5+10*2
This will give you the answer "38" in the output window. This is fine if you are making an algebraic expression this way, but if you are trying to make your statement do 4+5 and then multiply that answer by 10*2, it will not do that. It will just do the operation number by number. If you want it to do the equation by parts, you need to use perenthasis. The code should look like this:

Quote:
(4+5)+(10*2)
This will tell the compiler to do 4+5 first and then add whatever 10*2 is, which happens to be 20. Your new answer will be "29" in the output window.

**NOTE** The compiler does not recognize multiplication inbetween parenthasis. If you were doing a problem such as 5+5*4+5, you would have to type this in the source window:

Quote:
(5+5)*(4+5)
If you type the following, the compiler won't know what to do with the product that it got from the parenthesis.

Quote:
(5+5)(4+5)
So ALWAYS remember to put an asterisk (*) inbetween your parenthesis.

END STATEMENT

And True Basic, like most other programs, you will need an "End" statement at the end of your code. If you don't have one, the compiler won't know what to do with the information you have put into the source window.

SEMICOLONS AND QUOTATION MARKS

When programming in True Basic, you need to use quotation marks when youm want specific text to show in the output window. If I want my output window to say "Hello everyone, my name is Brandon", I will have to wrap my text in quotation marks.

What do you think will happen when you type this code in the compiler?

Quote:
Print Hi my name is Brandon
END

If you said it will give you an error, you are correct. When entering text after a statement, you always use quotation marks because when you don't, the compiler will think you are trying to do a mathematical equation. The compiler notices that none of the letters from "Hi my name is Brandon" are one of the functions that are used in a math equation. The correct way to do this would be:

Quote:
Print "Hi my name is Brandon"
END
Now that you know when to use parenthasis, you need to know how to use semicolons. In True Basic, semicolons are used to tell the compiler that you are done with using quotations and want to do a mathematical equation. If you want your output window to say "The number of kids in the class is 5" and you want 5 to equal the answer of a mathematical equation, you will need to put a semicolon after your ending quotation mark. Here's what it should look like:

Quote:
Print "The number of kids in the class is"; 3+2
END
This will tell the compiler that you are done puting text in the output window and that anything after the semicolon will be a mathematical expression. You can also use more than 1 semicolon on a line of code. If you wanted the output window to say "I have 2 brothers that were both born in October" you would write the following code:

Quote:
Print "I have"; 1+1; "brothers that were born in October"
END

The semicolon not only says that you are done with your quotations, but it also tells the compiler that you are done with a mathematical equation.


USING LET STATEMENTS



In True Basic, when you are defining a variable, you use what's called a "Let" statement. Let statements are used to tell the compiler that anytime a certain phrase is used in your code, the output window will give it a specific value. Here's an example of using a Let statement.

Quote:
Let brother1 = 5
Let brother2 = 10
Print "I have 2 brothers. They were both born in October. The sum of my brothers ages combined are"; brother1+brother2
END
This will tell the compiler that when you type in brother1, it will give it the value "5" and when you typr brother2, it will give it the value "10". In your output window, you will get the following result:

Quote:
I have 2 brothers. They were both born in October. The sum of my brothers ages combined are 15
When using a let statment, it will define the variable for everything under that let statement and nothing above it. If you were to put the Let statement UNDERNEATH where your mathematical equation is, it will give you an error that you are not using a correct mathematical function because your compiler doesn't know what brother1 or brother2 is. When you use a let statement, it tells the compiler that brother1 = 5 and brother2 = 10.

If you want to assign brother1 and brother2 a different value for the coding after your "Brother sum" statement, you can define it again. If you want to assign brother1 as 6 and brother 2 as 11, your code will look like this:

Quote:
Let brother1 = 5
Let brother2 = 10
Print "I have 2 brothers. They were both born in October. The sum of my brothers ages combined are"; brother1+brother2
Let brother1 = 6
Let brother2 = 11
Print "My brother just had their birthday, the new sum of their ages is"; brother1+brother2
END
Since you defined brother1 and brother2 again, anything BELOW your newely defined variabled will be effected by this. All coding above the new let statement stays as it was before.

Now that I have explained some of the basic of True Basic, I hope that you have gained farther knowledge of the program. By reading this, you may even want to start programming in True Basic. Who knows? I hope to write more lessons in the future.

-EATME
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic MoneyMaker Guide V1.2 Medievil Maplestory Character Guides 80 10-26-2008 08:32 AM
Visual Basic.net Question Gendarme Programming 6 11-29-2006 10:03 PM
WOO! True Basic Lesson II is now out :D Carnage Chat 7 10-12-2006 07:43 PM
True Basic Lesson II Carnage Programming 2 10-12-2006 07:27 PM

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 02:26 PM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.09476995 seconds (100.00% PHP - 0% MySQL) with 20 queries