Searching for empty arrays

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
kinosh
Newbie
Posts: 1
Joined: Mon Jan 23, 2017 7:49 pm

Searching for empty arrays

Post by kinosh »

I have an array, some contain strings and some are empty (no integers). Is there a way to find the empty arrays?
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: Searching for empty arrays

Post by burger2227 »

LEN can tell you how long a string is in each part of the array. 0 is an empty index.

Code: Select all

DIM array$(100)

FOR i = 0 TO 99  'set indices 
    array$(i) = "AA"
NEXT

PRINT array$(50)  'read an index
PRINT LEN(array$(50)) 'display length of string

PRINT LEN(array$)
You will have to read each index using a FOR loop.
LEN can NOT be used on numerical arrays as it will only show the number's
byte size which never changes even for 0.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Post Reply