Passer le nom de la colonne comme argument à une fonction - concatène avec : nécessaire ?Ci-dessous se trouve une fonction dans laquelle j'essaie de transmettre un nom de colonne pour tracer une distribution, mais cela ne fonctionne pas. Je me demande quelle est la bonne syntaxe ?
Names Default To Here (1);
getDistChart = Function({ColName}, {dC},
dC = Distribution( Continuous Distribution( Column( :ColName) ) );
return(dC);
);
//gt = getDistChart ("MyCol"); to test the function
J'ai déjà ouvert la table de données avec MyCol comme nom de colonne. Je me demande si je dois concaténer
:
avec le nom de la colonne
ColName
Si oui, comment (car la concaténation normale avec || || ne semble pas fonctionner) ?
Tableau de donnéesScriptRe : Passer le nom de la colonne comme argument à une fonction - concatène-t-il avec : nécessaire ?Merci @Mark_Bailey Cela marche.
Re : Passer le nom de la colonne comme argument à une fonction - concatène-t-il avec : nécessaire ?Oui, cela fonctionne parfaitement pour moi avec JMP Pro 16.1.0. Je n'ai installé aucune version antérieure de JMP à tester. Votre version a environ 5 ans. JSL est en constante évolution, il est donc possible que ma syntaxe ne fonctionne pas pour une version antérieure.
Vous pouvez contacter le support technique JMP ( support@jmp.com ) pour aider.
Vous pouvez également essayer d'utiliser des expressions pour accomplir ce que vous voulez. Ils fonctionnent pour n'importe quelle version de JMP, depuis la version 4. Voir si cette version fonctionne :
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function( {ColName, _LSL, _USL}, {distChart},
Eval(
Substitute(
Expr(
distChart = New Window( "" || ColName || " distribution",
Distribution(
Stack( 1 ),
Continuous Distribution(
Column( As Column( ColName ) ),
Horizontal Layout( 1 ),
Vertical( 0 ),
Capability Analysis( LSL( _LSL ), USL( _USL ) )
),
SendToReport(
Dispatch(
{ ccc },
"Distrib Histogram",
FrameBox,
{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
)
)
)
);
),
Expr( ccc ), colName
)
);
Return( distChart );
);
getDistChart( "weight", 55, 185 );Re : Passer le nom de la colonne comme argument à une fonction - concatène-t-il avec : nécessaire ?@Mark_Bailey Merci. L'exécution de votre script me donne ce qui suit dans le journal
Cannot find item "ColName" in outline context {ColName}
Ça marche pour toi?
(je suis sur JMP 13)
Re : Passer le nom de la colonne comme argument à une fonction - concatène-t-il avec : nécessaire ?Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function( {ColName, _LSL, _USL},
{distChart},
New Window( "" || ColName || " distribution",
Distribution(
Stack( 1 ),
Continuous Distribution(
Column( As Column( ColName ) ),
Horizontal Layout( 1 ),
Vertical( 0 ),
Capability Analysis( LSL( _LSL ), USL( _USL ) )
),
SendToReport(
Dispatch(
{colName},
"Distrib Histogram",
FrameBox,
{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
)
)
)
);
Return( distChart );
);
getDistChart( "weight", 55, 185 );Re : Passer le nom de la colonne comme argument à une fonction - concatène-t-il avec : nécessaire ?@Mark_Bailey Merci ça marche. Cependant, je bloque pour passer à l'étape suivante. Je voudrais passer le nom de la colonne à plusieurs endroits dans mon script. Utilisation de Big Class comme exemple ci-dessous. Je suis capable de passer le ColName à New Window mais pas à Dispatch
Names Default To Here (1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function({ColName, _LSL, _USL}, {distChart},
New Window(""||ColName||" distribution",
Distribution(
Stack( 1 ),
Continuous Distribution(
Column(As Column (ColName) ),
Horizontal Layout( 1 ),
Vertical( 0 ),
Capability Analysis( LSL(_LSL ), USL(_USL) )
),
SendToReport(
Dispatch(
{"weight"},
"Distrib Histogram",
FrameBox,
{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
)
)
);
);
return(distChart);
);
getDistChart ("weight", 55, 185);
Par exemple ce
Dispatch( {ColName},...
ou ca d'ici
Dispatch( {Expr(ColName)},...
ne marche pas. Quelle est la syntaxe correcte pour passer une chaîne comme argument pour Dispatch ?
Re : Passer le nom de la colonne comme argument à une fonction - concatène-t-il avec : nécessaire ?Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function( {ColName}, {dC},
dC = Distribution( Continuous Distribution( Column( As Column( colName ) ) ) );
Return( dC );
);
gt = getDistChart ("weight");