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

Click For Summary
SUMMARY

The discussion focuses on removing an element from an array in BASIC programming. The method involves shifting elements down to fill the gap left by the removed element and then adjusting the array size using the ReDim statement. Participants highlight the importance of understanding the specific dialect of BASIC being used, as techniques may vary, particularly between older versions and modern dialects like Visual Basic. The conversation emphasizes the limitations of arrays in BASIC and suggests using lists for dynamic data management.

PREREQUISITES
  • Understanding of BASIC programming syntax and structure
  • Familiarity with array manipulation techniques in BASIC
  • Knowledge of the ReDim and ReDim Preserve statements
  • Awareness of different BASIC dialects, such as Liberty BASIC and Visual Basic
NEXT STEPS
  • Research the differences between Liberty BASIC and Visual Basic for array management
  • Learn about using lists and collections in Visual Basic for dynamic data handling
  • Explore the ReDim Preserve functionality in various BASIC dialects
  • Investigate the flag technique for managing active elements in arrays
USEFUL FOR

Programmers working with BASIC, particularly those needing to manipulate arrays, as well as educators teaching array concepts in programming courses.

  • #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   Reactions: 256bits

Similar threads

Replies
20
Views
2K
Replies
235
Views
14K
  • · 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
20K