Jump to content


Photo

checking which file format


  • Please log in to reply
3 replies to this topic

#1 Misu

Misu

    Awesometasticness!

  • GMC Member
  • 435 posts
  • Version:GM:Studio

Posted 07 April 2012 - 12:11 AM

I have to type of ini file formats:
*.cl9
*.bbxd

So I'm using this type of code to open up files:
levelname = get_open_filename("BBXD Level (.bbxd)|*.bbxd|Chain Level(.cl9)|*.cl9",".bbxd")

Now my question is:
Is there a way to check which type of file is being opened?

What I'm asking for is something like this:

if format == ".cl9"
{/*blah blah blah*/}

:mellow:
  • 0

#2 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2297 posts
  • Version:GM7

Posted 07 April 2012 - 12:27 AM

Edit: Hrm nevermind, going to have to look at exactly how get_open_filename works
Edit: Also, if you need to know way after you've opened it what type of file it is, why not store the file and filetype as a key inside your ini?

Edited by greep, 07 April 2012 - 01:06 AM.

  • 1

#3 GameDevDan

GameDevDan

    Procrastinator

  • Reviewer
  • 942 posts
  • Version:GM:Studio

Posted 07 April 2012 - 08:51 AM

if ( filename_ext( levelname ) == ".cl9" ) {
 //PERFORM STUFF 
}

Does that work?

Edited by GameDevDan, 07 April 2012 - 08:52 AM.

  • 1

#4 Misu

Misu

    Awesometasticness!

  • GMC Member
  • 435 posts
  • Version:GM:Studio

Posted 07 April 2012 - 01:24 PM

I already tried with Greeps idea and I was able to pull this one off. But I haven't seen GameDevDan's code since i left to bed early. I tried it now and it caused a glitch where it opens the file many times without stop. However, I'm going with Greeps idea since I already tried it and worked very well. Thanks guys! :thumbsup:
PS:
Here is what I did:

Script213:
var ii, ee, oo;
for (ii=0; ii<40; ii+=1)
{
ee=string_char_at(levelname,ii)
   if ee=="."
{
      oo=string_copy(levelname,ii,4)
      return oo
}
}

code for opening a file:
levelname = get_open_filename("BBXD Level (.bbxd)|*.bbxd|Chain Level(.cl9)|*.cl9",".bbxd")
yuo=script213()
if yuo==".cl9"
{/*blah blah blah*/}
if yuo==".bbx"
{/*blah blah blah*/}
else
{show_message("Opening non-compatible file!")

Edited by MisuMen49, 07 April 2012 - 01:29 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users