Re: [Lazarus] SDL2 - win64

2016-03-24 Thread Björn Lundin
On 2016-03-23 19:22, Björn Lundin wrote:
> Hi!
> Using Lasarus 1.4.4

> I had Lazarus 1.6 before, but downgraded because of
> bug in databse interface reagrding floats.
> (thread with subject "TPQConnection and float")


Nevermind, I got the 32 bit version to work for both db interface and sdl2.


-- 
--
Björn

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


[Lazarus] SDL2 - win64

2016-03-23 Thread Björn Lundin
Hi!
Using Lasarus 1.4.4
I'm following the SDL tutorial at
http://www.freepascal-meets-sdl.net/
and get problems very fast.


looking at http://www.freepascal-meets-sdl.net/chapter-5-drawing-primitives/
I have the code starting like this


program Chapter5_SDL2;

uses SDL2;

var
i : integer;
sdlWindow1 : PSDL_Window;
sdlRenderer : PSDL_Renderer;
sdlRect1 : PSDL_Rect;
sdlPoints1 : array[0..499] of PSDL_Point;

begin

  //initilization of video subsystem
  if SDL_Init( SDL_INIT_VIDEO ) < 0 then HALT;

  sdlWindow1 := SDL_CreateWindow( 'Window1', 50, 50, 500, 500,
SDL_WINDOW_SHOWN );
  if sdlWindow1 = nil then HALT;
  writeln('1');
  sdlRenderer := SDL_CreateRenderer( sdlWindow1, -1, 0 );
  writeln('2');
  if sdlRenderer = nil then HALT;
and so on

However it crashes with runtime error 217 on line
sdlRenderer := SDL_CreateRenderer( sdlWindow1, -1, 0 );
I get '1' on the screen but not '2'



C:\bnl\svn\trunk\pascal\sdl-stuff>chapter5_sdl2.exe
1
Runtime error 217 at $07FEFD28ADAD
  $07FEFD28ADAD
  $07FEF9417F69
  $2D6E


if run from Lazarus, I get  some assembler listing

.

RaiseException
07FEFD28AD70 4881ecc800   sub$0xc8,%rsp
07FEFD28AD77 83e201   and$0x1,%edx
07FEFD28AD7A 488d05efff   lea-0x11(%rip),%rax#
0x7fefd28ad70 
07FEFD28AD81 894c2420 mov%ecx,0x20(%rsp)
07FEFD28AD85 33c9 xor%ecx,%ecx
07FEFD28AD87 4889442430   mov%rax,0x30(%rsp)
07FEFD28AD8C 89542424 mov%edx,0x24(%rsp)
07FEFD28AD90 48894c2428   mov%rcx,0x28(%rsp)
07FEFD28AD95 4d85c9   test   %r9,%r9
07FEFD28AD98 0f859a080100 jne0x7fefd29b638

07FEFD28AD9E 894c2438 mov%ecx,0x38(%rsp)
07FEFD28ADA2 488d4c2420   lea0x20(%rsp),%rcx
07FEFD28ADA7 ff15f3040400 callq  *0x404f3(%rip)#
0x7fefd2cb2a0 
07FEFD28ADAD 4881c4c800   add$0xc8,%rsp


and I have no clue where i crashes, but I presume it is in sdl2.dll
somewhere.
Downloaded the latest 64 bit for win at sdl.org (2.0.4)
searching throught the disk gives exactly 1 sdl2.dll

C:\>dir /s sdl2.dll
 Directory of C:\bnl\bin
2016-01-02  11:59 1 230 336 SDL2.dll
   1 File(s)  1 230 336 bytes
 Total Files Listed:
   1 File(s)  1 230 336 bytes
   0 Dir(s)  122 686 066 688 bytes free



Anyone has some ideas what to do.
Needless to say, google runtime error 217 gives no clear indication
on why it is complaining.

I had Lazarus 1.6 before, but downgraded because of
bug in databse interface reagrding floats.
(thread with subject "TPQConnection and float")




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


Re: [Lazarus] TPQConnection and float

2016-03-22 Thread Björn Lundin
2016-03-22 8:02 GMT+01:00 Michael Van Canneyt :


> This is a known bug which is fixed in trunk.
> See e.g. http://bugs.freepascal.org/view.php?id=29760
>
>
Oh, it did not occur to me to look for a ticket/bug database.
Thanks, I'll go for a downgrade coming weekend.

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


[Lazarus] TPQConnection and float

2016-03-21 Thread Björn Lundin
Hi !
I'm new to Lazarus (since Saturday)
but in the 90:ies id wrote some Turbo Pascal for school and liked it.
However, the last 15 years, I've worked with a system written in Ada
so that is the language I'm fluid in.
But it is close to Pascal.

So - I started to write a form with a tree widget and a graph,
and started go get data from a database to fill the graph with,
depending on the selected node in the tree.
But the values are off with a factor 1.

I wrote a console test program to reproduce it,
and in also gets the floats wrong with a factor 1.

Where should I report this - if this mailing list is not the place?
But perhaps first of all - am I doing something wrong here ?
code below.

Besides this, I am really impressed with Lazarus,
as an IDE.

I've already ordered some books at Amazon.

output as follows:
C:\pg_test_float>test_float.exe
A: 1
B:  1.E+004
C:  2.2000E+004
round(B): 1
round(C): 22000

(Win7 , Postgres 9.4, libpq.dll also 9.4, Lazarus 1.6)

program test_float;
uses
pqconnection,sqldb ;

function CreateConnection: TPQConnection;
begin
  result := TPQConnection.Create(nil);
  result.Hostname := 'some-server';
  result.DatabaseName := 'some-db';
  result.UserName := 'some-user';
  result.Password := 'some-pass;
end;

function CreateTransaction(pConnection: TPQConnection): TSQLTransaction;
begin
  result := TSQLTransaction.Create(pConnection);
  result.Database := pConnection;
end;

function CreateQuery(pTransaction: TSQLTransaction): TSQLQuery;
begin
  result := TSQLQuery.Create(pTransaction.Database);
  result.Database := pTransaction.Database;
  result.Transaction := pTransaction
end;

var
PQConn : TPQConnection;
T  : TSQLTransaction;
Q1, Q2, Q3 : TSQLQuery;

A : LongInt;
B,C : Double;

sSql : String;
begin
  PQConn := CreateConnection ;
  PQConn.Open;
  T := CreateTransaction(PQConn);
  T.StartTransaction;

  Q1 := CreateQuery(T) ;
  sSql := 'create table TEST ( ';
  sSql += 'A integer not null primary key, ';
  sSql += 'B numeric(8,3) not null , ';
  sSql += 'C numeric(15,2) not null ) ';

  Q1.SQL.Text := sSql;
  Q1.ExecSql;

  Q2 := CreateQuery(T) ;
  sSql := 'insert into TEST values (1, 1.0, 2.2)';
  Q2.SQL.Text := sSql;
  Q2.ExecSql;

  Q3 := CreateQuery(T) ;
  sSql := 'select * from TEST order by A';
  Q3.SQL.Text := sSql;
  Q3.Open;
  if not Q3.Eof then begin
A := Q3.FieldByName('A').AsLongint;
B := Q3.FieldByName('B').AsFloat;
C := Q3.FieldByName('C').AsFloat;
Writeln('A: ', A);
Writeln('B: ', B);
Writeln('C: ', C);
Writeln('round(B): ', round(B));
Writeln('round(C): ', round(C));

  end
  else
writeln('Eos');

  Q3.Close;
  T.Rollback;
  Q1.Free;
  Q2.Free;
  Q3.Free;
  T.Free;
  PQConn.Close;
end.


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