Staredit Network

Staredit Network -> Computers and Technical -> Programming Tutorial Collection
Report, edit, etc...Posted by DT_Battlekruser on 2005-09-18 at 02:42:05
Post your programming tutorials in this topic now, a link will be added from the first post. Here's mine.

Tutorial Index
C++

Basic Loops - Euro

PHP
PHP - Beginnings - Shmeeps
Reading .php Files - Slyence
MySQL Basics - RexyRex

Python
The Basics - DT_Battlekruser
GUIs in Tkinter - Cheeze

Visual Basic
Links to Tutorials - LegacyWeapon

Other
BrainF*** - Moose77



Getting Started in Python

1. The Very Basics

1.0 Materials

1.0.0 Download

Go here: http://www.python.org/download/ and download the Python program for your OS. Python works on Linux, Mac and Windows. Install Python.

1.0.1 Startup
Start the application in your Python folder called IDLE (Python GUI). Go to File and select New. A new window will appear for your program.

1.0.2 Save to Implement Coloring
Save your blank program to a desirable directory. Remeber to call the file something.py (you must type the .py). Code you type in will now by color-coded. Raw strings are green, system commands red, etc.


1.1 Basic Commands

1.1.0 The print Command
Type into your new program the following code:
CODE
print "Hello World"

Save the file and press F5 to run it. In the command shell, the program will print "Hello World" and end.

1.1.1 Variables
To declare a variable in Python, simply type the name of your variable, add an =, and set its value. To print a variable of "Hello World", use this code in your program.
CODE
text = "Hello World"
print text

Running the program will result in the same as in 1.1.0.

You do not need to declare variable type; you can switch a variable's type by redeclaring it. A few types of variables are:
Integers
Lists
Dictionaries
Floats
Strings
Tuples

1.1.2 Operators
The following operators can be used with variables in Python:
CODE
+     Adds two variables
-     Subtracts two variables
*     Multiples two numbers
/     Divides two numbers
+=   Adds (numbers) or appends (strings) one variable to another.
-=   Subtracts one number from another.


Try this code:
CODE
text = "Hello"
text += " World"
print text

Again the program prints "Hello World".

too tired to add to this, will later.

Meh, topic merging doesn't like me, resubmit the tuts up here.
Report, edit, etc...Posted by Kashmir on 2005-09-18 at 06:44:36
what!? no modulus? What about a character at the end of statements, such as a ";". The modulus is the pimp of c++. Also an operator "%". A modulus can tell you whether a number is odd or even, can be used to find factors of a number, and it also divides and returns the remainder. Pretty nifty smile.gif The following program is in C++ just to show you how it works.

CODE
#include <iostream>
using namespace std;
int main()
{
 int some_value;
 std::cout << "Enter a value: ";
 std::cin >> some_value;
 if ( some_value % 2 == 0 )
 {
   std::cout << some_value << " is an even number" << endl;
 }
 else
 {
   std::cout<< val << " is an odd number" <<<< endl;
 }
}

Pretty much the #include and using are just pre-requisites of the program telling ti where to find some code for the commands, the "int main()" is the main function. Then the program has you enter a number and it uses modulus by 2. If its even it says so ELSE it says its odd.
Report, edit, etc...Posted by Slyence on 2005-09-18 at 09:04:03
I guess I will type up a simple users online script...


This requires no MySQL database! it just writes to a .php file. to put it into your web page use this code:
CODE
<?php include(counter.php); ?>

CODE
<?php
//vars
$file_name = "whois_online.dat.php";  
$c_time = time();  
$timeout = 300;  
$time = $c_time - $timeout;  
$ip = getenv("REMOTE_ADDR");  

if(!file_exists($file_name)){  
$fp = fopen($file_name, "w");  
fwrite($fp, "<?php die('Restricted File');?> \n");  
fclose($fp);  
}  

//write to file
$fp = fopen($file_name, "a");  
$write = $ip."||".$c_time."\n";  
fwrite($fp, $write);  
fclose($fp);  

//open file to as array, to count online
$file_array = file($file_name);  
$online_array = array();  
for($x = 1; $x < count($file_array); $x++){  
list($ip, $ip_time) = explode("||", $file_array[$x]);  
if($ip_time >= $time){  
array_push($online_array, $ip);  
}  
}//end for

