I have a table to describe a crossroad. Each traffic line has it own Q(flow), V( speed) and direction.
I'm saving data in array, which hardcoded (very simple code data = {{66, 55, 3}, {44, 33, 2}, {22, 11, 1}};) . The functional allows to create more traffic lanes. Now it works, when I change value in inputfield it changes in data_array correctly.
I would like to create an array, without hardcode(it could be full of 0 e.g.), like C++ malloc. It is possible? Thank you!
P.S. After user complete the table, I need to have this array( already changed) and it length(also changed due to user's amount of traffic lines). Then I would give this array to C++ to calculate( but now the question is about malloc array)
resultingControl = Labeled[
Manipulate[
data = {{66, 55, 3}, {44, 33, 2}, {22, 11, 1}};
e = 0;
Grid[{
{Style["direction East", 16, Bold]}
}~Join~
Table[
{Style["traffic lane", Bold], e,
Labeled[InputField[Dynamic[data[[#, 1]]] &@e, FieldSize -> 8],
"Q", Left, LabelStyle -> Directive[Bold]],
Labeled[InputField[Dynamic[data[[#, 2]]] &@e, FieldSize -> 8],
"V", Left, LabelStyle -> Directive[Bold]],
PopupMenu[
Dynamic[data[[#, 3]]] &@e, {0 -> "out", 1 -> "left",
2 -> "right", 3 -> "straight", 4 -> "straight-left-right",
5 -> "straight-left", 6 -> "straight-right",
7 -> "left-right"}]}, {e, EastLines}
]
],(*direction East*)
Grid[{
{DynamicModule[
{
code = Hold[EastLines :> 2
]
},
With[
{
fn = (
code = #;
ReleaseHold[# /. RuleDelayed -> SetDelayed]
) &
},
Manipulate[
Column[
{
Labeled[
InputField[Dynamic[code, fn], Hold[Expression],
FieldSize -> 35 ], "", Left,
LabelStyle -> Directive[Bold]]
}
],
Initialization :> fn[code]
]
]
]
}
}],(*DynamicModule EastIN*)
SynchronousInitialization -> False,
ContinuousAction -> False
](* Manipulate *),
"Lab№2", Top,
LabelStyle ->
Directive[Bold, Blue, Italic, 24, FontFamily -> "Helvetica"]
]; (* Labeled *)
resultingControl