Ok, so I'm being a complete newbie and getting stuck with scope. How should I be doing this? PHP Code: $fileLoc = "C:/output.txt"; global $file=`fopen $fileLoc "r"`; global int $readcount = 0; global string $curval = ""; global int $curframe = 0; global matrix $frame[18][38]; main(); global proc main(){ $curval = `fgetword $file`; $readcount++; while ( size( $curval ) > 0 ) { if($readcount == 686){ $readcount = 1 drawmatrix(); } if($readcount == 1){ $curframe = $readcount; print ( $curval + "\n" ); }else{ addmatrix(); } $curval = `fgetword $file`; $readcount++; } fclose $file; } global proc addmatrix(){ int $count = $readcount - 1; int $y = 0; while($count > 38){ $count -= 38; $y++; } int $x = $count; $frame[$y][$x-1] = $curval; } I get loads of errors about things not being defined so I'm certain it's a scope issue.