Modify SC substr to obtain substrings divided by a separator
Posted: 05 Apr 2021 16:14
Would it make sense to have a XYplorer command which would pull a range of items from a string. For example, let's say we have a file listing, a variable called $recents from
What I was thinking is a change to SC substr which would recognize if/when a separator parameter is provided.
- existing syntax for SC:
- proposed syntax SC:
So using the above example, where
Another possibility would be a new "format" along with a parameter for SC formatlist such that if a format of "m" is given a paramenter of 2-8 would list items 2-8 after any other formatting. Though I think SC substr would be better suited. Thanks.
get("list_recentlyopenedfiles") and we would like only the first 15 files in the list. I know there are current ways to do that using a while loop with a count or foreach loop, but it would seem to be much more direct if we could accomplish that using a scripting command.What I was thinking is a change to SC substr which would recognize if/when a separator parameter is provided.
- existing syntax for SC:
substr(string, [start], [length])- proposed syntax SC:
substr(string, [start], [length], [separator=CRLF]) such that if the separator is provided, XY knows that the resultant substring is broken down by the separator not by the characters as is the current default (and would still remain the default). Most importantly this separator parameter would not affect existing use of substr w/o sep.So using the above example, where
$recents = get("list_recentlyopenedfiles"); $recent15 = substr($recent, 0, 15, <crlf>); would provide a listing of the first 15 files listed via get("list_recentlyopenedfiles").Another possibility would be a new "format" along with a parameter for SC formatlist such that if a format of "m" is given a paramenter of 2-8 would list items 2-8 after any other formatting. Though I think SC substr would be better suited. Thanks.