How do you check for file type in RGSS?

Started by GreenBanana, August 03, 2010, 03:46:00 pm

Previous topic - Next topic

GreenBanana

How do you check for a filetype in RGSS?  I need to determine the difference between an mp3 and a midi, preferably via file extension, and preferably in a non-case-sensitive method. 

ForeverZer0

What do you need it for. Depending on the application, you probably will not even need to know it. I know RGSS does not require the extension when loading files from the Cache, etc.

If that is not your problem, the simplest way to do it that I know would be to create a RegExp to look for the pattern of the file type you are searching for from the file's name.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Zeriab

Here is a regular expression which you can use.
/\.[^\.]*\Z/

ForeverZer0

Quote from: Zeriab on August 05, 2010, 07:53:42 am
Here is a regular expression which you can use.
/\.[^\.]*\Z/



Thanks you. I am not too savvy with RegExp, I would have had to research the exact syntax for that...
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Zeriab

I made it as an example for my RegExp tutorial ^_^

ForeverZer0

Quote from: Zeriab on August 05, 2010, 03:27:47 pm
I made it as an example for my RegExp tutorial ^_^


Been a while since I read it...I better brush back up on it.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.