<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi !<br></div>I'm new to Lazarus (since Saturday)<br></div>but in the 90:ies id wrote some Turbo Pascal for school and liked it.<br></div>However, the last 15 years, I've worked with a system written in Ada<br></div>so that is the language I'm fluid in.<br></div>But it is close to Pascal.<br><br></div>So - I started to write a form with a tree widget and a graph,<br></div>and started go get data from a database to fill the graph with,<br></div><div>depending on the selected node in the tree.<br></div>But the values are off with a factor 10000.<br><br></div>I wrote a console test program to reproduce it, <br></div>and in also gets the floats wrong with a factor 10000.<br><br></div>Where should I report this - if this mailing list is not the place?<br></div>But perhaps first of all - am I doing something wrong here ?<br></div>code below.<br><br></div>Besides this, I am really impressed with Lazarus,<br></div>as an IDE.<br><br></div>I've already ordered some books at Amazon.<br><div><div><div><div><div><div><div><br><div><div>output as follows:<br>C:\pg_test_float>test_float.exe<br>A: 1<br>B: 1.0000000000000000E+004<br>C: 2.2000000000000000E+004<br>round(B): 10000<br>round(C): 22000<br><br></div><div>(Win7 , Postgres 9.4, libpq.dll also 9.4, Lazarus 1.6)<br><br>program test_float;<br>uses<br>pqconnection,sqldb ;<br><br>function CreateConnection: TPQConnection;<br>begin<br> result := TPQConnection.Create(nil);<br> result.Hostname := 'some-server';<br> result.DatabaseName := 'some-db';<br> result.UserName := 'some-user';<br> result.Password := 'some-pass;<br>end;<br><br>function CreateTransaction(pConnection: TPQConnection): TSQLTransaction;<br>begin<br> result := TSQLTransaction.Create(pConnection);<br> result.Database := pConnection;<br>end;<br><br>function CreateQuery(pTransaction: TSQLTransaction): TSQLQuery;<br>begin<br> result := TSQLQuery.Create(pTransaction.Database);<br> result.Database := pTransaction.Database;<br> result.Transaction := pTransaction<br>end;<br><br>var<br>PQConn : TPQConnection;<br>T : TSQLTransaction;<br>Q1, Q2, Q3 : TSQLQuery;<br><br>A : LongInt;<br>B,C : Double;<br><br>sSql : String;<br>begin<br> PQConn := CreateConnection ;<br> PQConn.Open;<br> T := CreateTransaction(PQConn);<br> T.StartTransaction;<br><br> Q1 := CreateQuery(T) ;<br> sSql := 'create table TEST ( ';<br> sSql += 'A integer not null primary key, ';<br> sSql += 'B numeric(8,3) not null , ';<br> sSql += 'C numeric(15,2) not null ) ';<br><br> Q1.SQL.Text := sSql;<br> Q1.ExecSql;<br><br> Q2 := CreateQuery(T) ;<br> sSql := 'insert into TEST values (1, 1.0, 2.2)';<br> Q2.SQL.Text := sSql;<br> Q2.ExecSql;<br><br> Q3 := CreateQuery(T) ;<br> sSql := 'select * from TEST order by A';<br> Q3.SQL.Text := sSql;<br> Q3.Open;<br> if not Q3.Eof then begin<br> A := Q3.FieldByName('A').AsLongint;<br> B := Q3.FieldByName('B').AsFloat;<br> C := Q3.FieldByName('C').AsFloat;<br> Writeln('A: ', A);<br> Writeln('B: ', B);<br> Writeln('C: ', C);<br> Writeln('round(B): ', round(B));<br> Writeln('round(C): ', round(C));<br><br> end<br> else<br> writeln('Eos');<br><br> Q3.Close;<br> T.Rollback;<br> Q1.Free;<br> Q2.Free;<br> Q3.Free;<br> T.Free;<br> PQConn.Close;<br>end.<br><br></div><div><br><div><div><div><div><div><div><div><div><div><div>-- <br><div class="gmail_signature">/Björn</div>
</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>