LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Getting MML DATA

Root / Submissions / [.]

12Me21Created:
MML DATA is usually formatted like:
@SONG_NAME
DATA "ABCDEFG"
DATA "more MML"
DATA "etc."
DATA 0
This makes it easy to use BGMSETD, but since it uses string AND number data, it's hard to read it all using READ. You can't just do something like
WHILE 1
 READ DATA$
 IF DATA$==0 THEN BREAK
 SONG$=SONG$+DATA$
WEND
However, if you use READ on an undefined variable, its type will change to whatever type of data there is.
DEF LREAD SONG$ OUT ENDED%,TEMP_
 READ TEMP_ 'TEMP_ is undefined now, so you can READ any type of DATA
 IF (TEMP_||0)==3 THEN 'check if TEMP_ is a string
  INC SONG$,TEMP_
  ENDED%=FALSE
 ELSE 'if TEMP_ isn't a string, there's no more MML DATA
  ENDED%=TRUE
 ENDIF
END

'Main function
DEF READSONG$()
 VAR SONG$
 VAR ENDED%
 REPEAT
  LREAD SONG$ OUT ENDED%,
 UNTIL ENDED%
 RETURN SONG$
END
You can now do something like:
RESTORE @SONG
PRINT READSONG$()

@SONG
DATA "T200"
DATA ":0[CDEFGAB]"
DATA ":1<[CDEFGAB]"
DATA 0

is it useful though?