How do I get values of dynamic fields of a control in scripting?
by Nathan Martin · in General Discussion · 09/01/2002 (4:03 pm) · 22 replies
Hello, how do I go about getting the value of a dynamic field in scripting? For example there is a text control named ServDlg_Port and it has a dynamic field named Max, how do I get Max field's value?
I've tried for a few hours trying to figure this out, but no cigar. :(
I've tried for a few hours trying to figure this out, but no cigar. :(
About the author
By day I work as an embedded microcontroller programmer for mainly Blackfin MCU/DSPs, and by night, and free time too, I'm a hobbyist game developer.
#2
Are you talking about script or C++ btw.?
EDIT: ah, ok, guess you mean in script :p
Well, I can't find the var you're talking about anywhere, but normally you can get every field of a var simply by writing
%myvar.myfield
Maybe you should post a snippit what you are trying to do exactly...
09/01/2002 (9:58 pm)
LOL! 1,5 hrs and you're complaining that nobody knows the answer to your question...?Are you talking about script or C++ btw.?
EDIT: ah, ok, guess you mean in script :p
Well, I can't find the var you're talking about anywhere, but normally you can get every field of a var simply by writing
%myvar.myfield
Maybe you should post a snippit what you are trying to do exactly...
#3
09/01/2002 (11:07 pm)
ummm, I explained what I am trying to do and yet you ask that question? READ THE POST, geez!
#4
Does that not mean anything to you at all?
Plus the fact of course I've tried %this.max and I get uknown command max.
09/01/2002 (11:08 pm)
For example there is a text control named ServDlg_Port and it has a dynamic field named Max, how do I get Max field's value? Does that not mean anything to you at all?
Plus the fact of course I've tried %this.max and I get uknown command max.
#5
09/01/2002 (11:23 pm)
yeah, sorry for trying to help
#6
09/02/2002 (12:19 am)
damn beffy, hope you never do that again ! ;)
#7
%ServDlg_Port.Max should hold the value. No?
Phil.
09/02/2002 (12:59 am)
If your first port was right..%ServDlg_Port.Max should hold the value. No?
Phil.
#8
09/02/2002 (3:55 pm)
it's just ServDlg_Port and using .max it gives 'unknown command'. If you use %ServDlg_Port will give 'unknown object %ServDlg_Port'.
#9
09/09/2002 (11:31 pm)
I guess no one could ever figure it out. :(
#10
The correct way to retrieve a dynamic field in script is just by using the dot operator (.) and the field name:
Enter that in the console, and (unless your build is fucked up), it'll work 100% of the time.
If you're talking about getting dynamic field values from script into c++ code, then no, I haven't yet figured that out.
09/09/2002 (11:50 pm)
No, that's not correct. You haven't given us enough information to work with. Post some sample code at least.The correct way to retrieve a dynamic field in script is just by using the dot operator (.) and the field name:
$var = new ScriptObject(){};
$var.max = "100";
echo($var.max);
==> 100Enter that in the console, and (unless your build is fucked up), it'll work 100% of the time.
If you're talking about getting dynamic field values from script into c++ code, then no, I haven't yet figured that out.
#11
ServDlg_Port = blah..
If thats the case, thats the problem.
use % for "local" and $ for global variables (I think).
Phil.
09/10/2002 (12:27 am)
are you saying you missed the % or $ out nathan? i.e.ServDlg_Port = blah..
If thats the case, thats the problem.
use % for "local" and $ for global variables (I think).
Phil.
#12
Let me repeat myself again how do I go about getting the value of a dynamic field in scripting? For example there is a text control named ServDlg_Port and it has a dynamic field named Max, how do I get Max field's value?
Meaning using $ServDlg_Port and %ServDlg_Port is NONE SENSE since the fact it's an actual textbox(aka GuiTextEditCtrl) control! What I am wanting to do is get the value from a dynamic field called Max.
Here is the control's creation script entry:
09/10/2002 (6:16 am)
Look people, read the whole forum thread before posting 'you didn't provide the code or not enough info' when I have provided well over enough information!Let me repeat myself again how do I go about getting the value of a dynamic field in scripting? For example there is a text control named ServDlg_Port and it has a dynamic field named Max, how do I get Max field's value?
Meaning using $ServDlg_Port and %ServDlg_Port is NONE SENSE since the fact it's an actual textbox(aka GuiTextEditCtrl) control! What I am wanting to do is get the value from a dynamic field called Max.
Here is the control's creation script entry:
new GuiTextEditCtrl(ServDlg_Port) {
profile = "GuiTextEditProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "75 7";
extent = "36 18";
minExtent = "8 8";
visible = "1";
helpTag = "0";
text = "28000";
maxLength = "5";
validate = "ServerDlg::valid(ServDlg_Port,1);";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
max = "65535";
min = "1";
};
#13
09/10/2002 (6:54 am)
I don't have the answer, but have you thought of looking in the Editor GUI scripts? There's a wealth of useful code in there.
#14
Wherever you stick this, it equals the value of the max property of ServDlg_Port. If it doesn't, or it says it doesn't exist, then make sure your GUI script is executing before whatever you're referencing it in.
09/10/2002 (7:07 am)
Read this:ServDlg_Port.max
Wherever you stick this, it equals the value of the max property of ServDlg_Port. If it doesn't, or it says it doesn't exist, then make sure your GUI script is executing before whatever you're referencing it in.
#15
09/10/2002 (7:35 am)
ServDlg_Port.max causes the error: 'unknown command max'
#16
i just copied your "snippet" into the mainMissionGui.gui, started the exe and
echo(ServDlg_Port.max)
in the console returned 65535 !!! so ServDlg_Port.max *does* work!!
09/10/2002 (7:39 am)
hmm, awesome:i just copied your "snippet" into the mainMissionGui.gui, started the exe and
echo(ServDlg_Port.max)
in the console returned 65535 !!! so ServDlg_Port.max *does* work!!
#17
I see what I've been doing wrong >:(
I was using ServDlg_Port.max() and not ServDlg_Port.max
I'm too use to functions doing all the value grabbing.
My bad :p
09/10/2002 (7:42 am)
ohhh crap......I see what I've been doing wrong >:(
I was using ServDlg_Port.max() and not ServDlg_Port.max
I'm too use to functions doing all the value grabbing.
My bad :p
#18
09/10/2002 (7:45 am)
DOH!!!
#19
09/10/2002 (8:25 am)
lol, this is why the rest of us are polite when faced with what seems like bad/incompetent advice: it often turns out that you're the one being the moron.
#20
09/10/2002 (8:29 am)
=p
Torque Owner Nathan Martin
TRON 2001 Network