Skip to content

Language Reference ‐ Streams Library

Andreas AFENTAKIS edited this page Oct 28, 2025 · 2 revisions

Language Reference ‐ Streams Library

The Streams Library in FAST.FBasic offers robust support for file and memory stream operations, enabling advanced IO workflows and data manipulation within programs.

Stream Statements

FILESTREAM

Declare a file-based or in-memory stream and assign it a name.

FILESTREAM stream_name, in|inmemory|out, library, path, file_name
  • stream_name: Unique identifier for the stream.
  • in | inmemory | out: Specify input stream, in-memory stream, or output stream.
  • library: (Optional) External library used for stream handling.
  • path, file_name: Location and name of the file (for file streams).The
  • The IN stream, is only for input, the OUT is only for output. The INMEMORY implementation initally opens the file as input stream and then copy it to a MemoryStream. Memory Streams are suitable of opearations that will modify the content.
Important
References to File System operations is a subject of the implementation of the IFBasicFileManagementLayer interface. It is not part of the FBasic interpreter. Library, Path, File are concepts where are handled by the File Managment Layer. The default layer, if no other specified, is using a Root Path that the .NET application should provide and then the Path if the path to file after the Root Path and the Fileis the file name, with the extension. The library is not used.

SCOPY

Copy the contents of one stream into another.

SCOPY source_stream, destination_stream
  • source_stream: The stream to copy data from.
  • destination_stream: The stream to copy data into.

MEMSTREAM

Create a new in-memory stream for fast, temporary access.

MEMSTREAM stream_name
  • stream_name: Identifier for the memory stream.

SREWIND

Rewind a stream to the beginning.

SREWIND stream_name
  • stream_name: Identifier of the stream to rewind.

Planned Stream Statements

These statements are planned for future versions:

  • SSEEK stream_name, position: Seek to a specific position inside the stream.
  • SCLOSE stream_name: Close the stream and release associated resources.

Stream Functions

slength()

Get the total length of a stream.

slength("stream_name")
  • Returns the total length (in bytes or records) of the specified stream.

sposition()

Get the current read/write position in a stream.

sposition("stream_name")
  • Returns the cursor position inside the stream.

Remarks

  • Stream operations are essential for modular programs that perform extensive data reading and writing tasks.
  • FILESTREAM and MEMSTREAM statements let programs switch between persistent and high-speed temporary storage as needed.
  • Planned statements SSEEK and SCLOSE will enhance random access and resource management, respectively.

Clone this wiki locally