[fpc-pascal] Why the difference in the rounded results?

2021-10-15 Thread Gabor Boros via fpc-pascal

Hi All,

I got different results with 32bit vs. 64bit, 3.2.2 vs. 3.3.1, FPC vs. 
Delphi. Why?


var
  d1,d2:Double;

begin
  d1:=20.5;
  d2:=1.05;
  Writeln(RoundTo(d1*d2,-2));
  Writeln(SimpleRoundTo(d1*d2));
  d1:=28.9;
  Writeln;
  Writeln(RoundTo(d1*d2,-2));
  Writeln(SimpleRoundTo(d1*d2));
  d1:=21.5;
  Writeln;
  Writeln(RoundTo(d1*d2,-2));
  Writeln(SimpleRoundTo(d1*d2));
  Readln;
end.

- FPC 3.2.2 Win32

 2.1531E+001
 2.1531E+001

 3.0340E+001
 3.0340E+001

 2.2570E+001
 2.2570E+001

- FPC 3.2.2 Win64

 2.1523E+001
 2.1531E+001

 3.0347E+001
 3.0351E+001

 2.2574E+001
 2.2578E+001

- FPC 3.3.1 Win32

 2.1531E+001
 2.1531E+001

 3.0340E+001
 3.0340E+001

 2.2570E+001
 2.2570E+001

- FPC 3.3.1 Win64

 2.1523E+001
 2.1531E+001

 3.0347E+001
 3.0351E+001

 2.2574E+001
 2.2578E+001

- Delphi 10.4.2 Win32

 2.153000E+0001
 2.153000E+0001

 3.034000E+0001
 3.034000E+0001

 2.258000E+0001
 2.258000E+0001

- Delphi 10.4.2 Win64

 2.152000E+0001
 2.153000E+0001

 3.034000E+0001
 3.035000E+0001

 2.258000E+0001
 2.258000E+0001

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


[fpc-pascal] TEnumerator - After the last element?

2021-10-07 Thread Gabor Boros via fpc-pascal

Hi All,

I need to know the current position is after the last element. The 
attached solution demonstrate what I want.


Is an internal solution exists for this task? I not found anything.

Gabor
uses SysUtils, Generics.Collections;

type
  TR=record
i:Integer;
  end;

  TLEnumerator=class(specialize TCustomListEnumerator)
  private
function GetAfterLast:Boolean;
  public
property AfterLast:Boolean read GetAfterLast;
  end;

  TL=class(specialize TList)
  public
function GetEnumerator:TLEnumerator; reintroduce;
  end;

function TL.GetEnumerator:TLEnumerator;
begin
  Result:=TLEnumerator.Create(Self);
end;

function TLEnumerator.GetAfterLast:Boolean;
begin
  Result:=(FIndex>FList.Count-1);
end;

var
  R:TR;
  L:TL;
  E:TLEnumerator;

begin
  L:=TL.Create;
  R.i:=28;
  L.Add(R);
  R.i:=32;
  L.Add(R);
  E:=L.GetEnumerator;
  WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F'));
  E.MoveNext;
  WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F'));
  E.MoveNext;
  WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F'));
  E.MoveNext;
  WriteLn(E.Current.i,'-',BoolToStr(E.AfterLast,'T','F'));
end.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Operators for a class

2020-12-31 Thread Gabor Boros via fpc-pascal

Hi All,

I try to convert some C++ source to FPC, see below a short example from 
it. How can I define same operator with FPC trunk?


class Cla
{
INT64   Num;

public:
Cla operator +(const Cla& m)
{
Cla  ret(this);

ret.Num += m.Num;

return ret;
}

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


Re: [fpc-pascal] Worse performance with 64bit binary

2020-07-25 Thread Gabor Boros

2020. 07. 25. 18:42 keltezéssel, Florian Klämpfl írta:

Am 25.07.20 um 16:49 schrieb Gabor Boros:

Hi All,

I cannot show the real application but attached a simple example.
If compile with 3.2.0 "ppc386.exe -O3 test.pas" the execution time of 
the resulting example binary is 0.4s, and 2.2s if compile with 
"ppcx64.exe -O3 test.pas". Any idea why?


Missed optimization. I fixed it in trunk.



Thank you for the quick fix!
Now the 64bit binary a little faster than the 32bit.
The fix will be backported to the fixes_3_2 branch?

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


[fpc-pascal] Worse performance with 64bit binary

2020-07-25 Thread Gabor Boros

Hi All,

I cannot show the real application but attached a simple example.
If compile with 3.2.0 "ppc386.exe -O3 test.pas" the execution time of 
the resulting example binary is 0.4s, and 2.2s if compile with 
"ppcx64.exe -O3 test.pas". Any idea why?


Gabor
{$Mode objfpc}

uses SysUtils;

function IsP(n:Integer):Boolean;
begin
  Result:=((n mod 2)=0);
end;

procedure L5;
var
  n1,n2,n3,n4,n5:Integer;
  c:Integer;
  p:array of Integer;
  i:Integer;
  pc:Integer;

begin
  c:=0;

