Page 1 of 1 1
Topic Options
#122130 - 2004-07-03 06:11 PM Read file name from string
operez Offline
Getting the hang of it

Registered: 2003-08-08
Posts: 75
Is it possible to read a string (with Path\File Name) and just get the file name? Or how do I get to the end of the line and walk backwards until I get to the '\' back slash, without also picking up any command line arguments?
Top
#122131 - 2004-07-03 06:29 PM Re: Read file name from string
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see split()
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#122132 - 2004-07-03 07:05 PM Re: Read file name from string
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Split() is your friend but if you need to parse off args as well, it could get complicated. You may have to double-split and join to get what you're after.

The command can be split on the hacks '\' since they cannot exist in a folder or file name, but the args could be more challenging. The prob is that args are usually separated by spaces and spaces are valid characters in folder and file names. Sometimes args may be prefaced by hyphens '-' and whacks '/' or contain equals '=' somewhere in the middle.

How is it that you may have a string in KiX that includes path, command, and args and not know where one starts and the other ends? If you explained exactly what you are trying to do, there may be some better ideas.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.055 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org