Documentation for Pert 1.0

Despite the 1.0 versioning, Pert is still very much in beta. That is, it has not been fully tested. Should you discover a bug , or what you think might be a bug, please e-mail pert-bugs@media.mit.edu.

This documentation is also in beta. Since, Pert generally represents a subset of C, any external documentation on C should be valid for each of the language features below, unless otherwise noted.

The coordinate system for the Pert system is based around an origin in the lower-left corner of the window. This point is 0,0. Positive X goes to the right. Positive Y goes up. 1 unit is the length or height of 1 pixel.

Downloading Pert

Here is PertForPC and PertForMac and PertForSGI. The PC version can be decompressed with WinZip. Use Stuffit Expander for the Mac version. The SGI version can be decompressed by typing "gunzip pert1.0.tar.gz; tar -xvf pert1.0.tar." The SGI version should run as is. The PC and Mac versions both require OpenGL dlls/extensions to be installed on your computer. Any PC running Windows 95, 98, ME, NT, or 2000 should have these pre-installed. Any Mac running MacOS 8.6 or newer should have these pre-installed as well. The Mac libraries are available for download from Apple. The application also requires the GLUT dll/extension. For PC's, it is included in the zip file. It comes with OpenGL for the Mac automatically. Do not remove this file. Please report any problems running Pert.


Using Pert

Using Pert should be quite simple. First create a program using any text editor, and save the file as a plain text file. Launch the Pert application. You are asked to enter a file name. Make sure the file you are opening is in the same directory/folder as the application. Once the name is complete, press the Enter or Return key. If you're program has no errors, it should be running now.

You do not have to quit the Pert application to load a new file. The "Enter file name" screen may be brought up at any time, simply by pressing the Space-bar. In fact, a great way to write code in Pert is to keep the text editor open and continually reload in the C file as you make changes. It's always a good idea to backup your code...especially when it's working.


Special Pert Functions

You can now find a list of all the native pert functions, for math, drawing, etc, on a separate page.


General Pert C

comments Both C and C++ style comments are supported.
// one-line comment
/* multi line
 comments are nice */
types Pert supports the following types: bool, char, int, float, void (for functions only), bool arrays, char arrays, int arrays, and float arrays.

Note: it is best to declare arrays as globals (rather than within a function) for optimal efficiency. Arrays can be declared with sizes that reference integer variables...just make sure those variables are assigned values first.
int a = 10;
float d,e,f[10];
bool bList[20];
char g, h;
int iList[a];
expressions Expressions should behave like regular C expressions. For boolean expressions, sometimes parentheses are necessary.
a = 4;
f[2] = 3.0+1.3;
bList[0] = (a<3);
functions Function declarations are optional. Arrays cannot be arguments of functions, nor can they be returned.
float square(float d)
{
  return d*d;
}

int avg( int a, int b )
{
  return (a+b)/2;
}
if If statements should behave just like regular C if statements, including having optional else clauses.

As with all blocks, curly braces can be left out for a one-statement block.
if ( d < e ) {
  // code goes here
}

if ( bList[3] )
   // do something here
else
   // or something here
while While statements should behave just like regular C while statements. Use the "break;" command to exit a while loop. While loops which go on for too long (like over a million times) will be stopped as a measure against infinite loops.
while(a<10) {
  a = a + 2;
}

while(true)
{
  break;
}
for For statements should behave just like regular C For statements. Use the "break;" command to exit a for loop. For loops which go on for too long (like over a million times) will be stopped as a measure against infinite loops.
for(a=0; a<10; a++)
{
  d = 5.4*a;
}

for(a=0; a<10; a++)
{
  if (a==3)
    break;
}
return Return is used to return a value from a function. Return can be used at any point within a function, and it will instantly leave the function, without executing any more function code. Returned value types should match the type of the function.
return 7;
return 14+3.2;


last updated 3/31/01 by jarfish