Use Eval() to read the variables.
Eval("$x = $" & $name);Example
TBH this is not quite a good idea, but I can't find a better alternative except using arrays.
Like this.
Global $troopstot=2
Global $troop[$troopstot][4]
$troop[0][0] = GUICtrlCreateLabel("troop_1",10,10);Creates the first group of troop's data
$troop[0][1] = GUICtrlCreateInput("troop_1_2",10,10)
$troop[0][2] = GUICtrlCreateInput("troop_1_3",10,10)
$troop[0][3] = GUICtrlCreateInput("troop_1_4",10,10)
$troop[1][0] = GUICtrlCreateLabel("troop_2",20,10);Creates the 2nd group of troop's data
$troop[1][1] = GUICtrlCreateInput("troop_2_2",20,10)
$troop[1][2] = GUICtrlCreateInput("troop_2_3",20,10)
$troop[1][3] = GUICtrlCreateInput("troop_2_4",20,10)
GUICtrlSetOnEvent($Button, "AddTroop") ;On button pressed event adds a group of troop data to the pre-existing ones (incremental)
Func AddTroop()
$troopstot += 1
ReDim $troop[$troopstot][4]
$troop[$troopstot][0] = GUICtrlCreateLabel("troop_2",20,10)
$troop[$troopstot][1] = GUICtrlCreateInput("troop_2_2",20,10)
$troop[$troopstot][2] = GUICtrlCreateInput("troop_2_3",20,10)
$troop[$troopstot][3] = GUICtrlCreateInput("troop_2_4",20,10)
EndFunc