Available on: all targets
See also: BEGIN STORAGE

FILE (storage)

Inside a BEGIN STORAGE...END STORAGE block, the FILE command plays a crucial role in the process of embedding external data directly into the storage medium you are defining while compiling your program. Imagine you want to include a set of configuration data or any other static file directly into your program's storage medium, the FILE command allows you to do just that.

The basic syntax is to indicate the name of the source file that will be inserted into the media. If you do not want to use the same name, you can indicate an alias (AS target).

The addition of the CSV OF type statement is a powerful feature that allows you to include Comma Separated Values (CSV) files and specify the data type of each column. Instead of treating the CSV file as a simple block of bytes (as the FILE statement alone would), the compiler will parse the contents of the CSV file and convert it into a more structured internal representation that is ready for use by your program. The kind of structure will be described by the datatype type.

SYNTAX

 FILE source [AS target] [CSV OF type]


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 FILE "examples/data.dat"
 FILE "sprites.png" AS "sprites.dat"
 FILE "examples/data.csv" CSV OF BYTE
 BEGIN TYPE point
     x AS POSITION
     x AS POSITION
 END TYPE point
 FILE "examples/structure.csv" CSV OF point


Used in:

ABBREVIATION: FILE

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

FILE (storage) ↔ FILE

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS