Day 026: ERASE
#4
> I may or may not know what I'm talking about today.

Dammit! I was just about to use that as my signature. Now I have to come up with something else. Too bad Steve is busy! Big Grin

Yes, there is some interesting behavior in subs. For example...

Code: (Select All)
CALL pete

a(5) = 7
PRINT "a(5) back in main:"; a(5) ' This works. An un-passed un-shared dynamic array in a sub had the initialization maintained.

REDIM b(10) ' Dynamic array in the main.
b(5) = 3
PRINT "b(5) in Pete sub:"; b(5)
ERASE b
PRINT "b(5) after ERASE is non-existent."
PRINT "See? We now get a subscript out of range error at the next line..."
b(5) = 7 ' Errors out. This dynamic array in the main was de-initialized, as expected.

SUB pete
    REDIM a(10) ' Dynamic array in a sub.
    a(5) = 3
    PRINT "a(5) in Pete sub:"; a(5)
    ERASE a
    PRINT "a(5) after ERASE is non-existent."
END SUB

Also, as a slightly related side note, CLEAR removes the initialization of dynamic arrays, but not a static ones, but CLEAR cannot be used in a sub.

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


Messages In This Thread
Day 026: ERASE - by Pete - 12-07-2022, 07:24 AM
RE: Day 026: ERASE - by mnrvovrfc - 12-07-2022, 10:39 AM
RE: Day 026: ERASE - by bplus - 12-07-2022, 05:20 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 05:36 PM
RE: Day 026: ERASE - by bplus - 12-07-2022, 08:18 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 08:31 PM
RE: Day 026: ERASE - by SMcNeill - 12-07-2022, 10:13 PM
RE: Day 026: ERASE - by mnrvovrfc - 12-07-2022, 10:45 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 10:54 PM
RE: Day 026: ERASE - by sivacc - 06-10-2023, 06:28 PM
RE: Day 026: ERASE - by TerryRitchie - 06-10-2023, 06:31 PM
RE: Day 026: ERASE - by SMcNeill - 06-10-2023, 06:35 PM
RE: Day 026: ERASE - by bplus - 06-10-2023, 06:39 PM



Users browsing this thread: 9 Guest(s)