Poco Script FAQ - Extract the extension from a file name

Poco Script FAQ - Extract the extension from a file name

Q: have looked through alot of the operations found within the Poco scripting language, but can't seem to come up with anything that'll extract the extensions (or even substrings) from a string, given a passive location... for instance, a great way to extract an extension would be to have some way to just clip/read the last 4 characters on a filename string, thus giving the user .txt, .bat, .uhm ...etc. Would anybody be able to come up with a quick subroutine to do such a task?
 
A: To retrieve the last 4 characters of string $filename you would use: CharCount #len $filename Set $extension $filename SubIntegers #len 4 ChopString $extension 1 #len Note: There is no error checking here, you should check for a length of 4 or less to avoid potential errors. A better means of doing this would be to check for the position of the last "." (using a loop and the StringPos function) and extract it and all characters following it.