Re: Subscript range issue when doing increasing for loopHi,
I think that your problem is that N Cols (dt) increases after each iteration of your loop. Therefore, your index value "i" exceeds the number of elements in your collist list.
I suggest capturing the number of columns in dt outside the loop and using it as a fixed limit.
path = "my file path with filename.jmp";
dt= open(path);
collist = dt <<GET column="" names=""></GET>
Of note, I am unsure why the reverse loop works. You it should run into a similar issue with your collist variable.
Let us know if that solve your issue.
Best,
TS
Re: Subscript range issue when doing increasing for loopHi TS,
Yes, the error go away. However, I always use i<= N Cols (dt) and no issue at all. I dont understand why in this situation the same method failed?
Re: Subscript range issue when doing increasing for loop@Thierry_S the reverse loop captures ncols(dt) at the start of the loop, exactly once.
@dadawasozo
- the reverse loop isn't quite the same because it uses >colnumber+1 and probably should be >=colnumber+1 to match the non-working forward loop.
- In the forward loop, ncols(dt) is re-evaluated each time it loops and keeps getting bigger, but collist is not getting bigger, so eventually the subscript fails.
I like @Thierry_S solution.
Subscript range issue when doing increasing for loopI got error "Subscript Range in access or evaluation of 'collist[ /*###*/i]' , collist[/*###*/i]" when doing a simple new column () with increasing for loop. I able to solve it using decreasing for loop. However, I want to have created column ordered follow increasing for loop. I dont understand what causes the error when using increasing for loop here. Can someone provide suggestion how I can use increasing for loop here? if possible, can someone help explain why the error will happen for increasing for loop?
path = "my file path with filename.jmp";
dt= open(path);
collist = dt <<GET column="" names="">colnumber+1,i--, fixed issue but created column order inverted
dt <<NEW column=""></NEW></GET>
Automation and ScriptingConsumer and Market ResearchData AccessQuality and Process Engineering