Subscribe Bookmark RSS Feed

how do you use variables in a built in function?

alex

Community Trekker

Joined:

Jun 23, 2011

I'm trying to use a variable in the below Distribution Procedure which is inside a function. It works if I hard code the text(the commented out 1), but when I put it in a variable(varB), it's not evaluating the variable.

Is there some thing fundamental I'm missing?
the Show(varB) tells me that the value has been correctly passed...
but then in the Distribution Procedure I get:
Name Unresolved: varB{1}
???
Thanks,
Alex






style='font-size:10.0pt;font-family:"Courier New";color:black'>RunTheVERTICAL

style='font-size:10.0pt;font-family:"Courier New";color:black'>

style='font-size:10.0pt;font-family:"Courier New";color:navy'>=

style='font-size:10.0pt;font-family:"Courier New";color:black'>

class=GramE>function
style='font-size:10.0pt;font-family:"Courier New";color:black'>(

style='font-size:10.0pt;font-family:"Courier New";color:black'>{

class=SpellE>varB
},



Show
style='font-size:10.0pt;font-family:"Courier New";color:black'> (
class=SpellE>varB
)
;




style='font-size:10.0pt;font-family:"Courier New";color:black'>Distribution(

style='font-size:10.0pt;font-family:"Courier New";color:black'>




style='mso-spacerun:yes'>   
Continuous Distribution(

style='font-size:10.0pt;font-family:"Courier New";color:#0000DD'>Column

style='font-size:10.0pt;font-family:"Courier New";color:black'>(

style='font-size:10.0pt;font-family:"Courier New";color:black'>

style='font-size:10.0pt;font-family:"Courier New";color:navy'>:

style='font-size:10.0pt;font-family:"Courier New";color:black'>E2E )

style='font-size:10.0pt;font-family:"Courier New";color:navy'>,

style='font-size:10.0pt;font-family:"Courier New";color:black'> Horizontal
Layout(
1 ), Vertical( 0 ) )
style='font-size:10.0pt;font-family:"Courier New";color:navy'>,

style='font-size:10.0pt;font-family:"Courier New";color:black'>



     
class=GramE>By(
:MonthFinish
style='font-size:10.0pt;font-family:"Courier New";color:black'> )

style='font-size:10.0pt;font-family:"Courier New";color:navy'>,

style='font-size:10.0pt;font-family:"Courier New";color:black'>



     
style='font-size:10.0pt;font-family:"Courier New";color:green'>//1// Where
class=GramE>( :
Group == "Name of Group1")



     
style='mso-spacerun:yes'> 
Where (
style='color:navy'>:
Group

style='font-size:10.0pt;font-family:"Courier New";color:navy'>==

style='font-size:10.0pt;font-family:"Courier New";color:black'>
class=SpellE>varB
)




style='font-size:10.0pt;font-family:"Courier New";color:black'>)

style='font-size:10.0pt;font-family:"Courier New";color:navy'><

style='font-size:10.0pt;font-family:"Courier New";color:navy'><

style='font-size:10.0pt;font-family:"Courier New";color:black'> Set Window
Title (
"Histogram of E2E")
style='font-size:10.0pt;font-family:"Courier New";color:navy'>;

style='font-size:10.0pt;font-family:"Courier New";color:black'>




style='font-size:10.0pt;font-family:"Courier New";color:black'>)

style='font-size:10.0pt;font-family:"Courier New";color:navy'>;

style='font-size:10.0pt;font-family:"Courier New";color:black'>



c
style='font-size:10.0pt;font-family:"Courier New";color:navy'>=

style='font-size:10.0pt;font-family:"Courier New";color:black'>{

style='font-size:10.0pt;font-family:"Courier New";color:purple'>"Name of Group1"
};




style='font-size:10.0pt;font-family:"Courier New";color:#0000DD'>show

style='font-size:10.0pt;font-family:"Courier New";color:black'>(

style='font-size:10.0pt;font-family:"Courier New";color:black'>c)

style='font-size:10.0pt;font-family:"Courier New";color:navy'>;

style='font-size:10.0pt;font-family:"Courier New";color:black'>



//
class=GramE>RunTheVERTICAL
("Name of Group1");



RunTheVERTICAL
style='font-size:10.0pt;line-height:115%;font-family:"Courier New";color:black'>(

style='font-size:10.0pt;line-height:115%;font-family:"Courier New";color:black'>c)

style='font-size:10.0pt;line-height:115%;font-family:"Courier New";color:navy'>;



6 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

Take off the curly braces - that turns c into a list.

c = "Name of Group1";

If that still doesn't work try

RunTheVERTICAL(eval(c));
alex

Community Trekker

Joined:

Jun 23, 2011

neither of those works....

if you look at the 2nd line, the show(varB) works correctly....I get this output in the log...

varB:"Name of Group1"
varC:"Name of Group1"
Name Unresolved: varB{1}
Check for updates. I get the same error in JMP 8.0 but the script runs fine in JMP 9. Sorry I don't know what the fix was.
pmroz

Super User

Joined:

Jun 23, 2011

Try this:

Where ( :Group == eval(varB) )


If that doesn't work you may need to use something like this:

RunTheVERTICAL = function({varB},
Show (varB);
eval(
eval expr(
Distribution(
Continuous Distribution( Column( :E2E ), Horizontal Layout( 1 ), Vertical( 0 ) ),
By( :MonthFinish ),
Where ( :Group == expr(varB) )
)<< Set Window Title ("Histogram of E2E");
);
);
);
alex

Community Trekker

Joined:

Jun 23, 2011

@spokedude, i'm stuck on 8 for a while longer... if its a v8 bug then i'm happy to know that.

@PMroz
the 1st solution didn't work but the 2nd one did! awesome and thanks so much.
i have to admit i read through the expr/eval sections of the JMP Scripting Guide earlier today and couldn't make sense of them......i'm still not really sure. Re the above, do you think its a bug?
Really happy it works now. Thanks Again.
Regards,
Alex
pmroz

Super User

Joined:

Jun 23, 2011

No it's not a bug. I find eval, eval expr, expr, parse, etc. confusing as well. I've picked up a few techniques here and there to work around JSL's "features", especially wrt functions. Apply the techniques and move on ;).