New, Loading, and Printing

Syntax

Gfa_New

Gfa_DoNew

Gfa_Print

Gfa_Load

Gfa_LoadFile filename$ [,fMru% = 0]  (filename As String, fMru as Int)

Gfa_LoadMRU n% (n in 1..9)

Gfa_MergeFile filename$

Description

Gfa_New executes the File | New menu item creating a new project. The current project is removed and the new project gets the name 'noname.g32'. When the current project has the Gfa_Dirty status the project can be saved first.

Gfa_DoNew creates a new project without checking the Gfa_Dirty status. There is no correspondence menu item for this command.

Gfa_Print starts printing the selection or, when no text has been selected, the entire source code using the settings from the Properties dialog box.

Gfa_Load invokes the menu command <File | Load>. Gfa_Load displays a file-open dialog box, showing the current active directory.

Gfa_LoadFile loads the specified file without displaying a file-open dialog box and without providing a save option when the current project has changed.
When the optional parameter fMru% species a value other than zero (fMru <> 0) the filename is added to MRU list. When fMru = 0 or when the parameter is omitted the filename is not added to MRU list. In addition, the name of the file is not shown in the caption of the IDE and Gfa_FileName is "Noname.g32" or "OhneName.g32".

Gfa_LoadMRU loads the file with the specified MRU number. Loading the file updates the MRU list and puts the file at the top of the MRU list. The MRU list consists of the 9 menu entries in the File submenu that reflects the MRU file list in the register. In HKCU\Software\GFA\Basic the keys file1 to file9 specify the MRU list. The IDE updates the File submenu not before the File submenu is activated, in which case the IDE receives the WM_INITMENUPOPUP message.

Gfa_LoadMRU gets the filename from the <File> menu with the GetMenuString API function, not from the register. It turns out the File menu is not always up to date, for instance just after the start of the IDE when the File submenu isn't activated yet. The next example shows a modified MRU load.

Gfa_MergeFile inserts a GFA-BASIC 32 (g32) file or an ASCII file at the current position. When the file is a GFA-BASIC 32 project file, the form data and ‘:Files’ resources are inserted as well.
The IDE does not provide any means to invoke this command. The example shows how to add the file insertion functionality.

Example

 

Sub LoadMRU(Optional FileNo As Int = 1)

' The Gfa_loadMRU command gets the filename from the menu entries

' in the File submenu. However, the submenu items are not updated

' before the File submenu is actually selected, in which case

' the MRU filelist is read from the registry. Occasionally, the

' file to load isn't added to the submenu yet. Instead we must get the

' MRU file name from register directly.

Local String MRU = Gfa_Setting("File" $ Dec(FileNo))

If Exist(MRU)

Gfa_LoadFile MRU, 1         ' 1=add to MRU, 0=don't

EndIf

EndSub

The following example adds a menu item to the Extra menu to create an event sub to insert a file using Gfa_MergeFile:

 

Sub Gfa_Init

Global Int IdxMerge = Gfa_AddMenu("Insert file ...", menuMerge)

Gfa_MenuDesc(IdxMerge) = "Inserts the contents of the specified file at the current location."

End Sub

 

Sub menuMerge(i%)

Local fname As String

FileSelect # "Insert file", CurDir + "\*.*", "", fname

If Exist(fname)

Gfa_MergeFile fname

EndIf

EndSub

Remarks

See Also

Gfa_Save

{Created by Sjouke Hamstra; Last updated: 20/10/2014 by James Gaite}