Reading filenames up to certain position.
-
tiago
- Posts: 589
- Joined: 14 Feb 2011 21:41
Reading filenames up to certain position.
How to read each filename up to letter in position X from left to right, right to left...? Is there a command I am missing? substr() gives me a specific string but not whole sections. strpos() and strlen() are close but amiss either.
Power-hungry user!!!
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: Reading filenames up to certain position.
What do you mean by "whole sections" ?tiago wrote:How to read each filename up to letter in position X from left to right, right to left...? Is there a command I am missing?
substr() gives me a specific string but not whole sections.
strpos() and strlen() are close but amiss either.
Examples please.
substr(string, [start], [length])
Give me first three signs of string "string":
msg substr( "string" , , 3 ); // 'str'
Give me last three signs of string "string":
::msg substr( "string" , strlen( "string" ) -3 , ); // 'ing'
Give me three signs starting at sign 2 of string "string":
::msg substr("string", 1, 3); // 'tri'
Note:
Calculation starts from '0': first sign/char is at pos '0'
Start point '0' and end point 'last sign of string' are implicit and must not be entered into the command.
-
tiago
- Posts: 589
- Joined: 14 Feb 2011 21:41
Re: Reading filenames up to certain position.
substr(string, [start], [length]) is what I need, and I probably overlooked it on help and misunderstood the meaning of "lenght". Thank you Stefan.
Power-hungry user!!!
XYplorer Beta Club