Desktop AND Console in one APP

Is there a way to create a SINGLE project the can be compiled as both a Desktop/GUI app and a Console app…
Its not complex… but I need to test a class object in both environments… and while I can copy/paste into two projects, I’d rather not if possible

  • the GUI app, has a window with ONE button, clicking it executes a test routine (encased in a single Module and a single Class… the module has the test cases that are applied to the class)

  • when the test cases are complete, it will have created 3 files on the desktop, AND created 3 picture objects which it will display on a tabbed canvas

  • the Console app has the exact same Module and class, but obviously no controls

  • when it completes it will (hopefully) have created the same 3 files, but NOT the picture objects (the module has TARGET pragmas to control this)

If it can’t be done, or is a lot of work to do so, I’ll just make two projects

would still be interested in an answer… but realized it would be just as easy to export the module and the class and make two projects :slight_smile:

No

Thanks… short and to the point :slight_smile:

Two projects + external classes is probably your best bet.

This is something that we need to solve over the next few weeks. We have a single project that we need to build either as a single GUI application or a GUI application + two console apps. Code wise we are there. We just need to structure things correctly from a project point of view.

You can share classes either as external items or, if saved in text (version control) format, copy/paste the classes, then modify the manifests manually so they point to the same disk files. The XojoUnit project gives you an example of that.

If you do the latter, be careful to reload project X if you change one of the shared classes/modules in project Y.

I went with the external classes… thanks guys…
the cool thing is you can have both projects open… and if you change the class in one project and save it
it updates itself in the other project window automagically. I was afraid I’d have to be opening and closing projects to test, turns out I didn’t :slight_smile:

You can write an app which does both.
So if you do all in app.open and don’t init GUI stuff, you can have it console only.

See app.ArgumentsMBS function to get arguments.

[quote=293025:@Christian Schmitz]You can write an app which does both.
So if you do all in app.open and don’t init GUI stuff, you can have it console only.[/quote]
No… then you have an app using the GUI framework with no interface… not even close to the same thing.
The underpinnings of a “GUI” app (ie. App.Open), vs a “Console” app (ie. Run) are totally different

If you do it right your gui app can still process parameters and exit before the GUI things initialize.
So no dock icon and behavior like Console app.

See also StdoutMBS class
http://www.monkeybreadsoftware.net/class-stdoutmbs.shtml

Just because it looks like a duck and quacks like a duck doesn’t mean its a duck.

They use DIFFERENT FRAMEWORKS, therefore they are NOT the same…
I don’t want to make it “look like a console” I need it to be a console

[quote=293025:@Christian Schmitz]You can write an app which does both.
So if you do all in app.open and don’t init GUI stuff, you can have it console only.[/quote]
This ISN’T a console app
It’s a headless GUI app
And it will still have requirements for a user login window server etc

Its NOT a “console” app in the same way a Console project in Xojo is
You could not daemonize it and run it via cron without a user login

A Windowless desktop app won’t even start if one tries to use it on a web server, for instance. Simply because even if it is a Ubuntu server, it has no UI layer.

That’s not what I normally want in that case.
The goal here for desktop and console in one app is to have choice.
You can launch it with command line tools as console app in terminal and use it in bash scripts.
Or you double click it for the GUI app.

That has nothing todo with cron jobs, running on a web server or running headless.

it has everything to do with it as it is still NOT a “console” app and if you ssh into that machine it wont run

its a faceless gui app which is not the same

Christian… this is not about what YOU want… YOU didn’t ask the original question. it is about what I want, and a headless GUI app is NOT what I want :slight_smile:

bout time to lock/delete this topic.
The answer is NO it can’t be done.
The best thing is to use externals so two projects can share (which is what I have done)

Thanks

Than go with two projects and be happy. :slight_smile:

Christians answer is an answer to a slightly different question than was asked

His answer is for a question which might be phrased as “Can I create one project that creates ONE app that can be run as a GUI app and as a faceless GUI app that is its own own helper app” - yes … Christians answer lets you do that
But its still a GUI app in both cases - and that has some implications like the faceless instances NOT being real console apps so you cant run them with out a user login or window server

But thats not the same as “Can you create ONE project that turns out a GUI app AND a CONSOLE app” - no thats not possible