I have a really basic JSL question, I hope.
I'm using this line to create a list of words in a string.
all_list = words(first_string, " ");
I then want to loop all the words in all_list and get rid of any words that are a length of three or less.
How do I set up that loop?
Thanks in advance!
One approach is to use the Remove From() function in a reversed loop, i.e. removing items from the end of the list to preserve the list item numbering.
"Change the scale of a plot by clicking in the frame with the Magnifier tool or by rescaling the axes";
all_list = Words( first_string, " " );
For( i = N Items( all_list ), i > 0, i--,
If( Length( all_list[i] ) <= 3,
Remove From( all_list, i, 1 )
Show( all_list );
Just trying to ask a related question....how can one save a list into a data table OR text file? I have looked through the JSL scripting guide and have not come across any functions to convert a list to data table. Any help is appreciated!
The scripting index is helpful in this regard. To set values in a column in a table:
column(dt, "My Column Name") << set values(all_list);
To save a list to a text file:
save text file("c:\temp\myfile.txt", char(all_list));
// To save each entry on its own line:
all_text = concat items(all_list, "
save text file("c:\temp\myfile.txt", all_text);