Reading String from last character downwards

sabzam
Member Posts: 1,149
Hi to everyone,
How can I read a string from the last character backwards and stopping for example when a '\' is found? What I am doing is trying to get the file name from a whole path
Can anyone help pls?
Regards
How can I read a string from the last character backwards and stopping for example when a '\' is found? What I am doing is trying to get the file name from a whole path
Can anyone help pls?
Regards
0
Answers
-
Not exactly what you asked for, but i used this for separating filename and directory from a given path.
WHILE STRPOS(filename,'\') <> 0 DO BEGIN path += COPYSTR(filename,1,STRPOS(filename,'\')); filename := DELSTR(filename,1,STRPOS(filename,'\')); END;
0 -
Or:
FOR i := STRLEN("MyString") DOWNTO 1 DO BEGIN MESSAGE('%1',COPYSTR("MyString",i,1)); END;
:?:0 -
Thanks for your answer,
The function as it is gets the path a removes the file name
But what if I needed the file name instead of the path?
Regards0 -
check this thread: viewtopic.php?f=23&t=29284&hilit=SplitDirFile
the SplitDirFile function does what you need, i believe.kind of fell into this...0 -
Thanks alot for the thread....problem solved0
-
[The use of [SOLVED] in the Topic Title is no longer supported. Please edit the first message in the thread and use the field Attribute (below the Subject-field) to put a green checkmark next to the Topic Title]0
-
In my example the variable path holds the path and the variable filename the filename.
Really..
Try it0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions