[BASIC language] Removing an array element -- how?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
32 replies · 3K views
Liberty BASIC appears to be missing much of the structured data that is in VB and FB.
Being limited to a 2D array makes it more of a teaching language than a productive workhorse. $60 seems a high price to pay for restricted features, when it can be fully featured, open source, and free.

But BASIC is quite capable of the task. I would start with a record structure for the file storage, then write routines to read and write that to an array, with a validity flag to make deletion easy. Reading the file into the array, editing, then writing it back PRESERVEs data, and eliminates deleted data. REDIM the dynamic array to fit the size of the data file it must hold. For data entered by hand, cheap memory and disc storage are not a limit. The limit is your ability to structure the data record.
 
Physics news on Phys.org
Baluncore said:
But BASIC is quite capable of the task. I would start with a record structure for the file storage, then write routines to read and write that to an array, with a validity flag to make deletion easy. Reading the file into the array, editing, then writing it back PRESERVEs data, and eliminates deleted data. REDIM the dynamic array to fit the size of the data file it must hold. For data entered by hand, cheap memory and disc storage are not a limit. The limit is your ability to structure the data record.
Much of what you characterize there is what I have spent the last two or three weeks relearning. (and I have not finished this relearning.)
 
256bits said:
Not sure if one can delete unused memory in any Basic version? such as for an array that does not need its use anymore.
REDIM Array( 0 [,0] ) releases the memory.
Memory is released when an array or variable is lost from scope.
If you can do something in C, you can do it in FreeBASIC, because FB is now a frontend that translates to C, links to libraries, optimises and compiles to various platforms.
 
  • Like
Likes   Reactions: 256bits