$online = array_unique($online_array);  
$online = count($online);  
if($online == "1"){  
print "User online: $online"."<br>";  
}else{  
print "Users online: $online"."<br>";  
}  
?>


Easy enough?
Report, edit, etc...Posted by LegacyWeapon on 2005-09-18 at 10:15:14
First you need to get VB:
http://msdn.microsoft.com/vbasic/gettingstarted/getvb/
Now people get can VB Express and learn everything through those guides. Otherwise read on.

Anyone and everyone learning Visual Basic needs a reference book. If you can't get one then you can always use the reference here:
http://msdn.microsoft.com/library/default....cLROverview.asp
Make sure to read through all the functions (skimming is fine). Visual Basic is quite a simple language to learn. It's a lot like BASIC so if you've ever programmed your TI calculator, then you already know most of the functions.

I recommend everyone should go to:
http://www.vbtutor.net
Lessons 15-22, you really don't need to read. But they do teach you how to use components (most components come with instructions anyways).
Here is one of my first programs I have ever made:
Attached File aray.zip ( 6.76k ) Number of downloads: 2


After learning the basics and you want to start doing stuff with Starcraft maps, I recommend you download the sourcecode for WinMPQ:
http://shadowflare.gameproc.com/dwnload.html#WinMPQ

After learning how to use MpqControl:
http://shadowflare.gameproc.com/dwnload.html#MpqControl

You can find out about the scenario.chk file specifications here:
http://www.campaigncreations.org/starcraft...chkformat.shtml
Report, edit, etc...Posted by CheeZe on 2005-09-18 at 10:45:07
For those who want to learn some basics of GUI in Python:

This is using the default tkinter, which is included with python after installation.

Basically, it's a project I quit after I got all the basics too work. It works just like Notepad, it can open and save text (or anything else) and display and edit. tongue.gif

CODE
from Tkinter import *
from ScrolledText import ScrolledText
import tkFileDialog
import tkMessageBox

fileTypes = [ ("Text files","txt") , ("All files","*") ]