  SetLength(p,6);
  for i:=0 to Length(p)-1 do p[i]:=0;

  for n1:=1 to 86 do
  for n2:=n1+1 to 87 do
  for n3:=n2+1 to 88 do
  for n4:=n3+1 to 89 do
  for n5:=n4+1 to 90 do
   begin
 Inc(c);
 pc:=0;
 if IsP(n1) then Inc(pc);
 if IsP(n2) then Inc(pc);
 if IsP(n3) then Inc(pc);
 if IsP(n4) then Inc(pc);
 if IsP(n5) then Inc(pc);
 Inc(p[pc]);
   end;
end;

var
  Start:TDateTime;

begin
  Start:=Now;

  L5;

  WriteLn(FormatDateTime('s.zzz',Now-Start));
end.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why external execution so slow? (fixed)

2020-04-02 Thread Gabor Boros

2020. 04. 01. 17:21 keltezéssel, Marco van de Voort írta:
But at least FPC3.2.0rc1 has a rewritten tprocess/runcommand that makes 
this fixable without source changes and recompilation, look at the next 
example:



It's fast but FPC's help not showed on the screen.

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


Re: [fpc-pascal] Why external execution so slow?

2020-04-01 Thread Gabor Boros

2020. 03. 31. 19:37 keltezéssel, Gabor Boros írta:

