Digital humans the art of the digital double
Ever wanted to know how digital doubles are created in the movie industry? This course will give you an insight into how it's done.
# 1 06-03-2010 , 03:19 PM
Registered User
Join Date: Feb 2010
Posts: 4

Scope scope scope

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 ) > ) {

        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.

# 2 06-03-2010 , 03:42 PM
Registered User
Join Date: Feb 2010
Posts: 4
Aha, gotta declare the vars again in each proc.

How do I globally define the $file, since I don't know datatype?

# 3 06-03-2010 , 04:37 PM
Registered User
Join Date: Feb 2010
Posts: 4
All fixed. To anyone who stumbles across this with the same problems:

1) global variables need to be defined in the procedure as well as outside the proc.

2) file id's can be defined globally by doing:

PHP Code:
global int $file;
$file = `fopen $fileLoc "r"`; 

# 4 06-03-2010 , 09:14 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
They can also be defined in one line.
PHP Code:
global int $file = `fopen $fileLoc "r"`; 


Imagination is more important than knowledge.
Posting Rules Forum 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

Similar Threads