class Notepad:
   def __init__(self):
       self.isModified = True  #Set to False whenever the TextArea is changed
       self.fileName = None
       self.createGUI()

       #Commands for File Menu
   def fileNew(self):
       if self.isModified == True:
           if tkMessageBox.askyesno( title = "Notepad" ,
                                     message = "The text in the file has changed\n \nDo you want to save the changes?" ):
               self.fileSave()
       self.textArea.delete( 1.0 , END )
       self.isModified = False
   def fileOpen(self):
       fileName = tkFileDialog.askopenfilenames( defaultextension = ".txt" ,
                                                 filetypes        = fileTypes )
       try:
           openFile = open( fileName[0] , "r" ).read()
       except IOError:
           return
       self.textArea.delete( 1.0 , END )
       self.textArea.insert( END , openFile )
       self.isModified = False
   def fileSave(self):
       print self.fileName
       if self.fileName == None or self.fileName == "":
           self.fileSaveAs()
       else:
           self.saveFile( self.fileName )
   def fileSaveAs(self):
       self.fileName = tkFileDialog.asksaveasfilename( defaultextension = ".txt" ,
                                                       filetypes        = fileTypes )
       if self.fileName == None or self.fileName == "":
           return
       print self.fileName
       self.saveFile( self.fileName )
   def filePageSetup(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def filePrint(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )

       #Commands for Edit Menu
   def editUndo(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editCut(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editCopy(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editPaste(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editDelete(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editFind(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editFindNext(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editReplace(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editGoTo(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editSelectAll(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def editTime(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )

       #Commands for Fortmat Menu
   def formatWordWrap(self): ###############CURRENTLY NOT WORKING###############
       if self.wordWrap.get():
           self.textArea.tag_config( Wrap = WORD )
       else:
           self.textArea.tag_config( Wrap = NONE )
   def formatFont(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )

       #Commands for Help Menu
   def helpTopic(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )
   def helpAbout(self):
       tkMessageBox.showinfo( title = "Notepad" ,
                              message = "This Feature Not Yet Available" )

       #Actions the Window should do
   def saveFile( self , fileName ):
       try:
           newFile = open( fileName , "w" )
           newText = self.textArea.get( 1.0 , END )
           newFile.write( newText )
           newFile.close()
           self.updateWindow()
       except IOError:
           return
       self.fileName = fileName
   def updateWindow(self):
       self.root.title( self.fileName )

   def createGUI(self):
       self.root = Tk()
       self.root.title( "Untitled" + " - Notepad" )
       mainFrame = Frame( self.root )
       menuBar = Menu( self.root )

       #Adding File Menu
       fileMenu = Menu( menuBar , tearoff = 1 )
       fileMenu.add_command( label = "New" ,
                             underline = 0 ,
                             command = self.fileNew        )
       
       fileMenu.add_command( label = "Open..." ,
                             underline = 0 ,
                             command = self.fileOpen       )
       
       fileMenu.add_command( label = "Save" ,
                             underline = 0 ,
                             command = self.fileSave       )
       
       fileMenu.add_command( label = "Save As..." ,
                             underline = 5 ,
                             command = self.fileSaveAs     )
       
       fileMenu.add_separator()
       
       fileMenu.add_command( label = "Page Setup" ,
                             underline = 8 ,
                             command = self.filePageSetup  )
       
       fileMenu.add_command( label = "Print..." ,
                             underline = 0 ,
                             command = self.filePrint      )
       
       fileMenu.add_separator()
       
       fileMenu.add_command( label = "Exit" ,
                             underline = 1 ,
                             command = lambda: root.destroy(self))
       
       menuBar.add_cascade(  label = "File" ,
                             underline = 0 ,
                             menu = fileMenu               )

       #ADding Edit Menu
       editMenu = Menu( menuBar , tearoff = 1 )
       editMenu.add_command( label = "Undo" ,
                             underline = 0 ,
                             command = self.editUndo       )
       
       editMenu.add_separator()
       
       editMenu.add_command( label = "Cut" ,
                             underline = 2 ,
                             command = self.editCut        )
       
       editMenu.add_command( label = "Copy" ,
                             underline = 0 ,
                             command = self.editCopy       )
       
       editMenu.add_command( label = "Paste" ,
                             underline = 0 ,
                             command = self.editPaste      )
       
       editMenu.add_command( label = "Delete" ,
                             underline = 2 ,
                             command = self.editDelete     )
       
       editMenu.add_separator()
       
       editMenu.add_command( label = "Find..." ,
                             underline = 0 ,
                             command = self.editFind       )
       
       editMenu.add_command( label = "Fine Next" ,
                             underline = 5 ,
                             command = self.editFindNext   )
       
       editMenu.add_command( label = "Replace..." ,
                             underline = 0 ,
                             command = self.editReplace    )
       
       editMenu.add_command( label = "Go To..." ,
                             underline = 0 ,
                             command = self.editGoTo       )
       
       editMenu.add_separator()
       
       editMenu.add_command( label = "Select All" ,
                             underline = 7 ,
                             command = self.editSelectAll  )
       
       editMenu.add_command( label = "Time/Date" ,
                             underline = 6 ,
                             command = self.editTime       )
       
       menuBar.add_cascade(  label = "Edit" ,
                             underline = 0 ,
                             menu = editMenu               )

       #Adding Format Menu
       formatMenu = Menu( menuBar , tearoff = 1 )
       self.wordWrap = BooleanVar()
       
       formatMenu.add_checkbutton( label     = "Word Wrap" ,
                                   underline = 0 ,
                                   variable  = self.wordWrap ,
                                   command   = self.formatWordWrap )
       
       formatMenu.add_command( label = "Font..." ,
                               underline = 0 ,
                               command = self.formatFont   )
       
       menuBar.add_cascade(    label = "Format" ,
                               underline = 0 ,
                               menu = formatMenu           )

       #Adding Help Menu
       helpMenu = Menu( menuBar , tearoff = 1 )
       helpMenu.add_command(   label = "Help Topics" ,
                               underline = 0 ,
                               command = self.helpTopic    )
       
       helpMenu.add_separator()
       
       helpMenu.add_command(   label = "About Notepad" ,
                               underline = 0 ,
                               command = self.helpAbout    )
       
       menuBar.add_cascade(    label = "Help" ,
                               underline = 0 ,
                               menu = helpMenu             )
             
       self.root.config( menu = menuBar )

       self.textArea = ScrolledText()
       self.textArea.pack( fill = BOTH , expand = YES )
       self.textArea["font"] = "Courier"

       mainFrame.pack()
   def Run(self):
       mainloop()

if (__name__=="__main__"):
   Notepad().Run()



Good tutorial and examples for how each widget works:
http://www.pythonware.com/library/tkinter/introduction/
Report, edit, etc...Posted by Shmeeps on 2005-09-18 at 11:49:27
I for one think this is a little stupid. The tutorials will be out of order and people will have to search for the ones that they want. You should allow for new topics for new tutorials.
Report, edit, etc...Posted by DT_Battlekruser on 2005-09-18 at 12:58:15
The index is up top, just click on the link to the tutorial you want.
Report, edit, etc...Posted by Shmeeps on 2005-09-18 at 15:13:29
M'kay, that's better then.




PHP: Beginners

To start off, let's explain exactly what PHP is.

PHP: PHP (PHP: Hypertext Preprocessor) used to stand for Personal Home Page, was created by Rasmus Lerdorf in 1994. It was a set of Perl Scripts to track visitors to his site. Later, he revised it with a Form Interpreter (FI) and released it again in 1996 as PHP-FI. Two people named Zeev Suraski and Andi Gutmans made the API, the PHP parser that became PHP3 in 1998. It was later updated as PHP4 with the Zend Engine to allow for scripting to be used with any combination of Web Server, Browser, and OS.

What it does: PHP a server side web language. Server side languages are run on the web server, so it is OS universal, and you don't need to download anything to run it. PHP uses commands to alter the file that the web server sends to a client computer before it is sent. This way, ceratin things, like data in a file, or the time, can end up showing up different things.

Getting Started:

--1.0: Basics and Echos.

CODE

<?

echo(" Hello World ");

?>


This is a really simple piece of code. To start off PHP code, you have to use <?, <?php, or <script language="php">. The most common used is <? or <?php.

The function echo(); will display text on the page. There's a few things you have to know about it.

If you use echo(" Bob said "RAWR"! ");, it will NOT work. There are four "'s in there. It is reading it as Opening, closing, opening, and closing, which cannot happen in a function. There's two ways around this.

echo(" Bob said \"RAWR\"! ");
or
echo(' Bob said "RAWR"! );

The first makes the inner two quotes escape, they aren't read as closing the function. The second uses single quotes, so the double quotes don't close the function.

Remember, that ALL functions must be closed with a semi-colon ( ; ).

--1.1: Variables.

CODE

<?

$variable = "rawr";

echo(" Bob said $variable ");

?>


Variables are much easier in php then most languages. In C++, you have to declare the variable type too, but in PHP, you don't. Variables also don't have to be decalred, and can switch between types.

To set a variable, use $(Variable Name) = "Thing to set it to"; You can set them to strings ("Hi there, my name is bob!"), numbers (1, 2, 3), booleans (TRUE, FALSE), or floating points (3.1246135).

A few things about variable names. You can not use a variable that has any of these names. Also, no name can start with a number ($1rawr) and none can have spaces ($rawr rawr).

There's a few ways to echo a variable:

echo(" Variable: {$variable} ");
echo(" Variable: $variable "):
echo(' Varaible: '.$variable.' ');

Variables are case sensitive, meaning $RAWR and $rawr are NOT the same.

--1.2 Comments.

CODE

<?

echo("Hello World");

//This wont be parsed.
#Neither will this.
/*Or this,
Or this*/

?>


Comments can be declared with #, //, or /* */. # and // are single line comments. Anything you write until you hit enter wont be parsed. /* */ are multi line comments. Until you type a */ after a /*, nothing of that will be parsed.

--1.3 Operators

-Arithmetical Operators
CODE

$sum = $one + $two;
$difference = $one - $two;
$product = $one * $two;
$quotient = $one / $two;
$modulus = $one % $two;
$increment = $one++;
$decrement = $two--;


These are simple. Adding, subtracting, multiplying, deviding, multiplying, increment, decrement.

Modulus divides the numbers, and return the remainder of the operation.

Increment and decrement add or subract one.

-Logical Operators
CODE

&& / AND
|| / OR
XOR
!


&& and AND evaluate the the operands and return true only if BOTH operatives are true.

|| and OR evaluate the two operands and return true only if only one, or both are true.

XOR evaluates the operators and returns true only if ONE of the operands returns true.

! (NOT) evaluates the operands and returns true only if BOTH of the operands are false.

-Assignment operators
CODE

= ($a = $b)
+= ($a += $b)
.= ($a .+ $b)
-= ($a -= $b)
*= ($a *= $b)
/= ($a /= $b)
%= ($a %= $b)


The first two, (Skipping =, we know what that does (hopefully wink.gif)) += and .= are adding operators.

+= is used for numbers, it is equivalent to ($a = $a + $b).

.= is used for strings. It will attach the second string to the end of the first.

-= is equal to ($a = $a - $b)

I think you should get it by now wink.gif

-Comparison Operators
CODE

if ($a == $b)
if ($a != $b)
if ($a > $b)
if ($a < $b)
if ($a >= $b)
if ($a <= $b)


The if function tests the operands, and preforms the operations if true is returned.

== checks if the operands are equal.
!= checks if the operands are not equal.
> checks if the first operand is greater than the second one.
< checks if the first operand is less than the second one.
>= checks if the first operand is greater than or qual to the second one.
<= checks if the first operand is less than or equal to the second one.

Remember to use == and not = when checking if two variables are equal.

--1.4 Functions.

CODE

<?

function line()
{
echo("<hr />");
}

function add( $arg, $arg2 )
{
$sum = $arg + $arg2;
return $sum;
}

line();
$sum = add(1, 2);
echo($sum);
line();

?>


Functions are set, then called. Whatever things are in the function are executed everytime the function is called.

If you give the function arguments, (function add), then it will modify the arguments, Use the return statement to return a variable (For $a = function()wink.gif.

--1.5 Statements.

-If Statement
CODE

$a = 1;
$b = 1;
if($a == $b)
{
echo("They're Equal ^_______________________^");
}


This is simple. It checks the two variables (In this case, if they are equal) and if they are, it preforms the operation (In this case, the echo function).

-If-Else and Else
CODE

$a = 1;
$b = 2;

if($a > $b)
{
echo("Variable a is greater than variable b");
}
elseif($a < $b)
{
echo("Variable b is greater than variable a");
}
else
{
echo("Dude, that's messed up....");
}


The elseif is used after an if statement to provide alternative code if the if statement is proven false. The else (Elseif without evaluation) function is used after an if or elseif function, and provides code if NONE of the if/elseif functions are proven true.

-Switch Statement
CODE

$num = 2;
switch($num)
{
case 1 : echo("Variable equals 1"); break;
case 2 : echo("Variable equals 2"); break;
default : echo("This shouldn't happen");
}


The switch statement is used to evaulate a variable against several different things at once. It's like compacting an ifelse statement. If checks whatever is after the case, and if a match is found, preforms all the functions after the colon. Always add a break; after the functions, or else every case will execute. The default case is used if no match is found.

-While Loop
CODE

<?

$i = 0;
$num = 50;

while($i < 10)
{
$num--;
$i++;
}
echo("Loop ended at {$i}, \n \$num is now $num");
?>


A while loop will continue to loop until the statement is proven false. Every statement inside will be executed as it goes.

-Do-While Loop
CODE

$i = 0;
$num - 50;

do
{
$num--;
$i++;
}
while($i<1);

echo("Loop stopped at {$i}, \n \$num is now $num");


This is the same as a while loop, except the statements are executed before the check statement. So the functions will ALWAYS be executed once.

-For loop
CODE

$a = 0;
$b = 0;
for( $i=0; $i<5; $i++ )
{
$a += 10; $b += 5;
}

echo("At the end of the loop, a = $a and b = $b");


A for loop is usually the most used loop. This is the syntax

for( INITIALIZER; TEST; INCREMENT).

Where initializer is what the variable starts at, test is what the for loop tests, and increment is how much the variable goes up.

-Interupting and Continuing loops
CODE

break;
continue;


Break and Continue are used to stop and start loops. I've never used continue, so I really don't know much about it, but the break statement can be used to like, make sure a loop only loops five times, ect.



These are some basic functions for PHP. I'll post some more advanced tutorials later. If anyone has any questions, feel free to ask them here wink.gif





EDIT: Someone needs to fix the addtion part of this, so I don't have to post 20 tutorials per post. Maybe add something in the tutorials database for these, or enable double posting in this forum?
Report, edit, etc...Posted by Slyence on 2005-09-19 at 22:06:57
[center]Your first PHP-enabled page[/center]

Create a file named slyence.php and put it in your web server's root directory (DOCUMENT_ROOT) with the following content:
Example 2-1. Our first PHP script: slyence.php
CODE
<html>
<head>
 <title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello Slyence</p>'; ?>
</body>
</html>

Use your browser to access the file with your web server's URL, ending with the "/slyence.php" file reference. When developing locally this URL will be something like http://localhost/hello.php or http://127.0.0.1/slyence.php but this depends on the web server's configuration. If everything is configured correctly, this file will be parsed by PHP and the following output will be sent to your browser:
CODE
<html>
<head>
 <title>PHP Test</title>
</head>
<body>
<p>Hello Slyence</p>
</body>
</html>

This program is extremely simple and you really did not need to use PHP to create a page like this. All it does is display: Hello Slyence using the PHP echo() statement. Note that the file does not need to be executable or special in any way. The server finds out that this file needs to be interpreted by PHP because you used the ".php" extension, which the server is configured to pass on to PHP. Think of this as a normal HTML file which happens to have a set of special tags available to you that do a lot of interesting things.

If you tried this example and it did not output anything, it prompted for download, or you see the whole file as text, chances are that the server you are on does not have PHP enabled, or is not configured properly.Make sure that you access the file via http with the server providing you the output. If you just call up the file from your file system, then it will not be parsed by PHP.

The point of the example is to show the special PHP tag format. In this example we used <?php to indicate the start of a PHP tag. Then we put the PHP statement and left PHP mode by adding the closing tag, ?>.

Now that you have successfully created a working PHP script, it is time to create the most famous PHP script! Make a call to the phpinfo() function and you will see a lot of useful information about your system and setup such as available predefined variables, loaded PHP modules, and configuration settings. Take some time and review this important information.

Example 2-2. Get system information from PHP
CODE
<?php phpinfo(); ?>
Report, edit, etc...Posted by DT_Battlekruser on 2005-09-20 at 02:57:19
http://localhost will always get you to your computers apache server. Don't know where you got 127.0.0.1 though.
Report, edit, etc...Posted by Shmeeps on 2005-09-20 at 18:20:01
That's the loopback IP, same as localhost.
Report, edit, etc...Posted by RexyRex on 2005-09-30 at 00:26:15
Eww, Slyence, .txt files sad.gif.
PHP - MySQL basics.
http://www.php.net/download_docs.php - You are going to love this. I do. smile.gif

Anyways, here are some basic MySQL things to play with.
Note that I'm doing this off of memory so bear with me on a couple mistakes, I'll come back and fix this post when I have the PHP manual (and time) handy. smile.gif
CODE

// Define username, host, and password constants.
define(MYSQL_USERNAME, "root");
define(MYSQL_PASSWORD, "");
define(MYSQL_HOST, $_SERVER['HTTP_HOST']);

// Connect.
@mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD)
or die("Error: Connection failed. MySQL returned: <br />".mysql_error());

// Query.
$query = "CREATE DATABASE rexyrex_is_cool";
$result = mysql_query($query);

// Check to see if the query was sucessful.
if($query)
echo("Query successful.");
else
echo("Query failed. MySQL returned: <br />".mysql_error());


Bleh. Have to go sleep. I'll finish later. smile.gif
Report, edit, etc...Posted by Doodle77(MM) on 2005-10-30 at 14:15:41
BrainF*ck links:
http://esoteric.sange.fi/brainfuck/compiled/win/DBFI.zip - BrainF*ck interpreter
Another interpreter
BrainF*ck compiler
(Don't get me for censor evasion, thats the web address and the censors messed up the URL)
Note: This programming language will piss you off, i have no idea how anyone manages to make a program longer than like 50 characters.
Also note: BF is fast as hell, running the program "+[[[+]+]+]" it managed 20,122 commands per millisecond in the interpreter.

[center]BrainF*ck[/center]


Brainf*ck is like Othello, easy to learn, really hard to master. It is a simple programming language. It has 8 commands, those commands are:
CODE
>  Increment the pointer.
<  Decrement the pointer.
+  Increment the byte at the pointer.
-  Decrement the byte at the pointer.
.  Output the byte at the pointer.
,  Input a byte and store it in the byte at the pointer.
[  Jump forward past the matching ] if the byte at the pointer is zero.
]  Jump backward to the matching [ unless the byte at the pointer is zero.

A simple BF program would be:
CODE
+[,.]

That would mean:
1. Increment the byte at the pointer to make it 1
2. Start the loop, since the byte at the pointer is no longer 0, it wont skip over.
3. Input a character and put it at the pointer
4. Output that byte
5. If you input 0, end the loop
Basically what this program does is it takes an input character and outputs it. if you use the compiler, then this will look like doubling up characters.
Unfortunately, its not easy to input a NULL character(well, technically if you were using the compiler you could just input a non-returning character).
To fix that, make the program this:
CODE
+[,.-----------------------------------]

Now, after it outputs the byte, it subtracts 35 from it, making it so that when you input "#" the program will exit.
Ok now onto a more complicated program:
CODE
-----------------------------------[>,-----------------------------------]<[++++++
+++++++++++++++++++++++++++++.<],

This program says:
1. Subtract 35 from the byte at the pointer, making it 221
2. Start a loop
3. Move the pointer forward 1.
4. Input a byte
5. Subtract 35 from the byte at the pointer
6. End the loop
7. Move the pointer back one
8. Start another loop
9. Add 35 to the byte at the pointer(which restores it to its normal form)
10. Output the byte at the pointer.
11. Move the pointer back one.
12. End the loop if the byte at the pointer is 0( the only case in which this will be true is if you are past the byte you started at. )
13. Input a byte at the pointer. This is just for if you are running a compiled version of this program on Windows, so you have a chance to look at the output before the window closes.
Sample input/output from this program:
CODE
Input:oleholehPIE#
Output: EIPhelohelo

Note the space(technically a null char) after the output, this is the point of the 35 minuses, at least one is required so the loop doesnt skip over and if you had only one then you would get a " instead.
If you want to learn more, heres a little hint.
If you need to add/subtract something large from the byte at the pointer, you can use a counter. for example if i wanted to subtract 97 from the byte, i could say:
CODE
+[,>++++++++++[-<----------->]<--- [.>>>]]

This code checks to see if you inputed "a" and then prints a null if you didnt.
CODE
>++++++++++[-<----------->]<---

This part of the code goes forward so you dont override the output, adds 9 to the byte(i call this byte the counter) starts a loop, subtracts one from the counter, goes back to the inputed byte and subtracts 10 from it. because of the counter, it loops through it 10 times.
Report, edit, etc...Posted by Demon on 2006-07-07 at 14:59:43
Eh, for all those who havn't heard of it-

http://poignantguide.net/ruby/
http://pine.fm/LearnToProgram/

It's interesting, easy to learn. The only thing I don't like about it is that noone knows about it ><.
Report, edit, etc...Posted by Xx.Doom.xX on 2006-07-07 at 16:11:58
Before i would enter either a CSS or an HTML tutorial, does this have to be written yourself or a link to another site? I think i should write my own tut considering everone else has. Just checking smile.gif

Ill write up my own soon, but heres a link when i first started HTML and CSS

Html and CSS Tuts <html.net>

QUOTE(LegacyWeapon @ Sep 18 2005, 10:14 AM)
First you need to get VB:
[url=http://msdn.microsoft.com/vbasic/gettingstarted/getvb/]

*shortened

Does VB6 cost anything? I havnt learned much of it and trying to learn more. I was using the VBscript just for a beginning and i wanted to get VB6. My dad said it was a couple $100's. Is this true or is it free? (I couldnt find a price on microsoft if there is one)

Also how does PHP and HTML Different? Im hoping to learn a little bit more a PHP this week.
Report, edit, etc...Posted by Killer_Kow(MM) on 2006-07-17 at 11:57:26
Could someone explain why I am not authorized to view this site?http://msdn.microsoft.com/vbasic/gettingstarted/getvb/
Report, edit, etc...Posted by Xx.Doom.xX on 2006-07-17 at 20:34:03
Cause it doesnt exist. Go to this link

Get VB express

Report, edit, etc...Posted by Killer_Kow(MM) on 2006-07-18 at 18:12:08
I already got it, so it doesn't matter tongue.gif
Next Page (1)