   RunCommandInDir('E:\FPC\3.2.0\bin\i386-win32','fpc.exe',['-h'],OS,[]);


Tried with modified(fpc -h) "Reading large output" example 
(https://wiki.freepascal.org/Executing_External_Programs#Reading_large_output). 
It's lighting fast. I will rewrite external execution in my real 
application based on this example...


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


Re: [fpc-pascal] Why external execution so slow?

2020-04-01 Thread Gabor Boros

2020. 03. 31. 23:31 keltezéssel, Alexander Grotewohl írta:
The other though I had is that your E: is going to sleep while you're 
programming and the first execution requires the drive to spin up again.


Same result if use a ramdisk.

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


Re: [fpc-pascal] Why external execution so slow?

2020-04-01 Thread Gabor Boros

2020. 03. 31. 23:21 keltezéssel, Marco van de Voort írta:


Antivirus?



No.

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


[fpc-pascal] Why external execution so slow?

2020-03-31 Thread Gabor Boros

Hi All,

I need to execute an external program from my application. This 
execution is much slower than execute the external application from 
command line. I made a simple example (see below) which show 1.7 seconds
for me. Why? (From command line the execution time is 15 milliseconds. I 
used Windows 10 64bit.)


var
  Start:TDateTime;
  OS:String;
begin
  Start:=Now;
  RunCommandInDir('E:\FPC\3.2.0\bin\i386-win32','fpc.exe',['-h'],OS,[]);
  WriteLn(FormatDateTime('nn:ss.zzz',Now-Start));

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


[fpc-pascal] Is TryStrToDate works wrong?

2020-01-04 Thread Gabor Boros

Hi All,

var
  DT:TDateTime;

begin
  Writeln(BoolToStr(TryStrToDate('1',DT),True));


The result of above code is "True" with FPC and "False" with Delphi.

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


[fpc-pascal] How to translate C macros which use stringification?

2019-11-22 Thread Gabor Boros

Hi All,

I made a simple example to demonstrate the problem:

#include 
using namespace std;

#define MACRO1(x)\
cout << #x << "(" << (x) << ")"; \

int main()
{
int var1;
var1 = 44;  
MACRO1(var1);
return 0;
}

The result of this simple example on the screen is:
var1(4)

Can I do the same thing with FPC in a simple way? I translate some C 
source to FPC and try to follow the original code.


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


[fpc-pascal] String type with specified length and without codepage

2019-08-18 Thread Gabor Boros

Hi All,

I try to rewrite some C/C++ code with FPC. I don't know which is the 
best string handling technique in this case. The original code for example:


char  b_l[b_list_len][bn_len+1];
char  s_n[sn_len+1];

I do not want to fight with "char"s or "byte"s. Just want to use the 
easier way which have the best performance. (The original code use 
strncpy.) I can use "s_n:String[sn_len]", but "String" is ShortString 
and it's have CP_ACP codepage if I understand the wiki correctly. So I 
need a string type with explicit defined length and with CP_NONE 
codepage for a Linux/Windows multi platform application. Any idea?


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


Re: [fpc-pascal] XML - Indent, text content, special char

2019-04-30 Thread Gabor Boros

2019. 04. 30. 2:45 keltezéssel, wkitt...@windstream.net írta:
are you saying that you are trying to use fixed-width fields that are 
space-padded in XML files???


No. The XML files are exists already. The task is... Load the 
contents/file to a TObject descendant, modify the data in the object(s) 
then build up XMLs from it a save back to file(s). Without lost any 
"TDOMNode.TextContent".


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

Re: [fpc-pascal] XML - Indent, text content, special char

2019-04-29 Thread Gabor Boros

2019. 04. 28. 21:24 keltezéssel, Santiago A. írta:
If you need the same indent or special chars, XML is not the right 
format for you.


Consider it



XML is not my choice. ;-)

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

Re: [fpc-pascal] XML - Indent, text content, special char

2019-04-29 Thread Gabor Boros

2019. 04. 28. 9:25 keltezéssel, Gabor Boros írta:
The "indent" and "text content" problems solved on the reader side by 
ReadXMLFilePreserveWhitespace:



With a sample application but not with the real life application. :-(
(My real application just find node for every second FindNode call.)

With the attached example and test xml file I got the next result:

*a*
**

Is this not a bug? Lost of formatting is not disturb me but text between 
> and < is the data/text content of a node.


Gabor
program XML_Read;

uses DOM,XMLRead;

var
  X:TXMLDocument;

begin
  ReadXMLFile(X,'TEST.xml');
  WriteLn('*',X.FindNode('doc').FindNode('text1').TextContent,'*');
  WriteLn('*',X.FindNode('doc').FindNode('text2').TextContent,'*');
end.



  a
   

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

Re: [fpc-pascal] XML - Indent, text content, special char

2019-04-28 Thread Gabor Boros

2019. 04. 28. 9:35 keltezéssel, Michael Van Canneyt írta:

the newly exposed XMLWriter



Will be merged/backported into fixes_3_2?

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

Re: [fpc-pascal] XML - Indent, text content, special char

2019-04-28 Thread Gabor Boros

2019. 04. 27. 13:57 keltezéssel, Michael Van Canneyt írta:
As far as I know you can't. I recently changed some things in xmlwriter 
so you can

influence the formatting to some degree, but no attempt is made to respect
the formatting of a previously read file. I believe the formatting info is
discarded on read (I would need to veify) so this would require lots of
rewriting.


The "indent" and "text content" problems solved on the reader side by 
ReadXMLFilePreserveWhitespace:


http://wiki.freepascal.org/XML_Tutorial#Whitespace_characters

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

[fpc-pascal] XML - Indent, text content, special char

2019-04-27 Thread Gabor Boros

Hi All,

I have an existing XML file. After load(, modify) and save this file 
some mandatory formatting things lost from it. I need same indent as 
before, same text contents and not replace every special chars. With the 
below code I got the attached OUTPUT.xml from the attached INPUT.xml. 
Any idea how to solve this problem? (I use fixes_3_2.)


X:=TXMLDocument.Create;
ReadXMLFile(X,'INPUT.xml');
WriteXMLFile(X,'OUTPUT.xml');

Gabor

http://www.w3.org/2001/XMLSchema-instance;>
	a
	 
	X > Y
	 

http://www.w3.org/2001/XMLSchema-instance;>
  a
  
  X  Y
  

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

Re: [fpc-pascal] Libxml2 - How to get messages on Linux?

2018-05-25 Thread Gabor Boros

2018. 05. 24. 9:37 keltezéssel, Michael Van Canneyt írta:

Are these functions callbacks ? If so, is the calling convention correct ?



I used xmlSchemaSetValidErrors and the documentation say "Set the error 
and warning callback informations". Tried with and without cdecl.


Meanwhile tried xmlSchemaSetValidStructuredErrors and that works with 
Win32, Win64 and Linux 64bit.


Is libxml package have a maintainer or is it a legacy/deprecated thing? 
I experienced some differences between the documentation of libxml2 and 
the "Interfaces for validating" section in xmlschemas.inc.


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

Re: [fpc-pascal] Libxml2 - How to get messages on Linux?

2018-05-23 Thread Gabor Boros

Same problem with Win64. So not Linux specific.

Gabor

2018. 05. 22. 10:06 keltezéssel, Gabor Boros írta:

Hi All,

I need to accomplish validate XML files with an XSD. Found libxml in 
packages and works as expected with Win32. But I have problem with 
messages on Linux 64bit. Got %s instead the real message text. I use the 
below code to get the messages. Any idea why not works with Linux64 bit?


var
   SL_Warning,SL_Error:TStringList;

procedure SchemaValidityWarningFunc(ctx: Pointer; const msg: PChar);
begin
   SL_Warning.Add(msg);
end;

procedure SchemaValidityErrorFunc(ctx: Pointer; const msg: PChar);
begin
   SL_Error.Add(msg);
end;

Gabor
___
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

[fpc-pascal] Libxml2 - How to get messages on Linux?

2018-05-22 Thread Gabor Boros

Hi All,

I need to accomplish validate XML files with an XSD. Found libxml in 
packages and works as expected with Win32. But I have problem with 
messages on Linux 64bit. Got %s instead the real message text. I use the 
below code to get the messages. Any idea why not works with Linux64 bit?


var
  SL_Warning,SL_Error:TStringList;

procedure SchemaValidityWarningFunc(ctx: Pointer; const msg: PChar);
begin
  SL_Warning.Add(msg);
end;

procedure SchemaValidityErrorFunc(ctx: Pointer; const msg: PChar);
begin
  SL_Error.Add(msg);
end;

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

Re: [fpc-pascal] TStringList - Strange quotation mark handling

2017-08-16 Thread Gabor Boros

2017. 08. 16. 15:21 keltezéssel, Michael Van Canneyt írta:
Because the quotes must be the first and last character of each string 
(or "cell").


As noted in another reply, set the quote character to something unused, and
it will disable (or circumvent) quoting altogether.


SL2.QuoteChar:=#0; solved my problem. But strange if the TStringList 
think from a starting " the string is quoted. For example if data.cvs 
contains "abc|89|0 I got the next result with my example program 
(without QuoteChar trick): 0 * abc|89|0


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

Re: [fpc-pascal] TStringList - Strange quotation mark handling

2017-08-16 Thread Gabor Boros

2017. 08. 16. 15:15 keltezéssel, Kevin Jesshope írta:
Setting the quotechar to something impossible (linefeed, #0 etc) stops 
the quote processing.


SL2.QuoteChar:=#0; solved my problem. Thank you!

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

[fpc-pascal] TStringList - Strange quotation mark handling

2017-08-16 Thread Gabor Boros

Hi All,

With the attached example program and data.csv I got the next result:

0 * 84392
1 * asfds
2 * hytr
3 * 43421454
4 * O
5 *  fdsfds
6 * 654645645 "O" fdsfsd
7 * hgfgfedw
8 * fg
9 * 321.544
10 * 89
11 * 0


"O" fdsfds - broken into two parts which is bad from my POV. See 4 * O 
and 5 *  fdsfds. Why?


Gabor
84392|asfds|hytr|43421454|"O" fdsfds|654645645 "O" 
fdsfsd|hgfgfedw|fg|321.544|89|0program Project1;

uses Classes, sysutils;

var
  SL,SL2:TStringList;
  i:integer;

begin
  SL:=TStringList.Create;
  SL.LoadFromFile('data.csv');

  SL2:=TStringList.Create;
  SL2.StrictDelimiter:=True;
  SL2.Delimiter:='|';
  SL2.DelimitedText:=SL[0];

  for i:=0 to SL2.Count-1 do WriteLn(IntToStr(i)+' * '+SL2[i]);

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

Re: [fpc-pascal] SIGSEGV in fpc_check_object

2017-06-14 Thread Gabor Boros

2017. 06. 14. 10:28 keltezéssel, José Mejuto írta:
That's wrong for sure, x is not initialized to nil, not in Linux nor in 
Windows.


With the below code caption of the form not changed on Linux for me.

procedure TForm1.FormCreate(Sender: TObject);
var
  x:TPanel;

begin
  if Assigned(x) then Caption:='Assigned';
end;

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

[fpc-pascal] SIGSEGV in fpc_check_object

2017-06-14 Thread Gabor Boros

Hi All,

In my Lazarus application I use a TPanel descendant component (TMyPanel) 
which have subpanels (TMySubPanel) which are TPanel descendants also. 
The subpanels accessed through a TList. If add a new subpanel into the 
main panel added to the list with TList.Add if remove a subpanel from it 
remove from the list with TList.Remove then call TMySubPanel.Free. My 
main development platform is x86_64-Linux and the application works like 
a charm. But with the Windows version of the app (cross compiled to 
i386-Win32) got an "Access violation." at TMySubPanel.Free. If start 
with gdb got "Program received signal SIGSEGV, Segmentation fault.

0x004041c4 in fpc_check_object ()" at TMySubPanel.Free.

I completely don't understand what is the source of the problem and why 
the two platforms behaves differently.


Cannot have a simple test case just a dumb example.

procedure TForm1.FormCreate(Sender: TObject);
var
  x:TPanel;

begin
  x.Free;
end;

With Linux no error (x is Nil before the Free call), with Windows got 
SIGSEGV (x is not Nil before the Free call). Is it a Lazarus thing or 
come from FPC?


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

Re: [fpc-pascal] How to split file of whitespace separated numbers?

2016-12-23 Thread Gabor Boros

2016. 12. 23. 9:14 keltezéssel, Bo Berglund írta:

Is there a quick way to split a string of whitespace separated values
into the separate members?


Hi,

I don't know quick or not...

program Project1;

uses Classes;

var
  SL:TStringList;
  i:Integer;

begin
  SL:=TStringList.Create;
  SL.DelimitedText:='   0.0000.0007.0000.000  29.6628';
  for i:=0 to SL.Count-1 do
   begin
 WriteLn('*'+SL.Strings[i]+'*');
   end;
  ReadLn;
end.

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


Re: [fpc-pascal] Implicit conversion problem with TDate type

2016-11-02 Thread Gabor Boros

2016. 11. 02. 11:38 keltezéssel, Michael Van Canneyt írta:

If Delphi prints another result, then we can look at fixing the
implementation.


With Delphi 10.1 and "D: TDate;" the result is "date is 5" and with "D: 
TDateTime;" the result is "date is 7". So, the results are same with FPC 
and Delphi.


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


[fpc-pascal] Implicit conversion problem with TDate type

2016-11-02 Thread Gabor Boros

Hi All,

I use MWA's IBX for Firebird connection and have problem with date 
parameters. Tony provided to me a test program a suggested write to the 
FPC list. The simple test program is:


program Project1;

uses Variants, Sysutils;

var V: variant;
D: TDate;

begin
  D := EncodeDate(2016,10,20);
  V := D;
  writeln('date is ',VarType(D));
end.

The result is: "date is 5" (varDouble)

If modify D: TDate; to D: TDateTime; the result is "date is 7" (varDate)

I (We) missed something or is this a bug?

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


Re: [fpc-pascal] Can I open XZ compressed text file on the fly?

2016-10-28 Thread Gabor Boros

2016. 10. 27. 4:29 keltezéssel, Graeme Geldenhuys írta:

On 2016-10-26 14:58, Gabor Boros wrote:

Can I open it
without decompress it to the file system


Yes, simply use any component that implements the LZMA/LZMA2 compression
algorithms. You should then be able to decompress it in memory. I think
the TurboPower Abbrevia components on SourceForge support that. There
are probably other compression components that you can use too.

Regards,
  Graeme



Thank you Graeme!

I found this unit and works like a charm for me:

https://github.com/delphiunderground/xz-examples-delphi/blob/master/XZ.pas

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


[fpc-pascal] Can I open XZ compressed text file on the fly?

2016-10-26 Thread Gabor Boros

Hi All,

I need to analyze log file but its compressed with XZ. Can I open it 
without decompress it to the file system or can decompress in memory for 
example into a TStringList?


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


Re: [fpc-pascal] Free Delphi 10.1 Berlin Starter Edition

2016-08-24 Thread Gabor Boros

Anyone knows if Windows 7 would also work?


http://docwiki.embarcadero.com/RADStudio/Berlin/en/Installation_Notes#Operating_System_Requirements

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


Re: [fpc-pascal] Free Delphi 10.1 Berlin Starter Edition

2016-08-23 Thread Gabor Boros

2016. 08. 23. 17:40 keltezéssel, Dennis írta:


I miss its lightning fast compiler and good debugger.


+1

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


Re: [fpc-pascal] Access C++ APIs

2016-06-30 Thread Gabor Boros

2016. 06. 29. 17:11 keltezéssel, Dimitrios Chr. Ioannidis írta:

AFAIK, the Firebird New API is interface based not a C++ API.


Thank you for the clarification! (Firebird written in C/C++ and 3.0 have 
a new OO API, from this combination I think the new API is C++. :-) ).


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


[fpc-pascal] Access C++ APIs

2016-06-29 Thread Gabor Boros

Hi All,

I want to play a little with a fresh Qt 5.x. Lazarus access Qt through 
Qt4Pas. I see "Linking with C++ code" in future plans for FPC. Is there 
another way? For example I can access OO API of Firebird 3 with the 
provided pas file. Is it a special Firebird thing or a general solution?

Sorry for the dumb question I am a pascal guy and not have C/C++ knowledge.

https://github.com/FirebirdSQL/firebird/blob/B3_0_Release/src/include/gen/Firebird.pas

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


Re: [fpc-pascal] Object Pascal Handbook

2015-08-07 Thread Gabor Boros

2015.08.07. 13:13 keltezéssel, Gour írta:

I wonder, being FPC noob, how suitable it can be for learning FPC?


Hi,

The official documentation is not a good start point?

http://www.freepascal.org/docs.var

http://wiki.freepascal.org/FPC_documentation

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


[fpc-pascal] How to force unique field values with TBufDataSet

2015-04-27 Thread Gabor Boros

Hi All,

Added ixUnique type index with IndexDefs or AddIndex, set IndexName or 
IndexFieldNames. But no effect, I can add same field values without any 
error.


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


Re: [fpc-pascal] Free Pascal 2.6.4-rc1 released!

2013-12-26 Thread Gabor Boros

2013.12.26. 0:33 keltezéssel, Gerhard Scholz írta:

I downloaded

ftp://freepascal.stack.nl/pub/fpc/beta/2.6.4-rc1/i386-win32/fpc-2.6.4rc1.i386-win32.exe


The setup the said:

The setup files are corrupted. Please obtain a new copy of the program.

I did that; the second copy also didn't work.

Greetings

Gerhard


Hi,

I downloaded from 4-5 mirrors and got same error message.

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Free Pascal 2.6.4-rc1 released!

2013-12-26 Thread Gabor Boros

2013.12.26. 18:03 keltezéssel, Pierre Free Pascal írta:

   Please test again.

Sorry for the mistake.

Pierre Muller



Downloaded, installed and works like a charm.

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Win64 release of FPC 2.6.2 missing

2013-05-01 Thread Gabor Boros

2013.04.30. 20:39 keltezéssel, Graeme Geldenhuys írta:

Hi,

I just tried to update one of my Windows VM with the latest released
FPC. To my surprise there is no Win64 release for FPC 2.6.2 on
SourceForge? I only found a 32-bit cross-compiler.

Why is this?


Regards,
   - Graeme -



http://sourceforge.net/projects/freepascal/files/Win32/2.6.2/fpc-2.6.2.x86_64-win64.exe/download

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Free Pascal 2.6.2 - 64 - setup

2013-02-26 Thread Gabor Boros

2013.02.26. 15:20 keltezéssel, silvioprog írta:

Hello,

There are a setup to install FPC 2.6.2 stable 64 bit? In SF
(http://sourceforge.net/projects/freepascal/files) have only 32.

Thanks.

--
Silvio Clécio
My public projects - github.com/silvioprog http://github.com/silvioprog



http://sourceforge.net/projects/freepascal/files/Win32/2.6.2/fpc-2.6.2.x86_64-win64.exe/download

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: CrossFPC is finally released

2012-12-31 Thread Gabor Boros


2012.12.31. 0:18 keltezéssel, Ralf A. Quint írta:

At 03:01 PM 12/30/2012, leledumbo wrote:
Ok, still 33h to go 'til the end of December 2012 in this part of the
world, let's see if something is going to happen (or not...)

Ralf


https://forums.embarcadero.com/thread.jspa?threadID=81323tstart=0

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus settings and roaming profiles in Windows

2009-07-15 Thread Gabor Boros

Hi,

I don't know the answer for your question but I know a separate Lazarus 
mailing list exist.

http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Gabor

Jürgen Hestermann írta:
I am not sure whether there exists a separate mailing list just for 
Lazarus so I am posting this here:


Jürgen Hestermann.


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


Re: [fpc-pascal] When is FPC 2.2.4 docs available?

2009-05-09 Thread Gabor Boros

Hi,

ftp://ftp.freepascal.org/pub/fpc/dist/2.2.4/docs

Gabor

Graeme Geldenhuys írta:

Hi,

FPC 2.2.4 has already been released a while back, but the
documentation available for download (PDF files) are rather old. Could
new docs be generated and made available for download. Not everybody
has the skills or package dependencies to generate the PDF
documentation themselves.


From the following documentation download URL:


   http://www.freepascal.org/docs.var


FCL pdf = August 2007
FPDoc pdf = August 29, 2007
Lang Ref pdf = August 2007 for FPC 2.2.0
etc...


Regards,
  - Graeme -


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


Re: [fpc-pascal] Convert complicated string to DateTime

2009-03-04 Thread Gabor Boros

leledumbo írta:


What's the output of this:

FormatDateTime(' dd hh:nn:ss ',Now);


március 04 09:42:02 2009



that way you can understand what you should supply to ScanDateTime as the
corresponding value for  format. I mean, maybe it's not November, but
something else equivalent in your localization.


But I defined LongMonthNames in a TFormatSettings type variable and 
passed to ScanDateTime.


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


[fpc-pascal] Convert complicated string to DateTime

2009-03-03 Thread Gabor Boros

Hi,

I want to convert a string to a TDateTime variable.
In example the string is: 'November 21 09:42:21 2008'.
I tried ScanDateTime with ' dd hh:nn:ss ' pattern but not 
working. How can I convert this type of string to DateTime?


Gabor


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


Re: [fpc-pascal] Convert complicated string to DateTime

2009-03-03 Thread Gabor Boros

And? I don't understand your suggestion.

leledumbo írta:


Gabor Boros wrote:

Hi,

I want to convert a string to a TDateTime variable.
In example the string is: 'November 21 09:42:21 2008'.
I tried ScanDateTime with ' dd hh:nn:ss ' pattern but not 
working. How can I convert this type of string to DateTime?



ScanDateTime does the opposite of what FormatDateTime does, so you should
look at the output of FormatDateTime with that pattern. Note that if it
outputs String (such as that 'November'), it will depend on your
localization.


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


[fpc-pascal] SScanf question

2008-11-30 Thread Gabor Boros

Hi,

SScanf('123: aaa :456','%d: %s :%d',[EMAIL PROTECTED],@string1,@integer2]);

In this situation string1 is aaa. It is correct.

SScanf('123: bbb aaa :456','%d: %s :%d',[EMAIL PROTECTED],@string1,@integer2]);

In this situation string1 is bbb. But I need the whole string(bbb aaa). 
And I don't know how many piece contain the string. In example: 'Mr. aaa 
bbb' or 'Mr. aaa von bbb'. Can SScanf return the whole string?


Gabor

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


[fpc-pascal] Un/De-Format function still exists?

2008-11-25 Thread Gabor Boros

Hi,

Result of Format('abc: %d def: %d',[1,2]) is 'abc: 1 def: 20'.
It's ok , but I want to do this thing from the other direction.
I want to know the integers only and the strings ('abc') not the same in 
every line in a text file.

Is a function/procedure still exists in FPC or Lazarus for this problem.
If anybody understood me. ;-)

