Re: [Lazarus] systemd

2015-07-10 Thread A. Fortuny

Le 27/06/2015 13:47, A. Fortuny a écrit :

Hi Folks.

Currently I have some services running in a linux box (OpenSuse 11.2) 
and they will be moved to an OpenSuse 13.2. I want to move the 
services from SysV to systemd.
I noticed that in the service configuration file (namely 
/usr/lin/systemd/system/MyService.service) there are some options wich 
bother me a little bit. The services are programs written using 
Lazarus and its service framework. Please note that the services run 
either on Windows or on Linux (some $ifdef help). I wonder what 
happens on two points:
1. the new service type parameter TYPE in section [Service] should be 
"simple" I guess

2. the parameter TimeoutStartSec bothers me.

As in the sefvice framework developed using Lazarus units (service 
project), the program is started by the INIT script in /etc/init.d 
with the -r runtime switch. The program then responds to the start 
event of the Daemon unit wich, in turn, starts the main thread and the 
called start procedure exits as soon as posible. The program keeps 
running until the exit signal is fired and the main thread is stopped. 
If it is by the means of the INIT script (service MyService stop) the 
process is killed either soft or hard. The question is: does a service 
written in this new method still needs the Lazarus service framework ? 
What is the signal sent to systemd wich informs it that the sevice has 
started (read man systemd.service (5) )? The same mechanism as the 
Lazarus service framework still applies ?


I'm not yet ready to use either D-BUS messaging system nor socket 
based systemd start service mechanism.


Thank you for any information.

Antonio.


Hi All.

After a reading thru all documentation spread over there I succeeded to 
port an Initd service to the new systemd.. Both questions above got 
their answer:

1. simple is the right type
2. I didn't enven specify avy time out.

The most important lesson learned is that the service program written 
using Lazarus and Fpc does not require ANY change. It woks as is 
provided that the launch command includes the -r parameter.

systemctl enable MyService: OK
systemctl start MyService: OK
systemctl stop MyService: OK

Service file in /etc/systemd/system with minimal options
reboot the linux box and the service has been properly stopped and 
restarted after booting again.

Nice and clear, thanks to all

Antonio.



---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] systemd

2015-06-27 Thread A. Fortuny

Hi Folks.

Currently I have some services running in a linux box (OpenSuse 11.2) 
and they will be moved to an OpenSuse 13.2. I want to move the services 
from SysV to systemd.
I noticed that in the service configuration file (namely 
/usr/lin/systemd/system/MyService.service) there are some options wich 
bother me a little bit. The services are programs written using Lazarus 
and its service framework. Please note that the services run either on 
Windows or on Linux (some $ifdef help). I wonder what happens on two points:
1. the new service type parameter TYPE in section [Service] should be 
"simple" I guess

2. the parameter TimeoutStartSec bothers me.

As in the sefvice framework developed using Lazarus units (service 
project), the program is started by the INIT script in /etc/init.d with 
the -r runtime switch. The program then responds to the start event of 
the Daemon unit wich, in turn, starts the main thread and the called 
start procedure exits as soon as posible. The program keeps running 
until the exit signal is fired and the main thread is stopped. If it is 
by the means of the INIT script (service MyService stop) the process is 
killed either soft or hard. The question is: does a service written in 
this new method still needs the Lazarus service framework ? What is the 
signal sent to systemd wich informs it that the sevice has started (read 
man systemd.service (5) )? The same mechanism as the Lazarus service 
framework still applies ?


I'm not yet ready to use either D-BUS messaging system nor socket based 
systemd start service mechanism.


Thank you for any information.

Antonio.


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Windows CE

2015-05-22 Thread A. Fortuny

Le 22/05/2015 08:59, Koenraad Lelong a écrit :

Hi,

I could be able to purchase a number of second hand intelligent 
barcode scanners. I have project in mind where I could use such devices.
The scanners run Windows CE 5. Is it possible and advisable to develop 
for these devices using Lazarus ?
I know Lazarus has support for Windows CE, but at the moment I don't 
find which versions are supported.

Hi Koenraad.

No problem at all. I've been busy until last year with Lazarus and LCL 
on a Vista  workstation, 32bit compiler, cross compiler WinCE. Even Indy 
10 compiled (somes little changes though)  worked fine.
Hardware was hand held computers from Symbol technologies wich became 
Motorola some time ago.

HW
MC900 range (Pocket PC)
PPT 8800 series (WinCE)
All hw equipment was accessible by the means of some specialised DLL's.

Antonio.


Thanks,

Koenraad.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
http://www.avast.com


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] (no subject)

2015-05-06 Thread A. Fortuny

Le 5/05/2015 22:41, Xirax Xirax a écrit :

Hello,

Any one know who can I talk about Lazarus graphical interface like
logo,splash screen and so on?


Hi Guys (not seeing girls over there)

After a reading across this post, I wonder how much relevant is, for 
Lazarus users like me, Xirax Xirax proposal. To be honest I must write 
that I'm 64 and I know Lazarus and use it for more than 5 years. I also 
know Delphi from the very first version 1.0 on Windos 3.1 (do some of 
you remeber what it was ?).  As a Lazarus user, I'm absolutely happy on 
the job the team has achieved so far. As a developer (but non in 
Lazarus) I like that an IDE gives me as much help as possible to 
implement the best solution to a given problem. I do not care at all 
whether the splash screen is either red or grey or maybe the icon 
representing a component is blue or dark yellow, as long as I SEE that 
icon at the same place across all new releases. Lazarus and Delphi 
achieved the same goal. This is, for instance, one of my major blames 
against Micro$oft. On every new release I've to loose time just to find 
where those crazy people disguise the well known function in previous 
version.  That's also the major reason why I love Linux. I use the same 
Linux dialect for almost 10 years and nothing changed (except new 
features) neither in install process nor in the graphical interface 
(OpenSuse & Xfce). I'm not interested on what the GUI looks like as far 
as it works fine. Being a Linus and a Wind$ws user and developer, I 
highly apreciate how close the IDEs are in Linux and Windo$ws. This is 
also highly productive.


Xirax Xirax proposal could maybe lead to have a nice GUI for the IDE: 
useless for me and development time lost. As a developer I prefer to 
focus on efficiency rather than on beauty. The last needs guys (or 
girls) having some artistic skills. I have none.


Thanks to you all guys.

Antonio.


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
http://www.avast.com



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Filling ListBox without triggering OnSelectionChange

2015-01-07 Thread A. Fortuny

Le 7/01/2015 07:49, Marc Santhoff a écrit :

Hi,

it has been a very long time since I've programmed GUIs. I have
forgotten how to fill a ListBox without having the event handler
OnSelectionChange executed.

I've had the same problem for years, until I "invented" my method:
- fill in the two events OnEnter and OnExit for the control
- generate the code for the OnSelectionChange event and drop immediately 
the event in the component explorer

- manually fill in the following code in the three envents:

TMyForm.MyComponentEnter(Sender: TObject);
begin
  MyComponent.OnSelectionChange := MyComponentSelectionChange;
// do the same for all other events you want to drive
end

TMyForm.MyComponentSlectionChange(Sender: TObject; ...);
begin
  // do whatver to do when the event fires
end

TMyForm.MyComponentExit(Sender: TObject);
begin
  MyComponent.OnSelectionChange := nil
end

Of course you can control any firing event using the OnEnter and OnExit 
events of the control. This allows the program to fire events only when 
the user enters the control.
I think that GUI's  lack a control property wich indicates whether the 
events should always fire or fire only when the user enters the control.


Antonio.


I have tried (Un)LockSelectionChange on the list, setting ItemIndex to
-1, all in the forms create method. I've tried using add() or assign()
on the listbox's Items, nothing helps.

The wiki on TListBox doesn't say anything on this topic, neither does
the LCL help document.

How can it be done?





---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
http://www.avast.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Indy 10

2014-12-31 Thread A. Fortuny

Le 29/12/2014 11:26, Juha Manninen a écrit :

What is the recommended link to download Indy 10 for lazarus?
The wiki :
   http://wiki.freepascal.org/Indy_with_Lazarus#Downloads_.2F_Links
tells to use Indy 10 website :
   http://www.indyproject.org/index.en.aspx

This link works and the zip file looks ok.
link 

Antonio.

BTW, happy new year 2015 to all of you


which is messy.

Juha

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
http://www.avast.com



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Handling Firebird connection

2014-08-25 Thread A. Fortuny

Le
[...] 25/08/2014 12:13, Richard Mace a écrit :

Hi Antonia,

This sequence does not protect against the server disconnection
between two consecutive database calls.


Would you mind giving me an example of this?
What I mean is that the physical TCP/IP connection between the 
aplication (the client) and the firebird server is not systematically 
tested on every function call to the library accessing the firebirs 
server. If you assume the following sequence of operations:


   MySql.Database := MyDatabase;
   [...]
   MyDatabase.Connect;
   (1)
   Mysql.Sql.text := 'select any from thedatabase';
   MyTransaction.StartTransaction;
   (2)
   Mysql.Open:
   (3)
   while Mysql.EOF = False do begin
// do whatever to do with database records
Mysql.Next
   (4)
   end;
   (5)
   Mysql.close;
   (6)
   MyTransaction.Commit;
   (7)
   MyDatabase.Connected := False;

After each statement noted (1) thru (7) the TCP/IP link initiated by the 
MyDatabase.Connect can be broken anywhere betwenn (1) and (7) unless you 
code something to test it. This can be any function looking something 
like a:
telnet host_name(or IP address) 3050 (or whatever firebird port is used 
in host) issued in in a command line.
In a Lazarus program you would need something like Indy ping component 
(any other is also OK) wich will test the firebird server awakeness. Its 
is really a heavy workloa anyway.
I usually keep going with my former exemple. When the server connection 
is critical I fill in the except part some code to figure out witch is 
the failing part using either the exception code or the exception text 
itself. I can also specialize the different exception sources using the 
On MyException:Exception do
In the top example of code I'll insert try..except's (or finally's if I 
don't care about exceptions) around the critical places I can't miss. 
But this depends on the application as well


Antonio.


Thanks

Richard



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] root privileg

2014-06-04 Thread A. Fortuny

Le 4/06/2014 17:01, Reinier Olislagers a écrit :

On 04/06/2014 16:54, Michael Van Canneyt wrote:

On Wed, 4 Jun 2014, A. Fortuny wrote:

How to gain temporarily root privileges in a pascal program ? I
need to 'ping' an IP address and for ping to work (Indy 10) I need
to be root.

Why do you need root to ping? You could set up sudo to allow
The program I intend to make will be developed as a service "pinging" on 
a regular basis remote stations just to see if they are alive. The way 
that Indy implements ICMP protocol means that "pinger" socket is 
available only under root permission. The same test programs which fails 
under normal user succeeds under root.
This is clearly stated in Indy FAQ. Read http://www.indyproject.org/KB/ 
for this subject and associated questions.


Antonio.

regular/specific users to ping; perhaps there's something with this
new-fangled capabilities thing etc.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] root privileg

2014-06-04 Thread A. Fortuny

Hi Folks.

How to gain temporarily root privileges in a pascal program ?
I need to 'ping' an IP address and for ping to work (Indy 10) I need to 
be root.

Usage of another TCP component is not an option.
Another way is to execute a shell and intertpret the results but I'd to 
avoid it if possible.

It is on Linux system.

Thanks


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Problem rounding values at post

2014-06-04 Thread A. Fortuny

Le 3/06/2014 22:39, Daniel Erles a écrit :

Hello.
I have this problem:

My database (Firebird) has a table with the following fields:
...
rTitle DECIMAL(8,4) not null,
rDiameter DECIMAL(10,6) not null,
...

In my program I have a Form with a a TZTable object (ZEOS) called 
zData, bound to that table.

In a routine I have the following code:

zData.Insert;
...
zData.FieldByName('rTitle').AsFloat := 0.12;
zData.FieldByName('rDiameter').AsFloat := 0.12;
...
zData.Post;

Then, at the table, I see that the values are stored as follows:

rTitle = *0.1199*
rDiameter = 0.12

Do not know why rTitle is 0.1199 instead of 0.12
I need the saved values are accurate.
I've tried AsFloat, AsCurrency, Value, always with the same result.

Any idea?

Tks.
Daniel.


Well it's not easy indeed. In the case of Firebird (it's salso my case) 
you have to take into account the sql dialect which makes a big 
difference when interfacing numeric values. With sql dialect 1 all 
numeric (and decimal) types are output as binary floating point (sirgle 
or double dependgng on column precision) figures. In sql dialect 3 
decimal, numeric, money and dates are output as integer values ranging 
from single byte to int64 with all integer values in between, all 
depending on database presions (dates are always output as int64). This 
means that there are always fixed implied decimal positions. Have a look 
in http://ibexpert.net/ibe/index.php?n=Doc.SQLDialect . There are some 
other differences as well.


On the other side with Lazarus (even Delphi) the recipent containers are 
always double or extended depending on the interface used, leading to 
TFloatField definitions anyway. Sometimes a TBCDField is implemented. In 
all this stuff I've been used to use the math function RoundTo as the 
number of decimals is always known (think on accounting computations, 
invoicing, etc.)..


As a matter of fact, In my developments I always use sql dialect 3 in 
the database along with numeric or decimal types when decimals are 
needed (read http://www.firebirdfaq.org/faq340/), extended type in 
Lazarus and Delphi variables and RoundTo (where applicable) for 
intermediate results. There is also a subtle difference in rounding 
whether you use bank figures or acconting figures. But that is another story


Antonio.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] service launch

2014-06-03 Thread A. Fortuny

Le 2/06/2014 16:42, Michael Van Canneyt a écrit :



On Mon, 2 Jun 2014, A. Fortuny wrote:


Hi Folks.

