%this confuse
by FanZhang · in Torque Game Engine Advanced · 07/28/2009 (1:31 am) · 3 replies
I wrote the code below:
$QuestionSeq = 0;
function TestGui::onWake(%this){
%tempQuestionSeq = $QuestionSeq;
%this.setSubject(%this,%tempQuestionSeq);
//%this.setQuestionText(0);
//%this.setOptionText();
}
function TestGui::setSubject(%this,%seq){
%this.setQuestionText(%seq);
%this.setOptionText();
}
the problem is i intent to send the $QuestionSeq = 0 to the function TestGui::setSubject(%this,%seq),but out of my expectation that the variable %seq = 1295 not %seq = 0.it got the %this`s value.
what`s that matter? thnx:)
$QuestionSeq = 0;
function TestGui::onWake(%this){
%tempQuestionSeq = $QuestionSeq;
%this.setSubject(%this,%tempQuestionSeq);
//%this.setQuestionText(0);
//%this.setOptionText();
}
function TestGui::setSubject(%this,%seq){
%this.setQuestionText(%seq);
%this.setOptionText();
}
the problem is i intent to send the $QuestionSeq = 0 to the function TestGui::setSubject(%this,%seq),but out of my expectation that the variable %seq = 1295 not %seq = 0.it got the %this`s value.
what`s that matter? thnx:)
About the author
Recent Threads
#2
07/28/2009 (2:17 am)
ok,It can work now.Thank you Very much:)
#3
%foo.bar(%thing1);
function Foo::Bar(%this, %thing1)
When the function bar() is called, %this == %foo.
07/28/2009 (7:50 am)
Calling a function scoped to a particular object passes an implied reference to the calling object in the first parameter.%foo.bar(%thing1);
function Foo::Bar(%this, %thing1)
When the function bar() is called, %this == %foo.
Torque 3D Owner Twisted Jenius
%this.setSubject(%tempQuestionSeq);
Instead of:
%this.setSubject(%this,%tempQuestionSeq);
The variable in the front is what's used as the first argument (I hope I explained that correctly).