ReadData Question
BlitzMax Forums/BlitzMax Beginners Area/ReadData Question| 
 | ||
| Hi, I have a list of different music files in a list of DefData statements at the bottom of my program, for example, #Level01 DefData "Level01" # Level02 DefData "Level02" and so forth... I want to be able to select my label, like RestoreData Level01, read the data statement, to get the song to play and then play it. Currently I am doing this, 
Local Music:String
RestoreData Level01
ReadData Music
Select Music
    Case "Level01"
         PlaySound(Level01)
    Case "Level02"
         PlaySound(Level02)
End Select
Is there a simpler way so that I do not have to use the Select part. Can I just do a PlaySound(Music) somehow? Thanks for any advice. Jason. | 
| 
 | ||
| Probably a TMap would be best in this scenario. More here. | 
| 
 | ||
| Do your maps load/save from a file? You really should define things like that outside of code (not hardcoded). In any case: Obviously that could be automated, and you could even then use this technique to load the associations from a file. | 
| 
 | ||
| I`m just experimenting at the moment. If I were making a real game then yes, I would load my resources from outside of my code. Thanks for the example though Plash and thanks for the TMap link GfK, I`ll check it out. Jason. |