[fpc-pascal] mpcalc 7.4

2014-10-07 Thread franco

For anyone interested, a stable version 7.4 of mpcalc (unit for
multiple-precision floating-point computations) is now available:

ftp://ftp.freepascal.org/pub/fpc/contrib/mpcalc-7.4.zip
or http://www.polarhome.com/~franco/mpcalc-7.4.zip

Changes have been made to double factorial, ceil and floor functions.
Bug reports are always welcome. Thanks to everyone that has contributed
and to the fpc team.

Franco
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Is TFPList thread safe?

2014-10-07 Thread Michael Schnell

On 10/06/2014 05:55 PM, Dennis Poon wrote:



function TThreadList.LockList: TList;
  begin
Result:=FList;
System.EnterCriticalSection(FLock);
  end;


Yep.

System.EnterCriticalSection is a procedure variable that is set 
according to the OS and arch the project is compiled for.


In Linux without  UseCThreads it is just an empty function. (OK here 
creating threads is not allowed)
In Linux with  UseCThreads it is just an empty function it is a call to 
pthread_mutex_lock, which is in the pthreadlib so file and calls FUTEX 
or MUTEX, such as appropriate. (So don't try to "optimize" !!! )
In Windows I suppose it does a call to the Windows system DLL that 
supposedly does  a FUTEX workalike.  (So don't try to "optimize" !!! )





There is no special optimization at all.  It simply calls
  System.EnterCriticalSection(FLock),
so performance should be JUST THE SAME as wrapping a pair of critical 
section enter/leave around the code ourselves.

Yep. (So don't try to "optimize" !!! )

-Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Trying to register a Windows Service gives error

2014-10-07 Thread Michael Van Canneyt



On Mon, 6 Oct 2014, Sven Barth wrote:



Am 06.10.2014 17:45 schrieb "Graeme Geldenhuys" :
>
>
>
> On 06/10/2014 16:36, Sven Barth wrote:
> > That's the case since Windows Vista. Maybe you have disabled UAC
>
> Interesting, thanks for mentioning that. I know I've disabled UAC on my
> work laptop. I'm not in control of our development server, but I'll ask
> the admin when he is back in the office.

It's one of the reasons why I keep UAC enabled on my Windows systems: I catch 
such problems immediately ;)


I stopped doing that, because the constant messages are a real PITA.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Trying to register a Windows Service gives error

2014-10-07 Thread Sven Barth
Am 07.10.2014 09:55 schrieb "Michael Van Canneyt" :
>
>
>
> On Mon, 6 Oct 2014, Sven Barth wrote:
>
>>
>> Am 06.10.2014 17:45 schrieb "Graeme Geldenhuys" :
>> >
>> >
>> >
>> > On 06/10/2014 16:36, Sven Barth wrote:
>> > > That's the case since Windows Vista. Maybe you have disabled UAC
>> >
>> > Interesting, thanks for mentioning that. I know I've disabled UAC on my
>> > work laptop. I'm not in control of our development server, but I'll ask
>> > the admin when he is back in the office.
>>
>> It's one of the reasons why I keep UAC enabled on my Windows systems: I
catch such problems immediately ;)
>
>
> I stopped doing that, because the constant messages are a real PITA.

Our main application requires admin rights as well, but quite quickly my
muscle memory has taken over so that I can just dismiss the UAC dialog
without thinking much about it. (I did disable the "use secure desktop"
option though so that I don't get a black screen for some seconds...)

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Trying to register a Windows Service gives error

2014-10-07 Thread Michael Schnell

On 10/06/2014 05:12 PM, Graeme Geldenhuys wrote:
...
Please don't use such excessive multi-line "declaimers" in a forum.

-Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Trying to register a Windows Service gives error

2014-10-07 Thread Graeme Geldenhuys
Hi Michael,

On 07/10/2014 12:12, Michael Schnell wrote:
> Please don't use such excessive multi-line "declaimers" in a forum.

I did notice those (and don't like it either), but unfortunately nothing
I can do about it. It is my work address and our mail server injects
those "disclaimers" _after_ we sent the messages from our computers.

I'll try and limit posts from my work address to this mailing list.

Regards,
  Graeme


This email and its attachments may be confidential and are intended solely for 
the use of the individual to whom it is addressed. Any views or opinions are 
solely those of the author and do not necessarily represent those of Quality 
Technology Systems Ltd. If you are not the intended recipient of this email and 
its attachments, you must take no action based upon them, nor must you copy or 
show them to anyone. If you receive the message in error, please immediately 
delete it, destroy all copies of it and notify the sender. Internet email is 
not a totally secure medium and therefore Quality Technology Systems Ltd does 
not accept legal responsibility for the contents of this message. We have taken 
steps to ensure that this email and any attachments are free from viruses. 
However, we cannot accept any responsibility for any virus transmitted by us 
and recommend that you subject any incoming email to your own virus checking 
procedure. Registered in England No. 3208823
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TIniFile: how to save bool as string?

2014-10-07 Thread silvioprog
On Sat, Oct 4, 2014 at 6:28 AM, Reinier Olislagers <
reinierolislag...@gmail.com> wrote:

> On 03/10/2014 21:16, silvioprog wrote:
> > When I use the TIniFile to save my configurations, it saves the boolean
> > values as 0 and 1.
> >
> > Is there any way to save these values ​​as string (true/false) instead
> > of integer (0/1)? If not, can I send a patch to implement that?!
>
> 1. Write your own wrapper?
> 2. AFAIR, there already is a bug report+patch in the bug tracker on
> extending TInifiles.


Thanks.

Internally it uses this functions:

...
function CharToBool(AChar: char): boolean;
begin
  Result := (Achar = '1');
end;

function BoolToChar(ABool: boolean): char;
begin
  if ABool then
Result := '1'
  else
Result := '0';
end;
...

This functions could be replaced by functions from SysUtils functions,
allowing compatibility with words like 0/1 (as is now), true/false, yes/no
(USA), sim/não (Brazil), foo/bar (any) etc. Then:

Instead of:

function TCustomIniFile.ReadBool(const Section, Ident: string; Default:
Boolean): Boolean;
var
  s: string;
begin
  Result := Default;
  s := ReadString(Section, Ident, '');
  if s > '' then
Result := CharToBool(s[1]);
end;

Could be:

function TCustomIniFile.ReadBool(const Section, Ident: string; Default:
Boolean): Boolean;
var
  s: string;
begin
  Result := Default;
  s := ReadString(Section, Ident, '');
  if s > '' then
Result := SysUtils.StrToBoolDef(s[1], False);
end;

And, instead of:

procedure TCustomIniFile.WriteBool(const Section, Ident: string; Value:
Boolean);
begin
  WriteString(Section, Ident, BoolToChar(Value));
end;

Could be:

procedure TCustomIniFile.WriteBool(const Section, Ident: string; Value:
Boolean);
begin
  WriteString(Section, Ident, SysUtils.BoolToStr(Value, True));
end;

So I could use with:

initialization
  SetLength(SysUtils.TrueBoolStrs, 1);
  SetLength(SysUtils.FalseBoolStrs, 1);
  SysUtils.TrueBoolStrs[0] := 'true'; // or other
  SysUtils.FalseBoolStrs[0] := 'false'; // or other

Just ideas hehe..

--
Silvio Clécio
My public projects - github.com/silvioprog
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] TIniFile: how to save bool as string?

2014-10-07 Thread JB
I usually use integer cast to boolean values, sample:

var
  cond: boolean;
  i: integer;
begin
  cond := true;

  writeln(inttostr(integer(cond)));

  i := 0;

  if boolean(i) then
writeln('true')
  else
writeln('false');
end;

best regards




José Benedito
JBS Soluções
Consulting Systems Development
c ont...@jbsolucoes.net
www.jbsolucoes.net

skype: s...@jbsolucoes.net
+55 22 30251654
+55 22 996064279

On Tue, Oct 7, 2014 at 3:46 PM, silvioprog  wrote:

> On Sat, Oct 4, 2014 at 6:28 AM, Reinier Olislagers <
> reinierolislag...@gmail.com> wrote:
>
>> On 03/10/2014 21:16, silvioprog wrote:
>> > When I use the TIniFile to save my configurations, it saves the boolean
>> > values as 0 and 1.
>> >
>> > Is there any way to save these values ​​as string (true/false) instead
>> > of integer (0/1)? If not, can I send a patch to implement that?!
>>
>> 1. Write your own wrapper?
>> 2. AFAIR, there already is a bug report+patch in the bug tracker on
>> extending TInifiles.
>
>
> Thanks.
>
> Internally it uses this functions:
>
> ...
> function CharToBool(AChar: char): boolean;
> begin
>   Result := (Achar = '1');
> end;
>
> function BoolToChar(ABool: boolean): char;
> begin
>   if ABool then
> Result := '1'
>   else
> Result := '0';
> end;
> ...
>
> This functions could be replaced by functions from SysUtils functions,
> allowing compatibility with words like 0/1 (as is now), true/false, yes/no
> (USA), sim/não (Brazil), foo/bar (any) etc. Then:
>
> Instead of:
>
> function TCustomIniFile.ReadBool(const Section, Ident: string; Default:
> Boolean): Boolean;
> var
>   s: string;
> begin
>   Result := Default;
>   s := ReadString(Section, Ident, '');
>   if s > '' then
> Result := CharToBool(s[1]);
> end;
>
> Could be:
>
> function TCustomIniFile.ReadBool(const Section, Ident: string; Default:
> Boolean): Boolean;
> var
>   s: string;
> begin
>   Result := Default;
>   s := ReadString(Section, Ident, '');
>   if s > '' then
> Result := SysUtils.StrToBoolDef(s[1], False);
> end;
>
> And, instead of:
>
> procedure TCustomIniFile.WriteBool(const Section, Ident: string; Value:
> Boolean);
> begin
>   WriteString(Section, Ident, BoolToChar(Value));
> end;
>
> Could be:
>
> procedure TCustomIniFile.WriteBool(const Section, Ident: string; Value:
> Boolean);
> begin
>   WriteString(Section, Ident, SysUtils.BoolToStr(Value, True));
> end;
>
> So I could use with:
>
> initialization
>   SetLength(SysUtils.TrueBoolStrs, 1);
>   SetLength(SysUtils.FalseBoolStrs, 1);
>   SysUtils.TrueBoolStrs[0] := 'true'; // or other
>   SysUtils.FalseBoolStrs[0] := 'false'; // or other
>
> Just ideas hehe..
>
> --
> Silvio Clécio
> My public projects - github.com/silvioprog
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] TIniFile: how to save bool as string?

2014-10-07 Thread silvioprog
On Tue, Oct 7, 2014 at 3:58 PM, JB  wrote:

> I usually use integer cast to boolean values, sample:
>
[...]

But the main ideia to change it is allow any type supported by SysUtils,
like integer (-1/0 or 0/1), strings (true/false, yes/no, y/n, sim/não or
other) etc.

My patch keeps the current behavior of the INI class, but allows the
programmer to internationalize that to the your favorite way. You prefer
0/1, I prefer true/false, other prefer yin/yang etc., my patch allow to use
in any way. ;)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal