A variable in a loopHi,
I like to replace the values for
Column Names Start(2),
Data Starts( 3 ) );
as a variable like Headstart=2, DataStart=3 in Column Names Start(HeadStart). I used
Eval(Parse( " Column Names Start("||HeadStart||")," ));
I get no error but the results are not correct.
I appreciate your help. Thanks
----------------------------------------------------------------
For( iii = 1, iii <= nf, iii++, //this starts the first loop
filenow = (filelist[iii]);
dt = Open( filenow, private,
Column Names Start(2),
Data Starts( 3 ) );
New Column( "Source", Character, Nominal );
:Source << set each value( filenow );
//dt<
dt << Run Formulas();
//add the current table to the bottom of the combined data table
cctable << Concatenate( Data Table( dt ), Append to first table );
//don't use "Create Source Column" argument
Close( dt, NoSave );//after concatenating the table, close it and move on
);//end of the first for loop
Re: A variable in a loopHm...so it does. This works for me:
n=2; // b
d=4; // d
open(chartoblob(
"a
b
c
d"),columnnamesstart(n),datastarts(d))
I don't think the substitution is required for this. Glad Jim got you going!
Re: A variable in a loopThanks so much Jim. It works perfectly now.
Re: A variable in a loopI would put the open into Substitution() structure to make the changes and to run the code
datastart = 2;
namestart = 1;
Eval(
Substitute(
Expr(
Open(
"C:\...\simple.txt",
columns(
New Column( "1", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "2", Numeric, "Continuous", Format( "Best", 12 ) )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( __namestart__ ), // <<<<<<<<<<<<<<
Data Starts( __datastart__ ), // <<<<<<<<<<<<<<<<
Lines To Read( "All" ),
Year Rule( "20xx" )
)
)
),
Expr( __namestart__ ), namestart,
Expr( __datastart__ ), datastart
)
);Re: A variable in a loopThanks. It is true that column data and name start can be defined in JMP preferences. But I have tried inside open() and it works fine. I just need to parametrize it inside the open().
Re: A variable in a loopThose options go inside the Import Settings.
Open(
"C:\...\simple.txt",
columns(
New Column( "1", Numeric, "Continuous", Format( "Best", 12 ) ),
New Column( "2", Numeric, "Continuous", Format( "Best", 12 ) )
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma, CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( 1 ), // <<<<<<<<<<<<<<
Data Starts( 2 ), // <<<<<<<<<<<<<<<<
Lines To Read( "All" ),
Year Rule( "20xx" )
)
)