Gfa_CopyFile Command and Gfa_InlFileName Function

Syntax

Gfa_CopyFile src$, dest$

$ = Gfa_InlFileName(n%)

Description

Copies a (normal) file src$ to a new ':Files' inline resource with its name specified in dest$. The destination name must start with the semi colon : to prevent errors.

Gfa_CopyFile "e:\cparse\icodeb.ico", ":icodeb"

To delete an entry in the ":Files" tab specify the empty string for src$ and its resource name is dest$.

Gfa_CopyFile "", ":icodeb"

To copy the data from the inline resource section to a normal file use CopyFile.

CopyFile ":icodeb", "e:\cparse\icodeb.ico"

Note Most GFA-BASIC 32 functions that perform file I/O are capable of loading resources from the inline section directly. These commands and functions parse the filename for a starting colon, and assume an inline resource when found. For instance

PlaySound ":dingwav"

or 

Open ":menutext" for Input As # 1

Gfa_InlFileName(n%) returns the :File name with specified index n%. When n% (1, 2, …, n) is larger than the number resources the function returns the empty string.

Remarks

GFA-BASIC 32 supports so called inline files or, otherwise put, it allows for including raw data into the project file. These raw data entities are placed in a packed, mime-encoded data format at the end of the project file.

The inline resources are maintained in the ":Files" tab in the sidebar. When you right click in the client area of the ':Files' tab, a context menu will popup to allow for data insertion by loading a file or by pasting from the clipboard. In addition, when one of the loaded GFA Editor Extensions includes the Gfa_OnDropInl event sub, the ':Files' tab will become a drag and drop window and one or more file may be dropped. Inline files can not be used in GLL and Library projects.

The inline files are accessed through the GFA-BASIC 32 Open For Input As # statement. Once opened the resources can be read as any other file, GFA-BASIC 32 will decode and unpack on the fly.

When a resource must be used in other functions (API functions for instance), the resource must be copied to disk before it can be used. To copy the file you should use CopyFile or FileCopy. Usually, the file is copied to a temporary directory and killed after it is used.

Other functions that can load inline resources are LoadPicture and LoadCursor. Inline resources that are used without GFA-BASIC 32 commands must first be copied out of the inline section to a temporary file on disk before they can be accessed. After using the external file it is then deleted (most often). See LoadBmp.

See Also

Gfa_OnDropInl, CopyFile

{Created by Sjouke Hamstra; Last updated: 07/07/2022 by James Gaite; Other Contributors: Jean-Marie Melanson}