? Getting MML DATA ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Oh boy, the Spring Programming contest is almost over!

Getting MML DATA

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
Author
12Me21
Updated
Rating
1 vote
Categories
Keywords
0 Comment(s)