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
Posts: 1
Joined: Mon Jan 23, 2017 7:49 pm

Searching for empty arrays

Post by kinosh » Mon Jan 23, 2017 7:53 pm

I have an array, some contain strings and some are empty (no integers). Is there a way to find the empty arrays?

User avatar
Posts: 2407
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: Searching for empty arrays

Post by burger2227 » Wed Jan 25, 2017 8:49 pm

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"

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 :
Get my Q-Basics demonstrator: ...

Post Reply