LoginLogin

Converting letter from a string into an array?

Root / Programming Questions / [.]

ahavasandwichCreated:
What I'm trying to do is take something like A$="HELLO WORLD" and store each letter (and spaces between word) sequentially into a one-dimensional array. I've been looking at the instruction list, but I'm still not totally sure how to go about doing this. I feel in the like the first step I should use LEN and then a FOR loop.

DIM B$[0]
FOR I%=0 TO LEN(A$)-1
PUSH B$,A$[I%]
NEXT

String characters can be indexed like an array, so I'm not entirely sure why you would need this. What do you plan on using this for?

String characters can be indexed like an array, so I'm not entirely sure why you would need this. What do you plan on using this for?
I want to make a program that can take a character string from the user via INPUT and have it played back into Morse code. So far I have coded the Morse code for each letter and number into MML. There isn't a point to making this app. I just need something to tinker with for fun.

DIM B$[0]
FOR I%=0 TO LEN(A$)-1
PUSH B$,A$[I%]
NEXT
What is I%?

It's the counter variable for the for loop, and also the index variable for accessing elements of the target array.

DIM B$[0]
FOR I%=0 TO LEN(A$)-1
PUSH B$,A$[I%]
NEXT
What is I%?
I% is a variable. The % suffix indicates the variable holds integer values the same way the $ suffix indicates a variable holds string values. From your other reply, slackerSnail is correct. You do not need to make a copy of the characters for the task you describe.
FOR I%=0 TO LEN(A$)-1
' Using the character A$[I%], transmit that one character in Morse
NEXT

I finally got some free time to study the replies y'all wrote. It's a lot more simple than I though it would be. Thanks! :)