Gabor

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


Re: [fpc-pascal] Un/De-Format function still exists?

2008-11-25 Thread Gabor Boros

Thank you!

Gabor

JoshyFun írta:


Look for SScanf function, maybe it will fit your needs.



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


[fpc-pascal] How can i detect what cause the problem

2006-11-14 Thread Gabor Boros

Hi,

I have a Symbol mobile device with an integrated barcode scanner.
The scanner's API in C and I cannot use every API calls.

An example: The problem appears in the 
ScanBuffer:=SCAN_AllocateBuffer(TRUE,dwScanSize);

line (see the test app below).
If I run in GDB the error message is:

warning: Prefetch Abort: Thread=8dcfe8dc Proc=8c329ab0 'project1.exe'
warning: AKY=4001 PC= RA=00011338 BVA= FSR=04f0

Program received signal SIGSEGV, Segmentation fault.
0x in ?? ()

The test app is:

program test;

{$apptype console}
{$PACKRECORDS C}

uses Windows, dynlibs;

const
  MAx_SRC=32;
  dwScanSize:DWORD=7095;

type
  STRUCT_INFO=record
dwAllocated:DWORD;
dwUsed:DWORD;
  end;

  LABELTYPE = DWORD;

  LPSCAN_BUFFER = ^SCAN_BUFFER;
  SCAN_BUFFER=record
