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

Click For Summary
The discussion revolves around how to remove an element from an array in BASIC and adjust the array size accordingly. The method involves shifting elements down to fill the gap left by the removed item and then reducing the array size variable. Participants noted that the approach may vary depending on the specific dialect of BASIC being used, with some versions supporting dynamic arrays and others not. It was suggested that using a secondary array or a flagging system could help manage active records more effectively. Overall, the conversation highlights the limitations of BASIC for dynamic data management and the need for alternative approaches in more complex scenarios.
  • #31
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.
 
Technology news on Phys.org
  • #32
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.)
 
  • #33
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 256bits

Similar threads

Replies
20
Views
2K
Replies
235
Views
13K
  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
43
Views
5K
Replies
47
Views
5K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
22K
  • · Replies 397 ·
14
Replies
397
Views
19K