プレイ日記
☆CodeZeяo☆ Code-Zero-666
what am I doing wrong with MID$() ???
5そうだね
プレイ済み
返信[1]
親投稿
ĦHarry Ramstrong
You need to specify three things: The string, the position within the string, and the number of characters starting from that position.
2そうだね
プレイ済み
返信[2]
親投稿
☆CodeZeяo☆ Code-Zero-666
so if I used GAMESAVE$=GAMESAVE$+hp$+SP$ then Save "txt:gamesave", GAMESAVE$ ---- then I loaded it how would I use MID$()?
0そうだね
プレイ済み
返信[3]
親投稿
calc84 calc84maniac
You would probably want to separate your numbers with some kind of delimiter like a space or comma or something so you can tell where one value ends and the next one starts. For example, if you had HP$="1337" and SP$="42" you would end up with GAMESAVE$="133742", and there is no way to say you didn't start with HP$="133" and SP$="742". You can then use INSTR to search for the delimiter.
2そうだね
プレイ済み
返信[4]
親投稿
calc84 calc84maniac
For example, if you were using a comma: START=0 COMMA=INSTR(START,GAMESAVE$,",") HP$=MID$(GAMESAVE$,START,COMMA-START) START=COMMA+1 COMMA=INSTR(START,GAMESAVE$,",") SP$=MID$(GAMESAVE$,START,COMMA-START) To illustrate, I assumed you put a comma after the final value. Otherwise you would need to use COMMA=LEN(GAMESAVE$) for the last one.
2そうだね
プレイ済み
返信[5]
親投稿
calc84 calc84maniac
To decrease the amount of repeated code, we can write a function to help out: DEF NEXT_TOKEN S$,I OUT TOKEN$,J J=INSTR(I,S$,",") IF J<0 THEN J=LEN(S$) TOKEN$=MID$(S$,I,J-I) INC J IF J>LEN(S$) THEN J=-1 END I=0 NEXT_TOKEN GAMESAVE$,I OUT HP$,I NEXT_TOKEN GAMESAVE$,I OUT SP$,I
2そうだね
プレイ済み