So, you're expecting a 10-digit integer. Okay.
Your input line is great. But right after, you first have to get a string version of
G%, since it's an integer.
G$=FORMAT$("%010D",G%)
G$ is now a string representing
G%'s value a certain way. Let's look at that format string for a sec:
%010D
The
FORMAT$ function takes a
format string, and then some number of inputs. The inputs are then used to generate a string based on the provided format. This means the input is an integer, and we want it turned into an integer in base-10, ten digits long, with leading zeros. The upshot of this is that if the user inputs a number less than 10 digits, the rest at the beginning are filled in with zeros. 20 would become 0000000020, for example.
Since you're always expecting ten digits, we make
AREAS% be ten entries.
DIM AREAS%[10]
We don't need to fill it in with zeros, since SB does it automatically.
Now we have to split each digit (now characters in a string) and put them inside the array. A simple
FOR will do it.
FOR I%=0 TO 9
AREAS%[I%]=VAL(G$[I%])
NEXT
Instead of doing
MID$(G$,I%,1), we can do
G$[I%]. Strings support the array-bracket notation; by using it, we get the character at index
I% with a lot less code. The
VAL function here takes the character and generates the integer it represents. If we give it "0", it returns 0, and so on. It works with entire strings, too. That value is just assigned to our array index, and we're done.
This is basically just the process of turning a number into its digits, but with strings instead of math. Altogether the code is:
INPUT "Generation code: ",G%
G$=FORMAT$("%010D",G%)
DIM AREAS%[10]
FOR I%=0 TO 9
AREAS%[I%]=VAL(G$[I%])
NEXT
You could quite easily turn this code into something that handles an arbitrary number of digits, but I didn't want to burden you with that if you didn't need it.