An application without a main form ?

NRG

Member
Licensed User
Is it possible to write a console application in basic4ppc ? An app that doesnt have to show a form ? I'd like to write an app that will take some command line args, and display a notification bubble, without displaying a main form ? That possible ?
 

LineCutter

Active Member
Licensed User
Longtime User
Try the following & go from there...
B4X:
Sub Globals
    'Declare the global variables here.

End Sub

Sub App_Start
    Msgbox("Test")
End Sub
From the help file:
 
Last edited:

NRG

Member
Licensed User
Thanks. I figured it would be that easy... but last time I tried that, the app launched but didnt display anything. I was using the notification library posted here (baloon.dll). Without the main form loading, it didnt display the notification... strange.
 

mjcoon

Well-Known Member
Licensed User
AGraham was explaining in another thread recently that MsgBox is special (I think in the way that is uses the m-handling loop). Maybe that makes it different from the notification that you were using...

Mike.
 

taximania

Well-Known Member
Licensed User
Longtime User
If the baloon.dll was the library that I wrote,

You need to show a created form, then hide it.
I used a timer set at about 250ms
Otherwise the notification doesn't have a handle to grasp.

I'll recheck my posts, and post a reply tomorrow night when I finish work.
 

NRG

Member
Licensed User

Ah I see... but for those 250ms the main form will show, right ? It kind of defeats the purpose if a huge form will flash on my screen everytime I call the app to display a notification
 

derez

Expert
Licensed User
Longtime User
I have run this, compiled for desktop and it shows just the msgbox and exits:
B4X:
Sub App_Start
Msgbox("Database saved")
form1.Close
End Sub

There is a form1 defined.
Maybe the trick is in the content of the message...
 

agraham

Expert
Licensed User
Longtime User
If a form is not shown when App_Start ends the application closes. Showing a form, or running a FormEx if you are using my FormExDesktop library, starts the message loop for the application which then calls the applications event Subs as things happen. Without a message loop to run, the application - pedantically the applications main thread - terminates. A message box does run its own message loop to dispatch messages for the application while it is shown to stop the application totally freezing and to enable it to receive its own user input but this is temporary and it stops doing this when it is closed.

The blunt answer is that without a form being shown, or a FormEx run if you are using my FormExDesktop library, the application terminates at the end of App_Start.
 
noobish

Sub Globals

End Sub

Sub App_Start
For i = 0 To ArrayLen(args())-1
msgbox(args(i))
Next

Hello. I tested this example....nothing happens. Please , what's wrong?

Tools => Command Line Argumens .... what value am I to enter?
:sign0104:
 

mjcoon

Well-Known Member
Licensed User
Sub Globals

End Sub

Sub App_Start
For i = 0 To ArrayLen(args())-1
msgbox(args(i))
Next

Hello. I tested this example....nothing happens. Please , what's wrong?

I wanted to discover how Google Maps/Earth is called on the PPC so I wrote a program with exactly the same purpose as above. But I put in an empty form, as follows:
B4X:
Sub Globals
End Sub

Sub App_Start
   Form1.Show
      For i = 0 To ArrayLen(args())-1
            Msgbox(args(i), "Argument #" & i)
      Next
End Sub

Sub MenuExit_Click
   AppClose
End Sub

It worked, and now I know how to call Google passing it the name of the KML file that I have just created!

Mike.
 

taximania

Well-Known Member
Licensed User
Longtime User
Ah I see... but for those 250ms the main form will show, right ? It kind of defeats the purpose if a huge form will flash on my screen everytime I call the app to display a notification

Using my notification.dll

The form only shows when the app is 1st run. Any notifications, popups, contextmenu's etc still show as you would expect. The form is still in the background and stays hidden unless you call form.show.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…