Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: GreenBanana on August 03, 2010, 03:46:00 pm

Title: How do you check for file type in RGSS?
Post by: GreenBanana on August 03, 2010, 03:46:00 pm
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. 
Title: Re: How do you check for file type in RGSS?
Post by: ForeverZer0 on August 04, 2010, 09:08:51 pm
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.
Title: Re: How do you check for file type in RGSS?
Post by: Zeriab on August 05, 2010, 07:53:42 am
Here is a regular expression which you can use.
/\.[^\.]*\Z/
Title: Re: How do you check for file type in RGSS?
Post by: ForeverZer0 on August 05, 2010, 12:18:43 pm
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...
Title: Re: How do you check for file type in RGSS?
Post by: Zeriab on August 05, 2010, 03:27:47 pm
I made it as an example for my RegExp tutorial ^_^
Title: Re: How do you check for file type in RGSS?
Post by: ForeverZer0 on August 05, 2010, 04:25:14 pm
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