- Fri Nov 24, 2006 4:27 pm
#196820
ok let's discuss that again with global definitions of vars.
example: (an easy one for SunlightRocker,
)
* * *
// correct example 1
global proc A()
{
global string $A = "word A\n";
}
global proc B()
{
global string $B = "word B\n";
}
global proc C()
{
global int $N = 5;
}
global proc D()
{
global string $A;
global string $B;
global int $N;
print $A;
print $B;
print $N;
}
A;
B;
C;
D;
//result: word A word B, 5
//example 2
global proc A()
{
global string $A = "word A\n";
}
global proc B()
{
global string $B = "word B\n";
}
global proc C()
{
int $N = 5;
}
global proc D()
{
global string $A;
global string $B;
int $N;
print $A;
print $B;
print $N;
}
A;
B;
C;
D;
//result: word A word B, 0 because the new int $N is a new variable and
//not the global one.
//example 3
global proc A()
{
global string $A = "word A\n";
}
global proc B()
{
global string $B = "word B\n";
}
global proc C()
{
int $N = 5;
}
global proc D()
{
global string $A;
global string $B;
print $A;
print $B;
print $N;
}
A;
B;
C;
D;
//result: "$N" is an undeclared variable.
* * *
deadalvs
example: (an easy one for SunlightRocker,

* * *
// correct example 1
global proc A()
{
global string $A = "word A\n";
}
global proc B()
{
global string $B = "word B\n";
}
global proc C()
{
global int $N = 5;
}
global proc D()
{
global string $A;
global string $B;
global int $N;
print $A;
print $B;
print $N;
}
A;
B;
C;
D;
//result: word A word B, 5
//example 2
global proc A()
{
global string $A = "word A\n";
}
global proc B()
{
global string $B = "word B\n";
}
global proc C()
{
int $N = 5;
}
global proc D()
{
global string $A;
global string $B;
int $N;
print $A;
print $B;
print $N;
}
A;
B;
C;
D;
//result: word A word B, 0 because the new int $N is a new variable and
//not the global one.
//example 3
global proc A()
{
global string $A = "word A\n";
}
global proc B()
{
global string $B = "word B\n";
}
global proc C()
{
int $N = 5;
}
global proc D()
{
global string $A;
global string $B;
print $A;
print $B;
print $N;
}
A;
B;
C;
D;
//result: "$N" is an undeclared variable.
* * *
deadalvs