Reading Maps back in to game array?

BlitzMax Forums/BlitzMax Beginners Area/Reading Maps back in to game array?

Global mappath:String = RequestFile( "Please select a map to load")

Print mappath


Take a look at the ouput. It would be wise to check the extension type of the provided file to make sure they selected one of your map objects. To do this you can go

If Not (ExtractExt( mappath ) = "map")
   'insert code here to handle the bad file entry
EndIf


You could, for instance, just reopen the file selector dialog with a new informative message when the user selects the wrong file like so
If Not (ExtractExt( mappath ) = "map")
   mappath = RequestFile( "Please be sure the map file ends with a .map extension.")
EndIf


You may want/need to parse the path string further for whatever reason (if you wanted to extract the name of the file and display it on a menu or something). Look in the module documents under "File System" for a list of file path parsing functions.

Hope this helps! :)