A Gambas Newbie questions

Post your Gambas programming questions here.
User avatar
stevedee
Posts: 429
Joined: Monday 20th March 2017 6:06pm

Re: A Gambas Newbie questions

Post by stevedee » Sunday 06th December 2020 6:38am

AndyGable wrote:
Sunday 06th December 2020 4:33am
According to google the & command will start the program but will not make it take focus (so basically it will load the program into the background)

What I would like to do is start my application and have it then load other apps as it needs...
Re: loading a program in the background, that only makes sense if you only have one instance of a shell. As an example, my Pi based Internet Radios don't run a GUI. So each program that needs to run must run in the background, so the next will still be loaded and run.
So (as far as I can see) you can load several programs via different Shells from your Gambas program, and they won't block or inhibit the others.

One thing is clear, and that is that this is not a trivial application. So with that in mind I'm going to ask you to fully check your requirements and assess whether you are taking the best approach. Obviously its your choice how you do this, but I don't want to give advice regarding a possibly flawed approach.

Q1: Why do you want a separate program to perform this printing process?
Reason for question: It looks like you only want to print...when you want to print.
If you launch a separate program, you may need some kind of feedback to ensure that it is still running. You may end up checking its running each time, then restarting it if its not, then sending data to print. If that's the case (and you still want a separate program) you could just call it when you need it (via Exec or Shell) and let it close gracefully when its finished.

If you just want the code to be modular, have you considered just putting the printer code in a Module, creating a Class or creating and using a Library?

Like I say, its better to ask these questions now.


Incidentally, the only time I've found the need to create 2 Gambas programs to work together was for my bat call capture software. The first program had to take a quick decision on whether an audio stream contained ultrasonic signals, and then buffer each 'good' file. While the second had to go through each file and determine whether it contained a possible bat call or just other noise. So each file was either saved (along with analysis data, including frequency) or deleted. As the bats could make the sounds much faster than Gambas could classify them, I needed this 2 program (multi thread) approach.

AndyGable
Posts: 65
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: A Gambas Newbie questions

Post by AndyGable » Sunday 06th December 2020 7:40pm

stevedee wrote:
Sunday 06th December 2020 6:38am
Q1: Why do you want a separate program to perform this printing process?
Hi Stevedee,

the Reason I would like each printer to have its own program is because each printer uses different commands to print to the printer (these are not standard printers so I can not use the in built linux print functions) I am using Epson Retail printers and IBM as well as NCR and Wincor Nixdorf Printers (they all use thier own version of ESC/PoS)

I have not yet looked into the full features of Gambas but so far it looks like It may be what i want to drop windows from our Point of sale systems (well at the front end anyway)

and I am not using a GUI as such I have a Basic install of xserver and I can start the PoS with startx ./NPoS/NPoS (that is the name of the application) and the software starts up

the Reason I would want to have each other program running in the background would be because they do not have any user interfaces so they do not need to be interfaced with (they only talk to the main PoS application)

I am hoping to be able to add support for Scales in the Linux version (I have this in the Windows version but it is using OPoS and that is not supported in Linux)

Also I have a custom wrote DLL that handles the tills promotions (written in VB.net) I did not write this I paid someone to do that for me can I still use it with Gambas?

User avatar
gbWilly
Posts: 36
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: A Gambas Newbie questions

Post by gbWilly » Tuesday 08th December 2020 2:42pm

Hi AndieGamble
Also I have a custom wrote DLL that handles the tills promotions (written in VB.net) I did not write this I paid someone to do that for me can I still use it with Gambas?
DLL or Dynamic Link Libraries are a Windows thing and will not run on linux.
Also, all the code would probably be very Windows specific when it comes to how to approach hardware.

You could try to rewrite the DLL as a Gambas library if you have access to the source code of the DLL.
You should be aware that things work differently on linux compared to Windows when recoding.
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer


... there is always a Catch if things go wrong!

User avatar
stevedee
Posts: 429
Joined: Monday 20th March 2017 6:06pm

Re: A Gambas Newbie questions

Post by stevedee » Wednesday 09th December 2020 11:47am

AndyGable wrote:
Sunday 06th December 2020 7:40pm
....the Reason I would like each printer to have its own program is because each printer uses different commands to print to the printer (these are not standard printers so I can not use the in built linux print functions)...
From what you say, I would agree that you need to keep the printer stuff modular. But I'm not convinced that that means a bunch of separate programs, and that these need to be running in the background.

Presumably, at some point the main program will say "let's print some stuff to printer type A". The type A bit will direct the code to call a Module or a Class or maybe Library code to do the rest.

Note that when I say Class, I'm thinking of an OOP (object orientated programming) type class with common Methods and Properties (and possibly Events) which would handle the printing, even though the implementation details differ significantly between printer types. So in use, you would create an instance of your printer class for (say) the Type F printer and configure various Properties (and maybe run certain Methods) to suit the printers protocol. Then you just call a Method to 'print this'.

On the other hand, if you write separate independant programs for each printer, you still need to get them to talk to one another, and your overall testing time will be longer, and software quality may suffer.


The bottom line is that you probably need to fully familiarise yourself with the Gambas concepts of Modules, OOP Classes, and Libraries before taking a final decision on which approach to adopt.

Sorry if that is not the answer you were looking for.

AndyGable
Posts: 65
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: A Gambas Newbie questions

Post by AndyGable » Wednesday 09th December 2020 2:57pm

gbWilly wrote:
Tuesday 08th December 2020 2:42pm
Hi AndieGamble
Also I have a custom wrote DLL that handles the tills promotions (written in VB.net) I did not write this I paid someone to do that for me can I still use it with Gambas?
DLL or Dynamic Link Libraries are a Windows thing and will not run on linux.
Also, all the code would probably be very Windows specific when it comes to how to approach hardware.

You could try to rewrite the DLL as a Gambas library if you have access to the source code of the DLL.
You should be aware that things work differently on linux compared to Windows when recoding.
I have full access to the source code of the DLL (as it was written for my company) is it hard to do a libary for Gambas? Ive never done anything like that before

User avatar
stevedee
Posts: 429
Joined: Monday 20th March 2017 6:06pm

Re: A Gambas Newbie questions

Post by stevedee » Wednesday 09th December 2020 7:17pm

AndyGable wrote:
Wednesday 09th December 2020 2:57pm
... is it hard to do a libary for Gambas? Ive never done anything like that before
You will find my simple-starter-guide to Gambas libraries here: https://captainbodgit.blogspot.com/2019 ... aries.html

...or for using C libraries with Gambas: http://captainbodgit.blogspot.com/2019/ ... aries.html

AndyGable
Posts: 65
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: A Gambas Newbie questions

Post by AndyGable » Saturday 12th December 2020 12:07pm

Thank-you Steve I shall have a Read of that and have a play with Gambas at the weekend

Post Reply