Best way to port code from Desktop to Console?

Hello all,

What is the best way to port code from a desktop app to a console app? In the desktop app, the form owns class objects. But in a console, there is no “form” to become the owner. So what is the best way to create an owner? The three thoughts are:

  1. The Console App object itself
  2. A new Class that holds all of the objects - there would be a single instance of this created by the Console App.
  3. A module that holds all of the objects - there would be a single instance of this created by the Console App.

The objects include AutoDiscovery subclass, Einhuger E-Net classes, timers and other similar objects.

The console is to run on an ARM.

Any thoughts, opinions, direction would be greatly appreciated!

Thank you.
Tim

So you dragged the objects onto the window in desktop? The equivalent would be to make them properties of a module and instantiate them in app.open.

Hi Tim.

Some were dragged, some were instantiated via code.

Either way, it appears you suggest the module route. To be clearer to me, all handling of all of those objects that was in the form, would be handled entirely within the module.

Correct?

Thanks Tim!
Tim

Correct.

Thought so.
Started an hour or three ago.

Thanks for the confirmation Tim.

Tim

Hi Tim.

I have one follow-up question that I was hoping you could answer:
I use the Einhuger ENetServer plugin, which wants to know who its owner is. The Einhuger sample shows how to integrate the Server part of EnetServer with a form. But how can I do that with a module?
This is from the sample code: server = new MyServer(self)

I cannot refer to the Module as Me, of Self, so not sure how to do this.

What I did do is to create a private property in the module called server As ENetServer. In an initialization method of the module, I perform this code “server = New MyServer”, note it leaves out the “owner” parameter which is normally there according to the sample code. I removed the code from the MyServer class, but without this reference, it is kind of lost and wont work properly.

The MyServer class is NOT within the Module (when viewed in the Xojo Navigator).

Any ideas how to fix this? The application will be either a console or Service type app.
Thank you,
Tim

Can you point me to the documentation you got that from? Nothing on Einhuger’s site that I can see indicates that a window is required or even involved. Perhaps you’re using an EnetServer subclass that has been wired to show some indicators/statistics on a window?

Hi Tim.
It is in their sample code. I got it working just a moment ago without the reference back to the object, and the interesting thing is that without that, the object still sends data back to a method in the Module.

This code is in the myServer class:

frmAxcysPMSInterface.UDP_ReceiveMsg(Data, IP)

Note that for porting ease, I made the module name the same as the original form name.
Tim