suggestion: initialize array values within the DIM statement
#2
I suppose there are a couple of ways it could be coded into a function...

Code: (Select All)
DIM AS LONG LNUMS(5)
RESTORE mytmp
DIM a AS LONG
FOR i = 1 TO UBOUND(LNUMS)
    READ a
    LNUMS(i) = a
NEXT

mytmp:
DATA 1,2,5,8,4000

' Proof.
FOR i = 1 TO UBOUND(LNUMS)
    PRINT LNUMS(i)
NEXT

'--------------------- Next method...
ERASE LNUMS
'--------------------- Begin...

a$ = "{1, 2, 5, 8, 4000}"
a$ = MID$(a$, 2, LEN(a$) - 2)

FOR i = 1 TO UBOUND(LNUMS)
    j = INSTR(seed, a$ + ",", ",")
    LNUMS(i) = VAL(MID$(a$, seed + 1, j - seed - 1))
    seed = j + 1
NEXT

' Proof
FOR i = 1 TO UBOUND(LNUMS)
    PRINT LNUMS(i)
NEXT

I suppose it all depends on finding a dev who could use it frequently enough to include it in a future release.

Pete
If eggs are brain food, Biden takes his scrambled.
Reply


Messages In This Thread
RE: suggestion: initialize array values within the DIM statement - by Pete - 12-21-2022, 05:23 AM



Users browsing this thread: 8 Guest(s)