Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Filenames and the Index Function
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
recneps




PostPosted: Fri Apr 30, 2004 7:38 pm   Post subject: Filenames and the Index Function

Ok, i want to separate the filename fromt he file path which is entered by the user. How would i do this? like...
i want to find the last / or \ in the path and then save all letters after that as the filename. Im not very good with the index function. could someone help? Smile
Sponsor
Sponsor
Sponsor
sponsor
Raugrist




PostPosted: Sat May 01, 2004 7:19 am   Post subject: (No subject)

Index is good for the first occurence. if you want the last, I'd use a decreasing for loop.
code:

for decreasing i : length (path) .. 1
    if path (i) = "/" then
        filename := path (i + 1 .. *)
    end if
end for

You could also check for "\\" in the path if that's what you chose to use, but come on, just stick with the single slash in your pathnames.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: