Crea un numero diverso di caselle di testo in base alla variabileCaro JMPer,
Provo a creare diverse caselle di testo in una nuova finestra, il numero di caselle di testo è variabile
Quindi ho una casella di scorrimento e devo impostare il testo per quelle caselle di testo che ho appena creato mentre sposto la barra
Immagino che un ciclo for dovrebbe essere la soluzione, ma non riesco proprio a farlo
colname = {"Name", "Height", "Weight"}; //it's a list of column names from previous code, number of items is not fixed
min = 0;
max = 10;
Value = 0;
eval(evalexpr(
nw = New Window( "parameter setting",
Panel Box( "parameter setting",
tb1 = text box(char(colname[1]) || ": " || char(:expr(nameexpr(ascolumn(colname[1])))[1])),
tb2 = text box(char(colname[2]) || ": " || char(:expr(nameexpr(ascolumn(colname[2])))[1])),
tb3 = text box(char(colname[3]) || ": " || char(:expr(nameexpr(ascolumn(colname[3])))[1])),
//.
//.
//.
//.
//.
//.etc
//lines for tb should determined by N itmes(colname)
Valuetb = Text Box( "Value: " || Char( Value )),
sb = Slider Box(
min, max, Value,
Valuetb << set text( "Value: " || Char( Value ));
:Parameter A << set each value(Value);
tb1 << set text(char(colname[1]) || ": " || char(:expr(nameexpr(ascolumn(colname[1])))[1]));
tb2 << set text(char(colname[2]) || ": " || char(:expr(nameexpr(ascolumn(colname[2])))[1]));
tb3 << set text(char(colname[3]) || ": " || char(:expr(nameexpr(ascolumn(colname[3])))[1]))
) // when I move the slider box, values of all columns in colname will be changed, so I do set text for all columns in colname
)
)
))
Automazione e scriptingRi: Crea un numero diverso di caselle di testo in base alla variabileGrazie, ho capito.
Inoltre ho appreso che usi eval insert per sostituire le mie funzioni long long originali.
Apprezzo sempre la tua gentile condivisione
Ri: Crea un numero diverso di caselle di testo in base alla variabileFornisce un ulteriore (e abbastanza semplice) livello di separazione al tuo script ed è più semplice modificare questi piccoli blocchi di codice rispetto all'enorme nuova finestra (non hai ancora una nuova finestra grande ma possono diventare rapidamente molto lunghe). A volte potrebbe causare qualche problema "perdendo" i riferimenti ma penso che ne valga comunque la pena.
Ri: Crea un numero diverso di caselle di testo in base alla variabileGrazie Jarmo, questo è esattamente ciò di cui ho bisogno
Posso chiederti perché preferiresti spostare lo script per Slider Box fuori dalla slider box?
Ri: Crea un numero diverso di caselle di testo in base alla variabileMemorizza i riferimenti all'elenco, crea il "raccoglitore" per le caselle di testo all'esterno della nuova finestra e sposterei anche lo script per Slider Box all'esterno della casella di scorrimento in una funzione/espressione separata.
è di questo che hai bisogno?
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
colnames = {"name", "height", "weight"}; //it's a list of column names from previous code, number of items is not fixed
min = 0;
max = 10;
Value = 0;
lub = Lineup Box(N Col(1));
tbs = {};
For Each({colname}, colnames,
text_to_add = Eval Insert("^colname^: ^dt[1, colname]^");
lub << Append(tb = Text Box(text_to_add));
Insert into(tbs, tb);
);
If(N Items(tbs) != N Items(colnames),
Throw("!Fatal error");
);
update_tbs = Expr(
For Each({colname, idx}, colnames,
text_to_set = Eval Insert("^colname^: ^dt[1, colname]^");
tbs[idx] << Set Text(text_to_set);
);
);
nw = New Window( "parameter setting",
Panel Box( "parameter setting",
lub,
Valuetb = Text Box( "Value: " || Char( Value )),
sb = Slider Box(
min, max, Value,
Valuetb << set text( "Value: " || Char( Value ));
:age << set each value(Value);
update_tbs;
)
);
);Ri: Crea un numero diverso di caselle di testo in base alla variabileGrazie Jim, ma non è ciò di cui ho bisogno, non è necessario sostituire (colname[1]) [1] con value
Ciò di cui ho bisogno è che quando l'elenco colname contiene più elementi, ad esempio: 5, lo script può fare:
tb1 =
tb2 =
tb3=
tb4 =
tb5=
quando ha 10 elementi, esegui tb1 ~ tb10
Ri: Crea un numero diverso di caselle di testo in base alla variabileNon sono sicuro che questo sia quello che vuoi. Le mie modifiche al tuo script cambiano i valori nelle caselle di testo nella finestra di visualizzazione, mentre sposti il cursore
names default to here(1);
dt = open("$SAMPLE_DATA/big class.jmp");
colname = {"Name", "Height", "Weight"}; //it's a list of column names from previous code, number of items is not fixed
min = 1;
max = 10;
Value = 1;
Eval(
Eval Expr(
nw = New Window( "parameter setting",
Panel Box( "parameter setting",
tb1 = Text Box(
Char( colname[1] ) || ": " || Char( :expr( Name Expr( As Column( colname[1] ) ) )[1] )
),
tb2 = Text Box(
Char( colname[2] ) || ": " || Char( :expr( Name Expr( As Column( colname[2] ) ) )[1] )
),
tb3 = Text Box(
Char( colname[3] ) || ": " || Char( :expr( Name Expr( As Column( colname[3] ) ) )[1] )
),
//.
//.
//.
//.
//.
//.etc
//lines for tb should determined by N itmes(colname)
Valuetb = Text Box( "Value: " || Char( Value ) ),
sb = Slider Box(
min,
max,
Value,
Valuetb << set text( "Value: " || Char( Value ) );
//:Parameter A << set each value( Value );
tb1 << set text(
Char( colname[1] ) || ": " ||char(column( colname[1] )[value] ));
tb2 << set text(
Char( colname[2] ) || ": " ||char(column( colname[2] )[value] ));
tb3 << set text(
Char( colname[3] ) || ": " ||char(column( colname[3] )[value] ));
) // when I move the slider box, values of all columns in colname will be changed, so I do set text for all columns in colname
)
)
)
);