Game Development Community

Problems using variables in GuiTextCtrl [SOLVED]

by Andrew H · in Torque Game Builder · 10/05/2011 (3:28 pm) · 1 replies

I have been attempting to use variables as the text in GuiTextCtrls - specifically, names to show if a specific profile is taken, and if so, by whom. Tests I have run have proven that the variable contains the value I want (in this case, "New"). Other tests have shown it is just that the TextCtrl doesn't want to use a variable as its text (I tried a direct input).

Here's the code for the control I am using:

new GuiTextCtrl(nameDisplay2) {
  canSaveDynamicFields = "0";
  isContainer = "0";
  Profile = "AntivirusLargeTextProfile";
  HorizSizing = "right";
  VertSizing = "bottom";
  Position = "479 301";
  Extent = "251 64";
  MinExtent = "8 2";
  text = $profileName2;
  canSave = "1"
  Visible = "1";
  hovertime = "1000";
  maxLength = "1024";
};

Anyway - when I try this, the text display comes up blank. And when I have text = "Test" or whatever, it shows up.

Please help me here!

#1
10/05/2011 (6:32 pm)
Okay, so somehow the problem is that I am executing it before the variables are set. Either way, when I execute it before the variables are set, it fixes the problem.