Game Development Community

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. :(
Page «Previous 1 2
#1
09/01/2002 (5:24 pm)
I guess no one has an idea about this one :(
#2
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
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
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
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);
==> 100

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.
#11
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
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
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
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
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.
Page «Previous 1 2