Jackson Hines
This user hasn't shared any biographical information
Homepage: http://www.atomicpages.net
Posts by Jackson Hines
Basic Unix Commands – Part 1
Jun 8th
Similar to using DOS in windows, in Linux and Mac OS X operating systems, you can use the terminal using Unix Commands. Here I will just quickly highlight the basics of how to use unix commands.
Once you open the terminal, you can start typing commands. After typing a command hit the enter key to execute it. When a command is finished executing it will display another prompt where it will wait for another command. Some commands will output things into the terminal window and others won’t.
Navigating the File System
Using unix commands, you can navigate through all your files and folders using just text. When you open a terminal window you start in your user account’s home directory. If you type the command ls you will see all files and folders within your home directory listed.
Unix commands also have options that you can set on them. For example the command ls -l would also list all your files but include more information like size and date.
Changing your current directory
To change your current direction you use the command cd [directory]where [directory] is the path to the directory you want to move to. For example if my current directory contains a folder called “Documents” and I want to move into this folder I would type cd Documents.
The command cd .. would move me to the parent directory of the current directory and cd ../../ would move me to the parent of the parent directory. A command like cd Documents/files would move me into the files directory that is inside the Documents directory. And you can use all different combinations of these like cd ../Music/songs would move up one directory and then into the Music/songs directory. If you try to move to a directory that doesn’t exist you will get a message output that says “No such file or directory”.
Deleting files and folders
To delete files in Unix you use the command rm [file] where [file] is the name of the file you want to delete.
To delete an entire directory and all the files contained in it, you use rm -r [directory] where [directory] is the path the directory you want to delete. Be very careful with this command as you could accidentally delete a lot of files all with the one command.
PHP #5: More Loops
Apr 19th
There are a few other types of loops in addition to while loops that we learned about in Part 4.
Do-While Loop
A do-while loop is very similar to a while loop. The only difference is that the condition is evaluated after each loop iteration, rather than before. The syntax is like this:
1 2 3 | do { // some code here } while (condition) |
Since the condition isn’t evaluated until after the loop body, the loop body is always executed at least once, whether or not the condition is true. Once it does get to the condition, if it is true, it goes back up to the top of the loop body. If it is false, the loop terminates.
1 2 3 4 5 | $i = 11; do { print "The number is $i<br />"; ++$i; } while ($i <= 10) |
The above code prints:
The number is 11<br />
even though the condition is not true. The loop body always executes once.
For Loop
The for loop is a bit more complicated. The syntax looks like this:
1 2 3 | for (initial-expression; condition; loop-end-expression) { //some code goes here } |
The initial-expression is evaluated only once, at the very beginning of the loop. The condition is then evaluated. If the condition is true, the body of the loop executes. Then the loop-end-expression is run. The process then starts over again with evaluating the condition. A for loop is generally used to do simple bounding loops, like this:
1 2 3 | for ($i = 1; $i <= 10; ++$i) { print "The number is $i<br />" } |
As you’ll notice, the same exact thing can be done with a while loop, but many prefer the for loop as it is more compact:
1 2 3 4 5 | $i = 1; while ($i <= 10) { print "The number is $i<br />"; ++$i; } |
More Looping Examples
Let’s try using a for loops to create a multiplication table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | $start = 1; $end = 10; print '<table border="1" cellspacing="0" cellpadding="5">'; for ($y = $start - 1; $y <= $end; ++$y) { print "<tr>"; for ($x = $start - 1; $x <= $end; ++$x) { if ($y == $start - 1) { print "<td><b>$x</b></td>"; } else if ($x == $start - 1) { print "<td><b>$y</b>"; } else { print "<td>" print $x*$y; print "</td>"; } } print "</tr>"; } print "</table>"; |
Notice that there is a for loop inside of another for loop. Trace the above code carefully to see how it works. This code will produce the following table:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 2 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
| 3 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 |
| 4 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 |
| 5 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 |
| 6 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 |
| 7 | 7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 | 63 | 70 |
| 8 | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |
| 9 | 9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 | 81 | 90 |
| 10 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 |
PHP #4: While Loops
Apr 14th
In programming, loops are used to execute the same lines of code multiple times. The simplest type of loop is called a while loop. The lines of code in the body of a while loop will continue executing over and over WHILE the condition is true. The syntax looks like this:
1 2 3 | while (condition) { //run this code repeatedly while the condition is true } |
Just like with if statements, the condition is evaluated as a boolean. If the condition is true, the block of code is executed and then it starts over my evaluating the condition again. If the condition is false, the block of code is not executed and the loop is terminated. Let’s try making a loop that will print all the numbers from 1 to 10:
1 2 3 4 5 | $i = 1; while ($i <= 10) { print "The number is $i<br />"; $i = $i + 1; } |
We start with a variable $i that we have set at 1. 1 is less than or equal to 10 so the loop body executes. “The number is 1<br />” is printed to the HTML, and then we add 1 to the variable $i. Now the condition is checked again, but this time $i is 2. 2 is still less than or equal to 10, so the loop body executes again. This continues and each time the number is printed and 1 is added to $i. Once $i gets to 11, the condition is no longer true, so the loop terminates.
A word about incrementing
When dealing with loops it is common to have an indexing variable, like $i in the previous example. Usually you will want $i to either increase by one or decrease by one on each iteration of the loop. In the previous example, we used
1 | $i = $i + 1; |
to do this, but there is a simpler way that accomplishes exactly the same thing:
1 | ++$i; |
This is called the pre-increment operator. There is also a pre-decrement operator that will subtract one from the variable:
1 | --$i; |
Important Note: A common misconception is that ++$i is the same thing as $i + 1. They are not the same. ++$i actually changes the value of $i to be 1 greater. $i + 1 keeps $i as is, but gives you the number 1 greater than $i to use as a value.
With that said, we can rewrite our loop above using the pre-increment operator:
1 2 3 4 5 | $i = 1; while ($i <= 10) { print "The number is $i<br />"; ++$i; } |
This loop accomplishes exactly the same thing as the previous one.
More Looping Examples
Looping can be used to accomplish a lot of different things.
In mathematics, the factorial of a positive non-decimal whole number is the product of all positive non-decimal numbers less than or equal to it. For example:
5 Factorial = 1 * 2 * 3 * 4 * 5 = 120
We can use a while loop to calculate the factorial of a number:
1 2 3 4 5 6 7 | $i = 5; //the number to calculate the factorial of $factorial = 1; while ($i > 0) { //once $i is no longer a positive integer, stop looping $factorial = $factorial * $i; //multiply by the current number --$i; //go down to the next number } print $factorial; |
This will print the number 120, the factorial of 5. If we want 10 factorial, all we have to do is change the initial value of $i, and our code will do the rest.
Now let’s apply what we learned in PHP #2: GET and POST to ask a user what number they would like to know the factorial of. First we’ll need an html form where the user enters the number:
1 2 3 4 5 6 7 8 9 10 11 | <html> <head> <title>Factorial Calculator</title> </head> <body> <form method="get" action="factorial.php"> Calculate the factorial of:<input type="text" name="factorial" /><br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> |
Now we’ll create a php file called factorial.php that will process the info from the form using the same method as before.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <html> <head> <title>Factorial Calculator</title> </head> <body> <?php $i = $_GET['factorial']; //the number to calculate the factorial of $factorial = 1; while ($i > 0) { //once $i is no longer a positive integer, stop looping $factorial = $factorial * $i; //multiply by the current number --$i; //go down to the next number } print "The factorial is $factorial."; ?> </body> </html> |
Now view the html page in your browser and you should have a functioning factorial calculator. You can download the full source code for this example here:

Factorial Example
Size: 1.17 KB
MMF2 Beginning Video Tutorial Series
Apr 9th
This tutorial series is designed to get beginner’s to Multimedia Fusion 2 up and running, creating their own games. By the end of series you will know all the basics and will have created your own your own Game of “One Player Pong.” The series is presented in chronological order.
Before using this course, you should:
- Have a copy of one of the current clickteam products (TGF2, MMF2 Standard or MMF2 Developer) or a demo version of these products available at www.clickteam.com. (Some of the tutorials may require a full version of MMF2 Standard or Higher.)
- Have some basic knowledge of how to use a computer.

