Assume I have the name of a table variable as a quoted string in a run-time variable. How do I get the table variable Name object from that?
I had this same issue with table columns which I was able to work around by getting a list of table Column Names and iterating through them until I found a Name object that matched the string. Unfortunately there doesn't appear to be a function that returns table variables so this method doesn't work.
Background: The purpose of this is to have a reusable library that can embed formulas in columns. Since the reuse code doesn't know the Table Variable Names or Column Names, I need to pass them to my functions as string parameters. However, if I use the string variable when building the formula the result is a quoted string instead of a reference to the column or table variable.
You can get the table variable's value from the string with
x = Current Data Table() << Get Table Variable( "teacher" );
And you can get a column's value with
x = column("height")[ 1 ];
Expressions can be used for more complicated meta-programming (JSL that manipulates JSL), but since you're starting with a string it may be better to use Parse() and Eval(). For example, the following takes a function name string and treats it as a function name.
I have a .doc file that contains Column names that needs to be used to create a Oneway graph. I load the document and try to parse the string to use in the expression :
----Script Code---- headers = load text file("headers.doc"); heads = parse(headers);
Oneway( Y(: heads //This is the variable that contains the headers ), X( :blah ), Means and Std Dev( 1 ), Box Plots( 1 ), Mean Lines( 1 ), Mean Diamonds( 1 ), Mean Error Bars( 1 ), Std Dev Lines( 1 ), Points Jittered( 1 ), Points Spread( 1 ) ) );
My question is, what type of string can I pass into Parse() so that I can insert multiple names into the Y() argument? Do the names need to be semi-colon, space, carrige return, comma delimited? And can I iterate through each of the Names? Thanks.
Update: I found the Word function that takes a string and delimiter and returns a list of words. This is just waht I was looking for because I can iterate over all of the words generating Oneway graphs per word. Thanks SAS.