StructInfo:STRUCT_INFO;
dwDataBuffSize:DWORD;
dwOffsetDataBuff:DWORD;
dwDataLength:DWORD;
dwTimeout:DWORD;
dwStatus:DWORD;
bText:BOOL;
dwLabelType:LABELTYPE;
dwRequestID:DWORD;
TimeStamp:SYSTEMTIME;
dwDirection:DWORD;
szSource:array[0..MAx_SRC-1] of TCHAR;
blsMultiPart:BOOL;
dwScanID:DWORD;
dwBarcodeID:DWORD;
dwNumRemaining:DWORD;
dwOffsetAuxDataBuff:DWORD;
dwAuxDataLength:DWORD;
  end;

  T_SCAN_AllocateBuffer = function 
(bText:BOOL;dwSize:DWORD):LPSCAN_BUFFER; cdecl;


var
  SCAN_AllocateBuffer: T_SCAN_AllocateBuffer;
  DLL_Handle:TLibHandle;
  ScanBuffer:LPSCAN_BUFFER;

begin
  DLL_Handle:=LoadLibrary('SCNAPI32.DLL');
  Pointer(SCAN_AllocateBuffer):=GetProcedureAddress(DLL_Handle, 
'SCAN_AllocateBuffer');


  ScanBuffer:=SCAN_AllocateBuffer(TRUE,dwScanSize);

  UnloadLibrary(DLL_Handle);
