|
Post by jarychk on Jul 23, 2024 6:28:04 GMT
This is made just for relearning how to remove one array element. Example is first few letters of alphabet, and includes initially an item which not belong in the list.
Basic idea is begin at the index of the item to be removed and change the rest of elements of array in a FOR loop.
'removeonearrayelem 'relearning how to remove one array element and shrink array by 1
dim arr$(25)
arr$(1)="A" arr$(2)="B" arr$(3)="C" arr$(4)="booboo" arr$(5)="D" arr$(6)="E" arr$(7)="F" arr$(8)="G" arr$(9)="H"
print "original array" for i0=1 to 9 print arr$(i0);" "; next i0
rem routine to eliminate item number 4, booboo for i1=4 to 9-1 let arr$(i1)=arr$(i1+1) next i1
LET arr$(9)=""
print "Checking those results :" for i2=1 to 9-1 print arr$(i2);" "; next i2
END
|
|