Syntax Question "::" vs "." -warning noob
by James Anderson · in Technical Issues · 11/06/2008 (7:50 am) · 4 replies
Hi All,
Ive been plugging away at Ken Finneys Book and Im starting to see bits of light (!)
I have a syntax question that Im not understanding.
why is it some times when assigning value to a variable throught an object is looks like this:
%client.cpCompleted[0] = true; //here cpCompleted is laps completed through a trigger
and sometimes it looks like this:
$Game::NumberOfLaps = 10; // here global value of total number of laps
the dot example is straight forward but Im not understanding what requires the syntax "::"
thanks for any pointers ;-) or explainations.
Best,
j.
Ive been plugging away at Ken Finneys Book and Im starting to see bits of light (!)
I have a syntax question that Im not understanding.
why is it some times when assigning value to a variable throught an object is looks like this:
%client.cpCompleted[0] = true; //here cpCompleted is laps completed through a trigger
and sometimes it looks like this:
$Game::NumberOfLaps = 10; // here global value of total number of laps
the dot example is straight forward but Im not understanding what requires the syntax "::"
thanks for any pointers ;-) or explainations.
Best,
j.
#2
There seems to be an explination for this in Maurina's GPGT
on page 120 in the console methods section.
I think Im understanding now~~~~~~
does this mean that:
you use the "." method when you are sending a value to a field in an instanced object?
and you use the "::" for global variable fields?
thanks for any clarity.
J.
11/06/2008 (11:09 am)
Thanks Manoel,There seems to be an explination for this in Maurina's GPGT
on page 120 in the console methods section.
I think Im understanding now~~~~~~
does this mean that:
you use the "." method when you are sending a value to a field in an instanced object?
and you use the "::" for global variable fields?
thanks for any clarity.
J.
#3
11/06/2008 (12:16 pm)
Quote:you use the "." method when you are sending a value to a field in an instanced object?Yes. The value is assigned to that particular object's field only.
Quote:and you use the "::" for global variable fields?Use it for naming global variables for organizational purposes. Globals do not contain fields.
#4
I think I got it now - thanks.
Sometimes I think its more complicated that it really is.
J.
11/07/2008 (9:40 am)
Hey,I think I got it now - thanks.
Sometimes I think its more complicated that it really is.
J.
Associate Manoel Neto
Default Studio Name
$Game::NumberOfLaps is a just a global variable whose value is being set to 10. It has no relationship with the contents of $Game. In TorqueScript you can use :: in variable names merely for organization purposes (you can use exportVars() and deleteVars() more easily that way).