Gambas Project Folders & Files

Post your Gambas programming questions here.
Post Reply
User avatar
Quincunxian
Posts: 128
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Gambas Project Folders & Files

Post by Quincunxian » Thursday 15th July 2021 11:50pm

I want to create a set of folders to store various types of data in my Gambas project area.
Is there a 'best practice' location to create these folders or is it just the project root?
This question is more around creating installation packages and where application data should go.

Anybody able to fill in the blanks and/or advise?

Folders:
.action - No idea ?
.connection - {DataBaseName}.connection if a connecton has been added.
.gambas - compiled gambas code (?)
.hidden - No idea ?
.lang - Assume translation files but not sure?
.src - Contains source files - Form.form, Form.class, {name}.class, {name}.module



Standard Project files included for completeness.

Files
.directory - Reference for the icon file
.gitignore - no idea ?
.icon.png - 256 X 256 png image file. - (If you set an icon for your project, it will be displayed in the centre of the existing icon)
.lock - No idea (locking a form in a project has no effect on this file that I can see)
.project - The base project data. Title, Start up form, a list of components in the project, etc...
.settings - Editor settings - Bookmarks, Forms Debug window Geometries,
.startup - Similar to the Project file - may be the order in which the components are to be loaded - unsure ?
Cheers - Quin.
I code therefore I am

User avatar
BruceSteers
Posts: 590
Joined: Thursday 23rd July 2020 5:20pm

Re: Gambas Project Folders & Files

Post by BruceSteers » Friday 16th July 2021 12:37am

Quincunxian wrote:
Thursday 15th July 2021 11:50pm
I want to create a set of folders to store various types of data in my Gambas project area.
Is there a 'best practice' location to create these folders or is it just the project root?
This question is more around creating installation packages and where application data should go.

Anybody able to fill in the blanks and/or advise?

Folders:
.action - No idea ?
.connection - {DataBaseName}.connection if a connecton has been added.
.gambas - compiled gambas code (?)
.hidden - No idea ?
.lang - Assume translation files but not sure?
.src - Contains source files - Form.form, Form.class, {name}.class, {name}.module



Standard Project files included for completeness.

Files
.directory - Reference for the icon file
.gitignore - no idea ?
.icon.png - 256 X 256 png image file. - (If you set an icon for your project, it will be displayed in the centre of the existing icon)
.lock - No idea (locking a form in a project has no effect on this file that I can see)
.project - The base project data. Title, Start up form, a list of components in the project, etc...
.settings - Editor settings - Bookmarks, Forms Debug window Geometries,
.startup - Similar to the Project file - may be the order in which the components are to be loaded - unsure ?
.hidden is where you'd put custom control info like my NCheckBox (it's got other uses too) this may do the job
.action get's filled when using the .Action property of controls
you are right on the other folders.

I have had issues with accessing data unless i put it in a folder called .public/ so that's what i generally do now

.gitignore is a list of filepatterns that will not upload when using "git push" to update your git repository
.project is the main project properties settings file.
not sure about the others.

check out the gambas IDE source folder https://gitlab.com/gambas/gambas/-/tree ... rc/gambas3 , it does not explain much but there is a bit more there for you to look at and go "aah , i see" ;)
(if you d/l and compile gambas the .action folder is populated)
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
Quincunxian
Posts: 128
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Gambas Project Folders & Files

Post by Quincunxian » Friday 16th July 2021 2:00am

Thanks Bruce.
.Public sounds like the place to be root for all the folders I want to create.

That makes it easier for my folder creation routine as well.
I have a class that I instigate as 'Folder' from the main module.
I assign various paths based on need so I can get dotted reference to the folders in the application.

So I can use {MainModule}.Folder.Icon16x16 to reference that location.
The actual Path would look something like this : /home/{name}/Projects/{ProjectName}/.Public/Images/Icon16x16 {while in development mode only}
You only have to change a single variable in the global module to the required path when you want to deploy the application - makes it a lot easier.

Each time you start the application, the required folders are checked for existence and created if they don't.
 Gambas class file

a'---------------------------------------------------------------------------------------------------------
' Purpose : To provide a single structure for Folder Management.
' Created : 13/08/2019
' Original Author : Quincunxian - Perth Western Australia
' Modifications Format - <Date><Modification><Date>
'---------------------------------------------------------------------------------------------------------

Private RootFolder As String = AG.ApplicationFolder   'AG = ApplicationGlobal module.

Public LastSelectedPath As String = ""   'Preserved full path from the last browse event - default is User.Home
Public SelectedPath As String = ""       'The full path selected from the the last 'Browse' event.
Public SelectedFileNames As New String[]   'The selected file names with extension if any
Public IsFileView As Boolean = True
Public TargetFolder As String = ""

Public SelectedFilter As String[]
Public FilterFile As String[] = ["*.*", "All Files"]
Public FilterImage As String[] = ["*.png;*.jpg;*.jpeg;*.bmp", "Picture files"]
Public FilterDocument As String[] = ["*.odt", "Document files"]

'----------------------Folders --------------------------------------------------------
Public Help As String = RootFolder &/ "Help"
Public Data As String = RootFolder &/ "Data"
Public Images As String = RootFolder &/ "Images"

Public SQLRefFiles As String = Data &/ "SqlRefFiles"
Public Icons16X16 As String = Images &/ "Icons16X16"
Public Icons32X32 As String = Images &/ "Icons32X32" ' This provides afolder for the Game icons
Public Pictures As String = Images &/ "Pictures"

Public Sub _new()
  
  InitialiseApplicationFolders
  
End

Private Sub InitialiseApplicationFolders()
  
  CheckFolderStructure(RootFolder)
  CheckFolderStructure(Data)
  CheckFolderStructure(SQLRefFiles)
  CheckFolderStructure(Help)
  CheckFolderStructure(Images)
  CheckFolderStructure(Icons16X16)
  CheckFolderStructure(Icons32X32)
  CheckFolderStructure(Pictures)
   
End

Public Sub CheckFolderStructure(InPath As String)
  
  If Not Exist(InPath) Then Mkdir InPath
  
End

Cheers - Quin.
I code therefore I am

User avatar
BruceSteers
Posts: 590
Joined: Thursday 23rd July 2020 5:20pm

Re: Gambas Project Folders & Files

Post by BruceSteers » Friday 16th July 2021 7:07pm

I dont know if it makes a difference or not but you said .Public , I said .public (lower case p)
Not trying to be pedantic but it might make a difference.

That looks like a cool way to store/get path names 🙂
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
Quincunxian
Posts: 128
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Gambas Project Folders & Files

Post by Quincunxian » Friday 16th July 2021 10:15pm

Yeah, it does make a difference.
I've spent some time looking for a error only to find out I'd capitalised something in a file/folder name.
That's one of the main reason I prefer setting up dotted references. - Do it once, do it right.
Cheers - Quin.
I code therefore I am

Post Reply