Auto make the project executable (it has it's uses)

Post your Gambas programming questions here.
Post Reply
Posts: 838
Joined: Thursday 23rd July 2020 5:20pm

Auto make the project executable (it has it's uses)

Post by BruceSteers » Sunday 8th August 2021 2:54pm

I've added this to one of my programs...
It automatically makes the executable in the project folder if it's being run from the IDE
(Args[0] will just be the app name if run from ide or it's path if run via the executable)

Public Sub _new()
  Dim sArgs As String[] = Args.All.Copy()

 ' With this command the project executable is compiled as it's launched (If run from the IDE Arg[0] has no path).
  If Not InStr(Args[0], "/") Then

  sArgs[0] = Application.Path &/ Application.Name
  If File.Ext(sArgs[0]) <> "gambas" Then sArgs[0] &= ".gambas"
    If Exist(File.Dir(sArgs[0]) &/ ".project") Then Shell "echo -n 'Run from IDE so compiling exe... '\ncd '" & File.Dir(sArgs[0]) & "'\ngbc3 -xawg\ngba3\necho 'Compiling complete'" Wait

This is useful for a couple of things at least...

You know when you have been testing an app (using the Run button in the IDE) and made changes but you forgot to hit "Make Executable" so you're still on the old version.
No worries it's already been compiled :)

Also if you are testing an app like some of mine that support drag-dropping onto the launcher icon.
these apps apps run the executable, i also have apps that only use one instance and other launches activate the open app. things like that need the executable made each time for testing.

Maybe you have had other reasons that you needed the Executable made every time you tested your program?

Post Reply