Subscribe Bookmark RSS Feed

remove few items from a list using script

robust1972

Community Trekker

Joined:

Jan 15, 2014

hi, everyone

I have a list like below and I wrote this script trying to remove items from a list using script which start with ".", but it reports error :"subscript range in access or evaluation of 'subscript', CSV_File_list[i]

=N Items(CSV_File_list);

(NOF);

(CSV_File_list);

(i=1,i<=NOF,i++,

(Starts With(CSV_File_list[i], "."),

Remove From(CSV_File_list, i),

);

CSV_File_list = {"FAB8_gf_MPW14011MA.A0_8XYL45155.049_A6-SRTOTPROM-14LPE.01_OTPROMMPW1401-SORT_04_BBOCN023SAG0_20150319-155848.csv", ".FAB8_gf_MPW14011MA.A0_8XYL45155.049_A6-SRTOTPROM-14LPE.01_OTPROMMPW1401-SORT_20150319-155445_04_BBOCN023SAG0_20150319-155848_20150319-171700.csv", "FAB8_gf_MPW14011MA.A0_8XYL45155.049_A6-SRTOTPROM-14LPE.01_OTPROMMPW1401-SORT_11_BBOCN016SAG7_20150319-171703.csv", ".FAB8_gf_MPW14011MA.A0_8XYL45155.049_A6-SRTOTPROM-14LPE.01_OTPROMMPW1401-SORT_20150319-155445_11_BBOCN016SAG7_20150319-171703_20150319-183919.csv"};


1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

As items are removed from the the list they get fewer than "NOF" and eventually i will exceed the current number of list items.

To avoid this, remove from the end:

For(i = NOF, i > 0, i--, ...)

1 REPLY
ms

Super User

Joined:

Jun 23, 2011

Solution

As items are removed from the the list they get fewer than "NOF" and eventually i will exceed the current number of list items.

To avoid this, remove from the end:

For(i = NOF, i > 0, i--, ...)