end.


Thanks!

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How can i detect what cause the problem

2006-11-14 Thread Gabor Boros

Many thanks Felipe, the problem is the exported name(s).
The exported names is SCAN_AllocateBuffer_A and SCAN_AllocateBuffer_W.

Thanks again!

Gabor

Felipe Monteiro de Carvalho írta:

Can you show us the c declaration of the function you are calling? It
should be on a .h file.

Also, you should put an way to verify if the calls are working, like:

   DLL_Handle:=LoadLibrary('SCNAPI32.DLL');

   if DLL_Handle = nil then raise EException.Create('Could not load 
library');


   Pointer(SCAN_AllocateBuffer):=GetProcedureAddress(DLL_Handle,
'SCAN_AllocateBuffer');

   if Pointer(SCAN_AllocateBuffer) = nil then raise
EException.Create('Could not load procedure');

One possibility is that this C library uses name mangling, and the
function has a different name from the canonical one. You can check
all function names exported by the function using this software:

http://wiki.lazarus.freepascal.org/Libview



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


[fpc-pascal] C API call problem under WinCE

2006-11-06 Thread Gabor Boros

Hi,

If I start the test application on the WinCE device the result is:
project1.exe is not a valid Windows CE application.
If I comment out the SCAN_FindFirst call, the application run properly.
See below for the C header, and the test app.
Any suggestions?

Many Thanks!
Gabor

The C header file:

typedef struct tagSTRUCT_INFO
{
DWORD dwAllocated;
DWORD dwUsed;
} STRUCT_INFO;

typedef struct tagSCAN_FINDINFO
{
   STRUCT_INFO StructInfo;
   TCHAR   szDeviceName[MAX_DEVICE_NAME];
   TCHAR   szPortName[MAX_DEVICE_NAME];
   TCHAR   szFriendlyName[MAX_PATH];
   TCHAR   szRegistryBasePath[MAX_PATH];
} SCAN_FINDINFO;

DWORD SCAN_FindFirst(LPSCAN_FINDINFO lpScanFindInfo,LPHANDLE lphFindHandle);


The test application:

program test;

{$apptype console}

uses Windows;

const
  E_SCN_SUCCESS=0;
  MAX_DEVICE_NAME=6;

{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}

type
  tagSTRUCT_INFO = record
dwAllocated : DWORD;
dwUsed : DWORD;
  end;

  STRUCT_INFO = tagSTRUCT_INFO;
  tagSCAN_FINDINFO = record
StructInfo : STRUCT_INFO;
  szDeviceName : array[0..(MAX_DEVICE_NAME)-1] of TCHAR;
  szPortName : array[0..(MAX_DEVICE_NAME)-1] of TCHAR;
  szFriendlyName : array[0..(MAX_PATH)-1] of TCHAR;
  szRegistryBasePath : array[0..(MAX_PATH)-1] of TCHAR;
end;
  SCAN_FINDINFO = tagSCAN_FINDINFO;
  LPSCAN_FINDINFO = ^SCAN_FINDINFO;

  function SCAN_FindFirst(lpScanFindInfo:LPSCAN_FINDINFO; 
lphFindHandle:LPHANDLE):DWORD;cdecl;external 'SCNAPI32.DLL';


var
  lphFindHandle:LPHANDLE;
  lpScanFindInfo:LPSCAN_FINDINFO;

begin
  SCAN_FindFirst(lpScanFindInfo,lphFindHandle);
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Compile error in sources from SVN Rev. 4420

2006-08-14 Thread Gabor Boros

Hi,

The problem is, missed keyword 'class' in zipper.pp line 368 and 439.

Gabor
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal