utilizzando una variabile come nome di colonna durante la creazione di un grafico
The script below loads some data and should create twice the same plot.<BR />The first one by referring to the column name by using a variable (test1), the second one by calling the column name directly.
The second one works fine, but for the first one I get an empty plot area. I guess there is a problem with how I define or call test1. I have tried different approaches, but so far nothing worked.
Names Default To Here( 1 );
// Import the Excel file with specified settings
dt = Open(
"/Y:/.../file.xlsx",
Worksheets( "Pivot table for JMP" ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Headers Start on Row( 2 ),
Data Starts on Row( 3 )
)
);
// Filter rows to include only "AAA" in "Common Designation"
dt_AAA = dt << Subset(
Rows( :Common Designation == "AAA" ),
Include All Columns,
Name( "Filtered AAA" )
);
size = "AAA" ;
Match( size,
"AAA", test1 = column ("PL (min)"),
);
New Window( size,
V List Box(
Graph Builder(
Size( 500, 297 ),
Show Control Panel( 0 ),
Variables( X( :test1 ), Y( :Chemistry ), Color( :Chemistry ) ),
Elements( Points( X, Y, Legend( 106 ) ) )
),
Graph Builder(
Size( 500, 297 ),
Show Control Panel( 0 ),
Variables( X( :"PL (min)"n ), Y( :Chemistry ), Color( :Chemistry ) ),
Elements( Points( X, Y, Legend( 106 ) ) )
),
),
);
Automazione e scriptingRe: utilizzo di una variabile come nome di colonna durante la creazione di un graficoSe ho capito bene, credo che basti rimuovere i due punti davanti a test1 nel primo script di Graph Builder. Ecco uno script di esempio che funziona:
Names Default To Here (1);
dt = open ("$SAMPLE_DATA/big class.jmp");
test1 = column ("weight");
Graph Builder (
Variables (X(test1), Y(:height), color (:sex))
);
Re: utilizzo di una variabile come nome di colonna durante la creazione di un graficoUn trucco interessante per trovare bug come questo:
Rimuovi sempre più righe dallo script difettoso, finché non rimangono abbastanza righe da generare l'errore.
importante: il codice deve contenere tutti gli ingredienti per produrre l'errore, per chiunque esegua il codice *)
Ciò presenta 2 vantaggi:
- nella maggior parte dei casi, il bug viene trovato automaticamente. Rimuovendo 1 riga, il bug è scomparso.
- il codice rimanente è molto breve, il che rende molto più facile trovare il bug.
*) sul mio sistema si è bloccato con il messaggio di errore:

molto meglio: usa uno dei file di esempio, come nell'esempio di @Jed_Campbell .
Questo ha un altro vantaggio: puoi distinguere tra:
- c'è un errore nella mia tabella dati (e l'errore è scomparso con i dati di esempio)
- c'è un errore nel mio script (perché posso riprodurre l'errore con i dati di esempio)