Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

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

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Pteri - Darigan available
Today 05:15 PM
by ftw
Last post by ftw
Today 05:15 PM
0 Replies, 1 Views
Go to first new post Let us play pokemon!
Yesterday 03:57 AM
by Kyo
Last post by Hale'iwa
Today 05:15 PM
87 Replies, 462 Views
Go to first new post Post Your Picture
10-09-2006 11:34 PM
by Ryan
Last post by Boink
Today 05:13 PM
8,066 Replies, 112,586 Views
Go to first new post So....I think I have...
Yesterday 07:49 PM
Last post by LordGrievous
Today 05:13 PM
22 Replies, 144 Views
Go to first new post [S] Amazing Main + 9mil
10-11-2008 01:40 PM
Last post by careousel
Today 05:13 PM
7 Replies, 91 Views
Reply
 
LinkBack Thread Tools Display Modes

 [TRUE BASIC] Add an access code
Old 12-04-2006, 06:01 AM   #1 (permalink)
Banned

Male Carnage is offline
 
Join Date: Sep 2006
Location: Saco, Maine
Age: 17
Posts: 1,879
iTrader: 1 / 100%
Carnage Is Popular
Rep Power: 0
[TRUE BASIC] Add an access code

In this short tutorial, you will learn how to add an access code to your True Basic program.

First of all, start True Basic

What you want to do first is execute your loop statement. To do so, enter "Do" into True Basic. This will tell the compiler that you wish you begin a loop.

Now what you want to do is give the user a way to enter the code. To do so, we will be using an Input Prompt. Input Prompt is a statement that allows you to combine a Print statement and an Input statement into 1 line of code. To do so, enter the following code:

Quote:
Input prompt "Code: ": code$
In past lessons, you have learned that you need to use a dollar sign ($) which initiates a string variable. If your code is NOT a word, you can remove the dollar sign. If you have any letters in your code, you will need to add the dollar sign.

Now we need to initialize an if statement. If statements are used to look at the variable you are comparing and see if the condition is true or false. In this case, we will be using an "equal to" if statement. To do so, enter the following code:

Quote:
If code$ = "open" then
Where "open" is, you will replace it with the code that you would like to protect your program with. In this case, I have used "open" as my code.

Not we need to tell the compiler what to do if the if statement is true.

Enter the following code:

Quote:
Print "ACCESS APPROVED!"
You can put anything you would like in the print statement, but try to make it say something along the lines of "Approved" or "You're in" because the user needs to know if they have accessed the program or not.

Now we need to tell the compiler what to do if the if statement is false. To do so, we will be using an else statement. Enter "else" into a new line of code and then press enter.

Now we need to tell the compiler what to do when the condition is false. To do so, we will use another print statement:

Quote:
Print "ACCESS DENIED"
Again, you can enter anything you'd like for this print statement. Since we've finished our if statement, we need to end it. To do so, enter "end if" on a new line of code.

Now we need to execute a loop statement. To do so, enter the following code:

Quote:
Loop until code$ = "open"
Since my code is "open", I have told the compiler to loop all of the data underneath the "Do" statement until the condition (code$) is true. Where "open" is, you would enter what ever value you assigned for code$.

Add this to the beginning of your program for a fast and simple code required access.

Your final product should look like this:

Quote:
DO
INPUT prompt "Code: ": code$
IF code$ = "open" then
PRINT "Access approved!"
ELSE
PRINT "ACCESS DENIED!"
END IF
LOOP until code$ = "open"
WRITTEN BY FICTICIOUS ON DECEMBER 4TH, 2006

Last edited by Carnage; 12-04-2006 at 06:06 AM. Reason: Added final product
  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

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 05:18 PM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.14660192 seconds (100.00% PHP - 0% MySQL) with 19 queries