OpenSuse 12.2
Based on the /etc/init.d/skeleton I've made a new service script 
named "service.test" replacing all what is needed (binary name, conf 
file, etc.)
When i launch it (using: # service service.test start) it fails to 
launch. The /var/log/messages displays:


Jun  2 11:50:02 aforsrv service.test[26037]: Starting Service test 
Usage: /home/data2/sources/compiled/service.bin [command]
Jun  2 11:50:02 aforsrv service.test[26037]: Where command is one of 
the following:
Jun  2 11:50:02 aforsrv service.test[26037]: -i --install   To 
install the program as a service
Jun  2 11:50:02 aforsrv service.test[26037]: -u --uninstall To 
uninstall the service
Jun  2 11:50:02 aforsrv service.test[26037]: -r --run   To run 
the service
Jun  2 11:50:02 aforsrv service.test[26037]: An unhandled exception 
occurred at $0046E48A :

Jun  2 11:50:02 aforsrv service.test[26037]: EInOutError :
Jun  2 11:50:02 aforsrv service.test[26037]: $0046E48A
Jun  2 11:50:02 aforsrv service.test[26037]: $00497C43 line 
233 of ../lib/simplelogger.pas
Jun  2 11:50:02 aforsrv service.test[26037]: $00473316 line 
48 of DaemonMapper.pas

Jun  2 11:50:02 aforsrv service.test[26037]: $00471C27
Jun  2 11:50:02 aforsrv startproc: startproc:  exit status of parent 
of /home/data2/sources/compiled/service.bin: 217

Jun  2 11:50:02 aforsrv service.test[26037]: ..failed
Jun  2 11:50:02 aforsrv systemd[1]: service.test.service: control 
process exited, code=exited status=7
Jun  2 11:50:02 aforsrv systemd[1]: Unit service.test.service entered 
failed state.





The program itself is written in FPC using Lazarus and when launched 
on its own it runs perfectly well:
# ./service.bin -r ( the -r parameter tells the program to run as a 
service).
Log file is present and readable, SIGHUP and SIGTERM are trapped and 
recorded. Everythning runs as expected, the service script excepted.


Any ideas ?


Does your script add the -r option when running the service ?

Yesy it does.
AT the same time I have to apologize. After re-creating the service 
script from the original /etc/init.d/skeleton,

- changing the first line as a /bin/bash script
- adapt the comments in the INIT INFO about the service name
- change the service binary program
- change the conf file name
- add the -r to the launching of the service binary file
everything runs OK;
I did forget to register the service (chkconfig) and to reload 
(systemctl --system daemon-reload)

Sorry for the annoyance and thanks anyway.

Antonio.


Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] service launch

2014-06-02 Thread A. Fortuny

Hi Folks.

OpenSuse 12.2
Based on the /etc/init.d/skeleton I've made a new service script named 
"service.test" replacing all what is needed (binary name, conf file, etc.)
When i launch it (using: # service service.test start) it fails to 
launch. The /var/log/messages displays:


Jun  2 11:50:02 aforsrv service.test[26037]: Starting Service test Usage: 
/home/data2/sources/compiled/service.bin [command]
Jun  2 11:50:02 aforsrv service.test[26037]: Where command is one of the 
following:
Jun  2 11:50:02 aforsrv service.test[26037]: -i --install   To install the 
program as a service
Jun  2 11:50:02 aforsrv service.test[26037]: -u --uninstall To uninstall the 
service
Jun  2 11:50:02 aforsrv service.test[26037]: -r --run   To run the service
Jun  2 11:50:02 aforsrv service.test[26037]: An unhandled exception occurred at 
$0046E48A :
Jun  2 11:50:02 aforsrv service.test[26037]: EInOutError :
Jun  2 11:50:02 aforsrv service.test[26037]: $0046E48A
Jun  2 11:50:02 aforsrv service.test[26037]: $00497C43 line 233 of 
../lib/simplelogger.pas
Jun  2 11:50:02 aforsrv service.test[26037]: $00473316 line 48 of 
DaemonMapper.pas
Jun  2 11:50:02 aforsrv service.test[26037]: $00471C27
Jun  2 11:50:02 aforsrv startproc: startproc:  exit status of parent of 
/home/data2/sources/compiled/service.bin: 217
Jun  2 11:50:02 aforsrv service.test[26037]: ..failed
Jun  2 11:50:02 aforsrv systemd[1]: service.test.service: control process 
exited, code=exited status=7
Jun  2 11:50:02 aforsrv systemd[1]: Unit service.test.service entered failed 
state.




The program itself is written in FPC using Lazarus and when launched on 
its own it runs perfectly well:
# ./service.bin -r ( the -r parameter tells the program to run as a 
service).
Log file is present and readable, SIGHUP and SIGTERM are trapped and 
recorded. Everythning runs as expected, the service script excepted.


Any ideas ?


Thanks in advance,
Antonio.

---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus