[Lazarus] Clear font backgrounds

2009-04-13 Thread Dave Coventry
Hi,

I'm using Image1.Convas.TextOut and I need the font background to be clear.

Does anyone know how to achieve this?

Thanks,

Dave Coventry
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Clear font backgrounds

2009-04-13 Thread Dave Coventry
Hi Martin, Thanks for the response.

2009/4/13 Martin Friebe laza...@mfriebe.de:
 uses LCLType, LCLIntf;

  SetBkMode(Image1.Canvas.Handle,  TRANSPARENT);

Yes, I do seem to have these functions.

 You may have to use  LCLIntf.ExtTextOut()

I'm not sure I understand.

Do you mean Image1.Canvas.LCLIntf.ExtTextOut()?

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


Re: [Lazarus] Clear font backgrounds

2009-04-13 Thread Dave Coventry
2009/4/13 Martin Friebe laza...@mfriebe.de:
 After SetBKMode try to output text as usual, eg with:
 Image1.Canvas.TextOut().  (or whatever it is, I don't recall exactly)

 This may already work, I haven't tried it

No, it doesn't, I'm afraid.

 What I have used is:

  dc := Canvas.Handle;
  SetBkMode(dc,  TRANSPARENT);
  LCLIntf.ExtUTF8Out(dc, X, Y, 0, @ARect, Text, Length, nil);

 ARect is a TRect thats specifies where the text goes. Unless you use
 clipping, only the top edge matters (since the background is transparent
 too)

 Example can be found in SynEdit:  components\synedit\syntextdrawer.pp
 line 1175 (the line refers to the SVN version; use search otherwise);
 the BKMode is set in synedits main unit.

I've found an easier way:

Set Image1.Canvas.Bruch.Style:=bsClear.

Works fine.

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


Re: [Lazarus] Clear font backgrounds

2009-04-13 Thread Dave Coventry
2009/4/13 Martin Friebe laza...@mfriebe.de:
 After SetBKMode try to output text as usual, eg with:
 Image1.Canvas.TextOut().  (or whatever it is, I don't recall exactly)

 This may already work, I haven't tried it

No, it doesn't, I'm afraid.

 What I have used is:

  dc := Canvas.Handle;
  SetBkMode(dc,  TRANSPARENT);
  LCLIntf.ExtUTF8Out(dc, X, Y, 0, @ARect, Text, Length, nil);

 ARect is a TRect thats specifies where the text goes. Unless you use
 clipping, only the top edge matters (since the background is transparent
 too)

 Example can be found in SynEdit:  components\synedit\syntextdrawer.pp
 line 1175 (the line refers to the SVN version; use search otherwise);
 the BKMode is set in synedits main unit.

I've found an easier way:

Set Image1.Canvas.Bruch.Style:=bsClear.

Works fine.

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


Re: [Lazarus] how to communicate with a ssh server

2009-03-19 Thread Dave Coventry
As you were. :(

The Plink output IS coming through, but whole sections of it are
missing. Presumably when the thread is processing the information it
cannot continue to accept the output from the pipe and that output is
'lost'. This explanation is not really consistent with some of the
earlier output still being available, but it's the best I can think
of.

Does anyone have any solutions?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] how to communicate with a ssh server

2009-03-18 Thread Dave Coventry
I need some advice on how to communicate with a ssh server.

I thought that I would take a short cut and use plink to do the donkey
work, just using TProcess to communicate with Plink, and this has
worked, up to a point.

However, it is largely unreliable.

Installing LNet has failed with the error message which says: Error:
Identifier not found __front_type__
(v0.9.27 r18951 i386-win32-win32/win64, fpc version 2.2.5 [2009/03/11]).
Similarly Indy has difficulty locating the project files, ICS doesn't
support ssh and Synapse doesn't connect. (Synapse also needs DLLs)

I am writing to Plink like this:

procedure TForm1.SendData(sendstring: string);
begin
  plink.input.write(sendstring[1],length(sendstring));
end;



And I am reading from Plink like this:

function TForm1.readplink: string;
var Buffer: string;
  BytesAvailable:DWord;
  bufsize,BytesRead: integer;
  pC: PChar;
begin
  BytesAvailable := PLink.Output.NumBytesAvailable;
  BytesRead:=0;
  Result:='';
//Sleep(100)-- If not commented out, some output is retrieved
  while BytesAvailable0 do
  begin
SetLength(Buffer, BytesAvailable);
BytesRead := PLink.OutPut.Read(Buffer[1], BytesAvailable);
Result:=Result+Copy(Buffer,1,BytesRead);
BytesAvailable := PLink.Output.NumBytesAvailable;
NoMoreOutput := false;
  end;
end;


I can connect okay, but if I send Plink an instruction:

SendData('cd /opt/myapp'+#10);

But when try to retrieve the output:
  repeat
NoMoreOutput := true;
plinkData:=plinkData+readplink;
  until noMoreOutput;

Followed by:
SendData('ls -la'+#10);

and, again, retrieving the output:
  repeat
NoMoreOutput := true;
plinkData:=plinkData+readplink;
  until noMoreOutput;

No output is retrieved from PLink.

However, if I put a sleep(100) at the beginning of the readplink
function, then I get some output (but, interestingly, the output from
the first command only appears with the output of the second command).
Also, using the debugger produces another set of results entirely.

This is all far too unpredictable to be of any use to me.

Can anyone give me any advice on this?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] how to communicate with a ssh server

2009-03-18 Thread Dave Coventry
Funny how after one goes into a really longwinded explanation of what
one is trying to do and how it is not working that the answer presents
itself.

I have set up a separate thread to keep polling the PLink process and,
sure enough, eventually it all came out

Sorry to have wasted anyone's time on this!

Although, having said that, I would much rather solve the problem
without having to go to an external app like Plink, so if anyone has
any suggestions.

Thanks again.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] TProcess 2-way conversation

2009-03-13 Thread Dave Coventry
Hi,

I'm writing a quick an dirty app to automate some commands which would
normally be issued by a terminal something like PuTTy.

To do this I'm using TProcess to call plink.exe and then trying to ssh
into the remote box and issue commands.

In short I want to log into the remote box and execute commands 'cd
/opt/someappdir' and './someapp', taking the input through one memo
and using another memo to issue the commands.

Can anyone point me in the right direction? I can open the terminal:

  PLink.CommandLine := 'plink.exe -ssh -pw
'+options.Values['Password']+' -batch
'+options.Values['User']+'@'+options.Values['Server'];
but sending subsequent calls fail:
  PLink.CommandLine := 'cd /opt/someappdir/ta';

Error message: 'Failed to execute cd /opt/someappdir/ta'

If I omit the subsequent calls it works roughly as expected:


  Plink.Options := [poUsePipes];
  Memo1.Append('-- executing --');
  Screen.Cursor:=crHourGlass;
  PLink.Execute;
  M.SetSize(BytesRead + READ_BYTES);
  n := PLink.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
  if n  0
  then begin
S.LoadFromStream(M);
Memo1.Append(S.Text)
  end;
  S.Free;
  M.Free;

and I get the following in memo1:

-- executing --
Last login: Fri Mar 13 02:49:21 2009 from 192.168.37.43

Y?J??9?a?f??/F?#2۶?/??Y.KDPx?R?`?8?\.ow?z%

Can anybody suggest something here? Or point me in a better direction.

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


Re: [Lazarus] TProcess 2-way conversation

2009-03-13 Thread Dave Coventry
Thanks guys!

Actually, as I sent it off I thought This isn't the best way of doing
this and I thought I might get either a dignified lack of response or
howls of derision!

But I'm having great difficulty in stalling any of the Internet
suites: lNet doesn't install because of a missing __front_type__
identifier ( http://forum.lazarus.freepascal.org/index.php/topic,6126.0.html
), Indy installs but it can't find the 'uses' code.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TProcess 2-way conversation

2009-03-13 Thread Dave Coventry
Hi Vincent,

2009/3/13 Vincent Snijders vsnijd...@vodafonevast.nl:
 See the process example:

 http://wiki.lazarus.freepascal.org/Executing_External_Programs#Using_input_and_output_of_a_TProcess
 and
 https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/examples/process/

 Vincent

That was the article on which I based my code.

I'm not having much luck.


  PLink.CommandLine := plink.exe -ssh -pw
'+options.Values['Password']+' -batch
'+options.Values['User']+'@'+options.Values['Server'];
  Plink.Options := [poUsePipes];
  Memo1.Append('-- executing --');
  PLink.Execute;
  M.SetSize(BytesRead + READ_BYTES);
  n := PLink.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
  if n  0 then
  begin
S.LoadFromStream(M);
for i:=0 to S.Count-1 do
begin
  Memo1.Lines.Append(S[i]);
end;
  end
  else
  begin
Memo1.Lines.Append('Unable to open '+options.Values['Server']);
  end;
  remoteCommand:='ls -l'+#10;
  plink.input.write(remoteCommand[1],length(remoteCommand));
  M.SetSize(BytesRead + READ_BYTES);
  n := PLink.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
  if n  0 then
  begin
S.LoadFromStream(M);
for i:=0 to S.Count-1 do
begin
  Memo1.Lines.Append(S[i]);
end;
  end;

I would expect the output of 'ls -l' to give me quite a lot of
information but S.LoadFromStream(M); doesn't contain anything at all.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Weird behaviour of copyrect.

2009-02-25 Thread Dave Coventry
I have a program which contains the following elements:

I have loaded a jpeg onto a TBitmap with the dimensions of 2772x2246 pixels.
I have a TImage on a form upon which I've copied a section of the
original bitmap (the Image height is 800 and the width is 1000
pixels).

I am using Image1.Canvas.CopyRect(Dest,JPegPic.Canvas,Source) to copy
a section of the Bitmap onto the smaller TImage.

What I'm trying to do is get the Bitmap to scroll over the Image area
as the Mouse cursor approaches the edge of the Image thus:

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var pagewid, pageht: integer;
begin
pagewid:=Image1.Width-x;
while pagewid10 do
begin
  PanImage(200,0);
  if Pic.Width-(Image1.Width+LeftB)=0 then break
end;
end;

procedure TForm1.panImage(X, Y: integer);
var Source,Dest: TRect;
  TX,TY: integer;
begin
  TopB+=Y;
  LeftB+=X;
  Source.Left:=LeftB;
  Source.Top:=TopB;
  Source.Bottom:=TopB+Image1.Height;
  Source.Right:=LeftB+Image1.Width;
  Dest.Top:=0;
  Dest.Left:=0;
  dest.Right:=Image1.Width;
  Dest.Bottom:=Image1.Height;
  Image1.Canvas.CopyRect(Dest,Pic.Canvas,Source);
end;

The interesting thing is that when the cursor approaches the right
hand edge of the Image the Bitmap does scroll over as expected but
when the cursor goes back towards the centre of the Image, the Bitmap
reverts and scrolls back.

It's no big deal; I'll probably just make the Image the same size as
the Bitmap and use the scroll bars, but I was hoping to avoid using
them. Still, I've wasted a day and a half trying to get around this
problem.

Details are as follows:

v0.9.27 r i386-win32-win32/win64

(Actually I'm a little bemused: I used tortoise svn yesterday to
update my Lazarus revision, but it doesn't seem to have taken. I'll
have to look into it).
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Mousewheel

2009-02-23 Thread Dave Coventry
Hi,

How do I read the Mousewheel?

The problem is that I have a TImage on my form and the Mpusewheel
events are for the Form; The Timage has no such events and it appears
to prevent the Form from getting these events.

My version is: v0.9.27 r15984:15992M i386-win32-win32/win64

Thank you,

Dave Coventry
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Mousewheel

2009-02-23 Thread Dave Coventry
Thanks.

As Graeme will confirm, us South Africans are at the whim of our
capricious Government Minister-Owned Monopoly Telecommunication
Company who use bandwidth as a mechanism for extorting additional
funds from their customers.

Hence my reluctance to stay entirely up to date.

Regards,

Dave Coventry

2009/2/24 Maxim Ganetsky gan...@narod.ru:
 Dave Coventry пишет:
 Hi,

 How do I read the Mousewheel?

 The problem is that I have a TImage on my form and the Mpusewheel
 events are for the Form; The Timage has no such events and it appears
 to prevent the Form from getting these events.

 My version is: v0.9.27 r15984:15992M i386-win32-win32/win64

 All I can say is: update your Lazarus.
 TImage OnMouseWheel events are present in Lazarus trunk and even in
 0.9.26.2 version.

 --
 Best regards,
  Maxim Ganetsky                  mailto:gan...@narod.ru
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


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


Re: [Lazarus] Large Integer errors

2009-02-14 Thread Dave Coventry
Yes, great, thanks.

Would there be any error or would Lazarus just continue as if nothing
had happened?


2009/2/14 Howard Page-Clark h...@talktalk.net:
 On Sat, 14 Feb 2009 12:30:55 +0200
 Dave Coventry dgcoven...@gmail.com wrote:

 function mycalc( num1,num2: real):integer;
 begin
   Result:=trunc(num1*num2);
 end;

 How can I protect from the product of the two numbers being too big?

 If it's too big I want to discard it anyway.

 function mycalc( num1,num2: real):integer;
  begin
   Result:=trunc(num1*num2);
  if result  maxint then result := 0;
  end;

 Would this do what you want?


 Howard Page-Clark h...@talktalk.net
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] Large Integer errors

2009-02-14 Thread Dave Coventry
Thanks Howard.

If the result is never going to be more than maxint anyway, then I
don't have to do anything at all, that will be perfectly acceptable to
me as it would already be beyond what is usable.

What would screw me up would be if I just lose the topmost bit and it
all resets to zero again.

2009/2/14 Howard Page-Clark h...@talktalk.net:
 On Sat, 14 Feb 2009 17:56:50 +
 Dave Coventry dgcoven...@gmail.com wrote:

 Yes, great, thanks.

 Would there be any error or would Lazarus just continue as if nothing
 had happened?


 2009/2/14 Howard Page-Clark h...@talktalk.net:
  On Sat, 14 Feb 2009 12:30:55 +0200
  Dave Coventry dgcoven...@gmail.com wrote:
 
  function mycalc( num1,num2: real):integer;
  begin
Result:=trunc(num1*num2);
  end;
 
  How can I protect from the product of the two numbers being too
  big?
 
  If it's too big I want to discard it anyway.
 
  function mycalc( num1,num2: real):integer;
   begin
Result:=trunc(num1*num2);
   if result  maxint then result := 0;
   end;
 
  Would this do what you want?

 Actually the code I fired off is useless - since result is an integer
 it is never going to be more than maxint! What you need is

 function mycalc( num1,num2: real):integer;
 var tmp: int64;
  begin
   tmp :=trunc(num1*num2);
   if (tmp = maxint) then
result := tmp
  else result := 0;
  end;

 Errors will only be flagged up if you compile with -Co
 or tick the appropriate overflow check box in the compiler options
 dialog, Code tab, Checks panel.

 
 Howard Page-Clark h...@talktalk.net
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] TStringList.SaveToFile loses path deliminators - possible bug?

2009-01-30 Thread Dave Coventry
Bart,

No Bug.

I had simply failed to create the Directory that the Config file is written to.

What threw me was the error message which had all the backslashes
stripped out of the path string.

Sorry to have brought this up.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-29 Thread Dave Coventry
= snip ===
   case ftype of
 43://'+'
 begin
   FS:=TFileStream.Create(fname, fmshareDenyWrite);
   Try
 FS.Seek(pos,soFromBeginning);
 FS.ReadBuffer(fldheader[0],4);
 increm:=LEtoN(PLongInt(fldheader)^)+1;
 for m:=0 to 3 do
 begin
   fldheader[m]:=increm and 255;
   increm:=increm shr 8;
 end;
  FS.Seek(pos,soFromBeginning);
  FS.WriteBuffer(fldheader[0],4); - Fails here
   Finally
 FreeAndNil(FS);
   end;
 end;
   end;
= snip ===

Continuing on the same block:

I am trying to read a block of 4 bytes, increment it by one and write
it back again.

However, if fails on the write.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-27 Thread Dave Coventry
2009/1/27 Michael Van Canneyt mich...@freepascal.org:
 That is what he is saying, yes.

I can confirm that this is the case.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
I'm having some difficulty over this:

= snip ===
  FS:=TFileStream.Create(fname, fmshareDenyWrite);
  Try
FS.ReadBuffer(hdbuffer[0],32);
  Finally
FreeAndNil(FS);
  end;
  RecSize:=LEtoN(PSmallInt(@hdbuffer[10])^);
  SetLength(recbuffer,RecSize);
  FillChar(recbuffer,RecSize,' ');
  pos:=68;
  bufferpos:=1;
  setLength(fldheader,48);
  for i:=0 to gFields.Count-1 do
  begin
ftype:=getFieldType(PChar(gFields.GetItem(i)));
case ftype of
  43://'+'
  begin
FS:=TFileStream.Create(fname, fmshareDenyWrite);- Fails here
Try
  FS.Seek(pos,soFromBeginning);
  FS.ReadBuffer(fldheader[0],4);
Finally
  FreeAndNil(FS);
end;
  end;
= snip ===

Project raised exception class 'External: SIGSEgV'

Followed by:

Project raised exception class 'RunError (216)'
'Access Violation'

What am I doing wrong?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
Hi AJ.

I was under the impression that this:

 FS:=TFileStream.Create(fname, fmshareDenyWrite);
 Try
   FS.ReadBuffer(hdbuffer[0],32);
 Finally
   FreeAndNil(FS);-
 end;

would free the File Pointer to be used again.

Do you suggest that I use another variable when I do it the second time?

Is it possible to specify that the program only uses one thread?

I'm having a lot of unexplained errors in developing this app and I'm
wondering if this isn't the cause of a lot of them.


FS2:=TFileStream.Create(fname, fmshareDenyWrite);

Surely that would fail too?

2009/1/26 ajv a...@vogelaar-electronics.com:
 Dear Dave Coventry,

 Probably the FileStream still exist in an other thread.
 Application.ProcessMessages might help.
 Better is it to open the stream on fname once an reposition the pointer
 repeatedly.

 Success.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
Hi Michael.

The file is accessed correctly the first time, but fails the second time.

2009/1/26 Michael Van Canneyt mich...@freepascal.org:
 This is so by default, unless you create threads yourself ?

No, I didn't.

 More likely is simply the fact that the file cannot be locked.

How can I check this?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
2009/1/26 Vincent Snijders vincent.snijd...@gmail.com:
 2009/1/26, Mattias Gaertner nc-gaert...@netcologne.de:
 Maybe you mean

 FillChar(recbuffer^,RecSize,' ');
  ?


 Or FillChar(recbuffer[1],RecSize,' ');

 if it is a string or [0] if it is a dynarray.

Thanks.

I'll put that in. It seemed to work okay as written but I obviously
never had the opportunity to check the output.

I'll have a go at twisting the code around to see if I can get the
calls to the file stream in the same 'try' block.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
2009/1/26 Andrew Brunner andrew.t.brun...@gmail.com:
 Actually, I'm thinking you're creating a memory problem with using
 fillchar and passing the pointer to the dynarray instead of the
 element.  Try using FillChar with the zero element again...  The
 reason why the construction maybe failing is b/c a potential memory
 leak created by not using the zero element of the dynarray you are
 using.

So you're saying that if I miss out the Fillchar function, it will
work a expected? Apart from the fact that my array won't be filled
with spaces, of course.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Where to place definition of a record?

2009-01-24 Thread Dave Coventry
Hi,

I'm following a suggestion for producing my own records
so that I can define a custom TStringlist as detailed in this
article:
http://dn.codegear.com/article/33423

However, I am unsure of where to post this code and am
wondering if someone would advise me.
=== snip ===
unit mvlists;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

type
  TNameValueRecord = record
  private
FNames: array of string;
FTypes: array of string;
function  GetCount: integer; inline;
function  GetItem(index: integer): string;
procedure SetItem(index: integer; const Value: string);
  public
function  Add(const line: string): integer;
procedure Clear;
function  IndexOf(const s: string): integer;
function  ValueOf(const s: string): integer;
property  Count: integer read GetCount;
property  Items[index: integer]: string read GetItem write SetItem; default;
  end;

implementation

function TNameValueRecord.Add(const nm, line: string): integer;
begin
  SetLength(FNames,Count+1);
  SetLength(FTypes,Count+1);
  FNames[Count-1] := line;
  FTypes[Count-1] := line;
  result := Count - 1;
end;
procedure TNameValueRecord.Clear;
begin
  SetLength( FNames, 0 );
  SetLength( FTypes, 0 );
...
=== snip ===

I get this error:
mvlists.pas(13,5) Fatal: Syntax error, : expected but identifier
FNAMES found

So I am clearly placing this code in the wrong section.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Not sure if the Laz Devs have seen this...

2009-01-22 Thread Dave Coventry
Please don't shoot me: :)

I just thought you might be interested in this:
http://www.theregister.co.uk/2009/01/21/git_gaining_ground/
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Not sure if the Laz Devs have seen this...

2009-01-22 Thread Dave Coventry
2009/1/22 Michael Van Canneyt mich...@freepascal.org:
 On Thu, 22 Jan 2009, Dave Coventry wrote:

 Please don't shoot me: :)

 Why would we do this ?

I just remember feathers flying a few months back when Graeme
suggested moving from SVN. :)
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Possible bug passing a TStringList to a function.

2009-01-20 Thread Dave Coventry
Darmawan,

When I put your code into my machine, it works fine.

Odd, because it is in more than one place where I've used the same
technique and they all fail at the same place.

But at least it would appear to be a problem with my coding, rather
than a bug in Lazarus, and it's not too difficult to work around.

Incidently my machine is AMD64 running Ubuntu 8.10 (Intrepid) and
using build v0.9.27 r17479 x86_64-linux-gtk 2 (beta)
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Passing an array to a function

2009-01-19 Thread Dave Coventry
I have a function that I'm trying to pass an array to.

function FieldValueAsString(fsbuffer: array of Byte; fitype,fisize:
integer): string;

Calling the function:

setlength(fsbuffer,recordsize);
FS:=TFileStream.Create(fname, fmshareDenyWrite);
FS.Seek(seekpos,soFromBeginning);
FS.ReadBuffer(fsbuffer,recordsize);
dfstring:= FieldValueAsString(fsbuffer,fitype,fisize);

Generates the error Project raised exception class SIGSEGV
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Passing an array to a function

2009-01-19 Thread Dave Coventry
Hi Andy, thanks for the response.

The array was declared as
var fsbuffer: array of Byte;

I tried your suggestion and typed the array as
Type TByteBuffer=Array of Byte;

then declared the buffer
var fsbuffer: TByteBuffer;

I also declared the function using 'var' as you suggested

function FieldValueAsString(var fsbuffer: TByteBuffer; fitype,fisize:
integer): string;

But my app is still falling over at the same point.

2009/1/19 Andrew Brunner andrew.t.brun...@gmail.com:
 Hi Dave,


 My first comment would be you must declare the input as a variable.
 Next, I probably would type the Array out as well before using it.

 Type TByteBuffer=Array of Byte;

 function FieldValueAsString(var fsbuffer:TByteBuffer; fitype,fisize:
 integer): string;

 Byte arrays should not generate an error.  There may be a memory leak
 for instances where you pass them in as constant values.  Because the
 Memory manager would need to free that memory as it is a dynamic
 array.

 -Andy


 On Mon, Jan 19, 2009 at 8:20 AM, Dave Coventry dgcoven...@gmail.com wrote:
 I have a function that I'm trying to pass an array to.

 function FieldValueAsString(fsbuffer: array of Byte; fitype,fisize:
 integer): string;

 Calling the function:

 setlength(fsbuffer,recordsize);
 FS:=TFileStream.Create(fname, fmshareDenyWrite);
 FS.Seek(seekpos,soFromBeginning);
 FS.ReadBuffer(fsbuffer,recordsize);
 dfstring:= FieldValueAsString(fsbuffer,fitype,fisize);

 Generates the error Project raised exception class SIGSEGV
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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

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


Re: [Lazarus] Passing an array to a function

2009-01-19 Thread Dave Coventry
Thanks Martin, that works.

2009/1/19 Dave Coventry dgcoven...@gmail.com:
 Hi Andy, thanks for the response.

 The array was declared as
 var fsbuffer: array of Byte;

 I tried your suggestion and typed the array as
 Type TByteBuffer=Array of Byte;

 then declared the buffer
 var fsbuffer: TByteBuffer;

 I also declared the function using 'var' as you suggested

 function FieldValueAsString(var fsbuffer: TByteBuffer; fitype,fisize:
 integer): string;

 But my app is still falling over at the same point.

 2009/1/19 Andrew Brunner andrew.t.brun...@gmail.com:
 Hi Dave,


 My first comment would be you must declare the input as a variable.
 Next, I probably would type the Array out as well before using it.

 Type TByteBuffer=Array of Byte;

 function FieldValueAsString(var fsbuffer:TByteBuffer; fitype,fisize:
 integer): string;

 Byte arrays should not generate an error.  There may be a memory leak
 for instances where you pass them in as constant values.  Because the
 Memory manager would need to free that memory as it is a dynamic
 array.

 -Andy


 On Mon, Jan 19, 2009 at 8:20 AM, Dave Coventry dgcoven...@gmail.com wrote:
 I have a function that I'm trying to pass an array to.

 function FieldValueAsString(fsbuffer: array of Byte; fitype,fisize:
 integer): string;

 Calling the function:

 setlength(fsbuffer,recordsize);
 FS:=TFileStream.Create(fname, fmshareDenyWrite);
 FS.Seek(seekpos,soFromBeginning);
 FS.ReadBuffer(fsbuffer,recordsize);
 dfstring:= FieldValueAsString(fsbuffer,fitype,fisize);

 Generates the error Project raised exception class SIGSEGV
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


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


Re: [Lazarus] Passing an array to a function

2009-01-19 Thread Dave Coventry
2009/1/20 Darmawan Sugiarto darmawan_sugia...@yahoo.com:
 Can you give more information about your function.

Sure:


function FieldValueAsString(var fsbuffer: TByteBuffer;
fitype,marker,fisize: integer): string;
begin
  case fitype of
43,52,108:Result:=inttostr(LEtoN(PLongint(@fsbuffer[marker])^));
 50:Result:=inttostr(LEtoN(PSmallInt(@fsbuffer[marker])^));
end;
end;

It was failing before it got there, so I don't think the problem was
with the function.

In any case, Martin's suggestion regarding calling the ReadBuffer
function with the first element of the array rather than the pointer
has worked...
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Possible bug passing a TStringList to a function.

2009-01-19 Thread Dave Coventry
Hi,

If I pass a TStringList to a function:

function TSLFunctn(myTSL: TSltringList):integer;
var i: integer;
begin
Result:=0;
for i:=0 to myTSL.Count-1 do //---fails here
begin
Result+=strtoint(myTSL.Strings[i]);
end;
end;

The function fails when I try to assign quantify myTSL.Count.

However, this works:

function TSLFunctn(myTSL: TSltringList):integer;
var i: integer;
internalTSL: TStringList;
begin
internalTSL:= TStringList.Create;
internalTSL:=myTSL;
Result:=0;
for i:=0 to internalTSL.Count-1 do //---works
begin
Result+=strtoint(internalTSL.Strings[i]);
end;
internalTSL.Free;
end;

Is this a bug? Or is that the way it's supposed to behave?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Loading an integer into a byte array

2009-01-08 Thread Dave Coventry
I have a file into which I want to put a long integer:

00 00 19 7A

The file expects the value in the form:

buffer[0]:=122;
buffer[1]:=25;
buffer[2]:=0;
buffer[3]:=0;

I am then intending to write this buffer to the file

FS.Writebuffer(buffer,4);

Is there a way of loading the buffer directly before writing?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Loading an integer into a byte array

2009-01-08 Thread Dave Coventry
Thanks DoDi.

2009/1/8 Hans-Peter Diettrich drdiettri...@aol.com:
 Dave Coventry schrieb:
 Which file?
It's just a data file that I'm writing to. But it does have to be
portable to other applications.

 That's the Intel byte order.
Yes, the specification of the datafile require little endian byte order.

 What is loading? Reading from the file?
No, the integer value is calculated and must be saved to the file.
There is more than one integer in a 48 byte block and I want to write
this block to the file, so I'm loading a 48 byte buffer. Some of the
values are single bytes or text.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TFileStream

2009-01-07 Thread Dave Coventry
How about if you wanted to change the contents of the start of a file?
Does it work if you seek to the start of the file and write a couple
of bytes, say, or do you have to rewrite the entire file?

2009/1/7 Andrew Brunner andrew.t.brun...@gmail.com:
 You could c write specific calls to write a byte or segment of contiguous 
 bytes.

 FS.Seek(128,soFromBegining);
 FS.WriteBuffer(fsBuffer[128],1);

 FS.Seek(132,soFromBegining);
 FS.WriteBuffer(fsBuffer[132],1);



 On Tue, Jan 6, 2009 at 7:55 PM, Dave Coventry dgcoven...@gmail.com wrote:
 I've started using TFileStream since posting a query here, but I'd
 like to know a bit more about it.

 Is there somewhere that I can find information on how to use it?

 Specifically, if I load a file into an array as follows:

 FS:=TFileStream.Create(fname, fmshareDenyWrite);
 FS.ReadBuffer(fsbuffer,recsize);

 can I alter the array and then save the altered array back into the file?

 do I just write the entire array back?

 fsbuffer[128]:=56;
 fsbuffer[132]:=42;
 FS.WriteBuffer(fsbuffer,recsize);


 or is there a better way?
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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

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


[Lazarus] TFileStream

2009-01-06 Thread Dave Coventry
I've started using TFileStream since posting a query here, but I'd
like to know a bit more about it.

Is there somewhere that I can find information on how to use it?

Specifically, if I load a file into an array as follows:

FS:=TFileStream.Create(fname, fmshareDenyWrite);
FS.ReadBuffer(fsbuffer,recsize);

can I alter the array and then save the altered array back into the file?

do I just write the entire array back?

fsbuffer[128]:=56;
fsbuffer[132]:=42;
FS.WriteBuffer(fsbuffer,recsize);


or is there a better way?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
Is there any documentation on this?
would the following:

longv:=LEtoN(@buffer[5]);

be the same as:

longv:=buffer[5];
longv+=buffer[6] shl 8;
longv+=buffer[7] shl 16;
longv+=buffer[8] shl 24;


2008/12/21 Andrew Haines andrewd...@aol.com:
 Yes. See LEtoN, BEtoN, NtoLE and NtoBE.

 BlockRead(F, FooLongInt, 4);

 FooLongInt := LEtoN(FooLongInt);

 Regards,

 Andrew
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
Hi Mattias,

Is there an equivalent for

shortv:=buffer[5];
shortv+=buffer[6] shl 8;

Many thanks

Dave

2008/12/21 Mattias Gaertner nc-gaert...@netcologne.de:
 On Sun, 21 Dec 2008 10:26:41 +0200
 Dave Coventry dgcoven...@gmail.com wrote:

 Is there any documentation on this?
 would the following:

 longv:=LEtoN(@buffer[5]);

 longv:=LEtoN(PLongint(@buffer[5])^);


 be the same as:

 longv:=buffer[5];
 longv+=buffer[6] shl 8;
 longv+=buffer[7] shl 16;
 longv+=buffer[8] shl 24;


 Mattias
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
Wow.

If I can push a little more: Can I read in an eight-byte IEEE double
using the same trick?

2008/12/21 Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com:
 On Sun, Dec 21, 2008 at 6:26 AM, Dave Coventry dgcoven...@gmail.com wrote:
 Is there any documentation on this?

 http://www.freepascal.org/docs-html/rtl/system/index-5.html

 would the following:

 longv:=LEtoN(@buffer[5]);

 be the same as:

 No, it's better. It only performs a conversion from Little Endian to
 current encoding. So it will just copy the contents if your software
 is running in a little endian processor or do the adequate conversion
 if your software is running in a big endian processor.

 --
 Felipe Monteiro de Carvalho
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] reading a little endian long.

2008-12-21 Thread Dave Coventry
2008/12/22 Marc Weustink m...@dommelstein.net:

 The example below is not complete, you need to cast.

 MyDouble:=LEtoN(PDouble(@buffer[5])^);

 Use codejumping (find declaration) on LEtoN to see what variants exist.

 Marc

Thanks Marc, I hadn't thought of doing that...

Thanks to all the guys who have given me help on this; I wasn't sure
that this list would be the best place to ask, but I was all googled
out.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] reading a little endian long.

2008-12-20 Thread Dave Coventry
If I Blockread(F,buffer,4) with buffer being an array of byte, Is
there a routine in fpc/lazarus which will revers the bytes for me?

This is what I want:
longv:=buffer[0];
longv+=buffer[1] shl 8;
longv+=buffer[2] shl 16;
longv+=buffer[3] shl 24;

Is there a function which does this for me?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Appending to a binary file

2008-12-20 Thread Dave Coventry
Thanks Andrew.

In future I will look at using filestreams rather than go down the
AssignFile route.

2008/12/19 Andrew Brunner andrew.t.brun...@gmail.com:
 Ok, so if you want to use TFileStream you would just


 FS.Seek(0,sofromEnd);
 FS.Write(MyRec,SizeOf(MyRec));




 On Fri, Dec 19, 2008 at 7:49 AM, Andrew Brunner
 andrew.t.brun...@gmail.com wrote:
 procedure Append();
 var
  sBuffer:string;
  iLength:integer;
 begin

  sBuffer:='My Appended String'#13#10;
  iLength:=Length(sBuffer);

  FS:=TFileStream.Create(sFileName, fmshareDenyWrite);
  Try
FS.Seek(0,soFromEnd);
FS.WriteBuffer(sBuffer[1],iLength);
  Finally
FreeAndNil(FS):
  end;
 end;

 On Fri, Dec 19, 2008 at 7:10 AM, Dave Coventry dgcoven...@gmail.com wrote:
 Can one do this?

 I know that you can append test to the end of Text files, but can you
 tack on data to an existing file?
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


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

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


Re: [Lazarus] reading a little endian long.

2008-12-20 Thread Dave Coventry
Great, thanks Andrew.

2008/12/21 Andrew Haines andrewd...@aol.com:
 Dave Coventry wrote:
 If I Blockread(F,buffer,4) with buffer being an array of byte, Is
 there a routine in fpc/lazarus which will revers the bytes for me?

 This is what I want:
 longv:=buffer[0];
 longv+=buffer[1] shl 8;
 longv+=buffer[2] shl 16;
 longv+=buffer[3] shl 24;

 Is there a function which does this for me?
 ___

 Yes. See LEtoN, BEtoN, NtoLE and NtoBE.

 BlockRead(F, FooLongInt, 4);

 FooLongInt := LEtoN(FooLongInt);

 Regards,

 Andrew
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


[Lazarus] Appending to a binary file

2008-12-19 Thread Dave Coventry
Can one do this?

I know that you can append test to the end of Text files, but can you
tack on data to an existing file?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Appending to a binary file

2008-12-19 Thread Dave Coventry
The file is type 'File'

var MF: File;
  bffer: array [0..127] of Byte;
begin
  AssignFile(MF,fname);
  FileMode:=fmOpenWrite;
  Reset(MF,1);
  Blockwrite(MF,bffer,128);
  CloseFile(MF);
end;

Do you reckon that would do it?

2008/12/19 Reenen Laurie rlau...@gmail.com:
 Yes...

 Seek the end of the file, and then write to the file...

 I think it's FileSeek these days.

 (that's if you binary file is a file of TMyRecord)


 On Fri, Dec 19, 2008 at 3:10 PM, Dave Coventry dgcoven...@gmail.com wrote:

 Can one do this?

 I know that you can append test to the end of Text files, but can you
 tack on data to an existing file?
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus



 --
 o__
 ,_./ _
 (_)_\(_)___
 ...speed is good
 ___
 I believe five out of four people have a problem with fractions.

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


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


[Lazarus] TDBRichEdit

2008-12-03 Thread Dave Coventry
Hi,

I'm looking at the demo sourcecode for TDBf, obviously written for Delphi.

It has a component called TDBRichEdit which, although it appears on
http://wiki.freepascal.org/Lazarus_Components but with only Turbo
Delphi checked.

Does Lazarus have a replacement component?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Finding out the Hostname of the Computer.

2008-11-28 Thread Dave Coventry
Thanks guys.

I knew there must be an easier way of doing it!
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Finding out the Hostname of the Computer.

2008-11-27 Thread Dave Coventry
Hi,

I'm trying to get the name of the computer my app is running on.

I've tried this:


function GetThisComputerName: string;
var
  c: array[0..127] of Char;
  computer: string;
  sz: dword;
  AProcess: TProcess;
  AStringList: TStringList;

begin
{$IFDEF Win32}
  sz := SizeOf(c);
  GetComputerName(c, sz);
  Result := c;
{$ELSE}
  AProcess := TProcess.Create(nil);
  AStringList := TStringList.Create;
  AProcess.CommandLine := 'echo $HOSTNAME';
  AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
  AProcess.Execute;
  AStringList.LoadFromStream(AProcess.Output);
  Result:=AStringList.Strings[0];
  AStringList.Free;
  AProcess.Free;
{$ENDIF}

end;

I'm not sure if it works under Windows, but running Ubuntu, it returns
'$HOSTNAME'.

Can anyone see what I'm doing wrong, or offer an alternative way of
getting the name of the computer?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Fwd: jitform.pas won't compile

2008-11-21 Thread Dave Coventry
This is what I did:

I ran 'svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc'
which downloaded the fpc files into /opt/fpc

I changed directory to /opt/fpc and ran 'make all', which seemed to
compile okay. Then I ran 'make install' which I expected to overwrite
the fpc-2.2.2 version as the default implementation.

However, that version still appears to be invoked when I try to compile Lazarus.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] jitform.pas won't compile

2008-11-21 Thread Dave Coventry
Vincent,

I've changed
/usr/bin/ppcx64- to point to- /opt/fpc/compiler/ppcx64
but this didn't work.

However, using PP=/opt/fpc/compiler/ppcx64 did work.

How is this going to affect my own applications? When I compile my own
apps, which compiler will they be compiled under? and does it matter?


2008/11/21 Vincent Snijders [EMAIL PROTECTED]:
 Dave Coventry schreef:

 This is what I did:

 I ran 'svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc'
 which downloaded the fpc files into /opt/fpc

 I changed directory to /opt/fpc and ran 'make all', which seemed to
 compile okay. Then I ran 'make install' which I expected to overwrite
 the fpc-2.2.2 version as the default implementation.

 However, that version still appears to be invoked when I try to compile
 Lazarus.

 make sure the symlink from fpc in /usr/bin points to the correct ppcXXX
 compiler

 Or
 Do make PP=/path/to/installed/ppcXXX
 for i386:
 make PP=/usr/lib/fpc/2.2.2/ppc386

 For more details, read the buildfaq (google for buildfaq.pdf)

 HTH,
 Vincent

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


[Lazarus] jitform.pas won't compile

2008-11-20 Thread Dave Coventry
Hi,

I've downloaded the latest SVN Checked out revision 17479.

But when I compile I get the following errors:

Target OS: Linux for x86-64
Compiling jitform.pas
jitform.pas(100,38) Error: identifier idents no member SetDesignInstance
jitform.pas(100,55) Error: Illegal expression
jitform.pas(100,55) Fatal: Syntax error, ; expected but ( found
Fatal: Compilation aborted
make[2]: *** [jitform.ppu] Error 1
make[2]: Leaving directory `/usr/lib/lazarus/designer/jitform'
make[1]: *** [jitform_all] Error 2
make[1]: Leaving directory `/usr/lib/lazarus/designer'
make: *** [designer] Error 2

Can anyone advise?

I'm using fpc 2.2.0 on an AMD64 Box with Ubuntu 8.10.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] pmNop and pmNot no longer working

2008-11-14 Thread Dave Coventry
Hi, my application has a requirement to draw in pmNot penmode (the
Inverse of canvas background colour).

Unfortunately, since upgrading Lazarus, I get the error:

Identifier not found pmNop (which is the constant for resetting the
Pen to normal (unchanged).

Obviously I need the integer value of pmNop

Cab anyone help?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Units missing

2008-10-31 Thread Dave Coventry
Hi,

I upgraded last night to the
Lazarus-0.9.27-17155-fpc-2.2.2-20081030-win32.exe nightly build.

My application won't compile with the following error:

C:\Programs\lazarus\components\printers\printersdlgs.pp(27,22) Fatal:
Can't find unit Dialogs used by PrintersDlgs

When I try to configure packages and rebuild the IDE, it stops with
the followng error:

C:\Programs\lazarus\components\tachart\taseries.pas(37,8) Fatal: Can't
find unit Graphics used by TASeries

So, obviously the units are not where the IDE expects them to be.

I have 3 'graphics.pas' files:

c:\Programs\lazarus\fpc\2.2.1\source\rtl\morphos\graphics.pas
c:\Programs\lazarus\fpc\2.2.2\source\rtl\morphos\graphics.pas
c:\Programs\lazarus\fpc\2.2.3\source\rtl\morphos\graphics.pas

Ialso have multiple instances of dialogs.pas
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Units missing

2008-10-31 Thread Dave Coventry
Hi Mathias,

I 'cd'ed to c:\Programs\lazarus and ran fpc\2.2.3\bin\i386-win32\make.exe

Which solved the problem.

With regards to the 'graphics.pas' files, I was drawing attention to
the fact that I have multiple instances of fpc (2.2.1, 2.2.2, 2.2.3),
which might have been confusing the compiler.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Multiple onSelection events

2008-10-31 Thread Dave Coventry
Hi,

I'm getting multiple 'onSelection' events from one mouseclick on a
TSgringGrid entity.

Can anyone suggest a cure for tis?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Initializing my App

2008-10-28 Thread Dave Coventry
Hi,

How can I tell when my application has loaded and I can start
initializing some of the form elements?

At the moment I place all of the initialization routines in the
FormCreate but quite often I get an 'external SIGSEHV' exception as
the mouse generates a false onSelection event on a StringGrid,
presumably because the StringGrid has yet to be fully loaded.

This is on Windows XP using 0.9.25 beta 15981 (I will upgrade when I
finish this current project).

Many thanks,

Dave Coventry
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Initializing my App

2008-10-28 Thread Dave Coventry
Hi Graeme,

How does the 'Loaded' thing work?



2008/10/28 Graeme Geldenhuys [EMAIL PROTECTED]:
 On Tue, Oct 28, 2008 at 1:59 PM, Dave Coventry [EMAIL PROTECTED] wrote:
 At the moment I place all of the initialization routines in the
 FormCreate but quite often I get an 'external SIGSEHV' exception as
 the mouse generates a false onSelection event on a StringGrid,
 presumably because the StringGrid has yet to be fully loaded.

 TComponent has a Loaded() method you could try and use.

 Alternative to FormCreate - maybe use a overridden AfterConstruction() method.

  procedure AfterConstruction; override;


 Regards,
  - Graeme -


 ___
 fpGUI - a cross-platform Free Pascal GUI toolkit
 http://opensoft.homeip.net/fpgui/
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] Initializing my App

2008-10-28 Thread Dave Coventry
Thanks Valdas, that's basically what I wanted to know. The event which
will only be triggered once the Form is completely loaded.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] No Native FPC Found...

2008-09-22 Thread Dave Coventry
Hi,

I'm trying to install Lazarus/FPC on a laptop that I've put Slax onto.

I've downloaded
'ftp://ftp.freepascal.org/pub/fpc/dist/i386-linux-2.2.2/fpc-2.2.2.i386-linux.tar'
(all 30 Meg) untarred it and run the 'install.sh' script.

I get the following error:

#No native FPC found.
#For a proper installation of a cross FPC the installation of a native
FPC is required.

Typing 'arch' returns 'i686'.

I've googled extensively to find the solution, and have turned up a
2007 thread in which Graeme Geldenhuis had a similar problem, but the
thread ended without a satisfactory conclusion...
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] No Native FPC Found...

2008-09-22 Thread Dave Coventry
Oops.

Please disregard the previous post.

I was trying to start the script by using the path to the script.

When I cd to the script's directory and run 'sh install.sh', it works
as expected...

Sorry.

2008/9/22 Dave Coventry [EMAIL PROTECTED]:
 Hi,

 I'm trying to install Lazarus/FPC on a laptop that I've put Slax onto.

 I've downloaded
 'ftp://ftp.freepascal.org/pub/fpc/dist/i386-linux-2.2.2/fpc-2.2.2.i386-linux.tar'
 (all 30 Meg) untarred it and run the 'install.sh' script.

 I get the following error:

 #No native FPC found.
 #For a proper installation of a cross FPC the installation of a native
 FPC is required.

 Typing 'arch' returns 'i686'.

 I've googled extensively to find the solution, and have turned up a
 2007 thread in which Graeme Geldenhuis had a similar problem, but the
 thread ended without a satisfactory conclusion...

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


Re: [Lazarus] In the name of science

2008-08-26 Thread Dave Coventry
Yes, but the 'Bush hid the facts' one is just plain weird.

Not sure why Graeme thinks we all have MS Word, though...

2008/8/26 Florian Klaempfl [EMAIL PROTECTED]:
 Graeme Geldenhuys schrieb:
 Off-topic but very cool... actually weird!  :-)


 TRICK #1
 An Indian discovered that nobody can create a FOLDER
 anywhere on the computer which can be named as 'CON'.
 This is something pretty cool...and unbelievable. ..
 At Microsoft the whole Team, couldn't answer why this
 happened!

 This is probably an urban legend that nobody can answer this: CON is a
 reserved device name (console, try echo asdf  CON) like e.g. COM1. You
 can't create a folder called COM1 either if you're system has COM1.
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


[Lazarus] Using TFPHashTable

2008-08-25 Thread Dave Coventry
Hi,

I've been googling for a way to return the index of a particular
string in an array and have come across an old thread on this List
referring to TFPHashTable, which sounds like what I need.

However, I've been unable to find out how to use it.

If I have an array defined at compile time:

directions:array[0..299] of
string('JUMP','BACK','FOREWARD','UP','DOWNN',LEFT'','RIGHT',etc..ect);

I need to convert this to the string's index, so that position('UP')
would return 3.

TFPHashTable looks as though it would suit my application.

How do I populate the fields? Can it be done in the same way as the
array fields are populated as above?

Many thanks,

Dave Coventry
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Strange behaviour sending data to a serial port.

2008-07-31 Thread Dave Coventry
Hi,

I have approached the Synapse mailing list with this problem, but have
had no response, so it may be a Lazarus issue.

In any case, maybe someone can suggest a work-around

I have used the following code to send data to a serial printer using
the TBlockSerial synapse variable.

var ser:TBlockSerial;

  ser:=TBlockserial.Create;
  try
ser.RaiseExcept:=True;
ser.Connect('COM1');
ser.Config(9600,8,'N',0,false,false);
ser.SendString('Invoice: The Galley Restaurant'+#13+#10);
  finally
ser.Free;
  end;

If I run the above code, there is no response from the printer.

However, if I put a breakpoint into the code and step through it, the
printer prints as expected.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Strange behaviour sending data to a serial port.

2008-07-31 Thread Dave Coventry
Hi Roberto, thanks for the assistance...

2008/7/31 Roberto Padovani [EMAIL PROTECTED]:
 Hi,
 this might be irrelevant and I never used the Synapse routines, but I'll try:
 are you stepping also into the actual transmitting routine, character
 by character ?

Placing the breakpoint anywhere prior to the 'end;' of the
'try...finally...end;' block allows the printer to print as expected.

Obviously, the executable can't print.

 I am asking this because it is quite strange to see a device thar
 requires _no_ stop bit, like you configured it:

ser.Config(9600,8,'N',0,false,false);

I took the example in the package and tweaked it slightly for my
usage; I' not really sure what parameters I need to pass to the
printer, but 9600 for the baud, seemed reasonable, I suppose I could
use 7 bits because I am sending ASCII strings, N for the parity
because I can't see that parity is required, and the others seemed
okay.

 and by stepping, you might be stopping after each character, so that
 the device state machine can decode the character.
 All the devices I have ever seen in the last decade, either PC devices
 or not, they _need_ exactly 1 stop bit, so an easy shot could be to
 change it to:

ser.Config(9600,8,'N',1,false,false);

 Let me know if it works!

I'm afraid that it makes no difference...
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Strange behaviour sending data to a serial port.

2008-07-31 Thread Dave Coventry
Thanks Felipe.

2008/7/31 Felipe Monteiro de Carvalho [EMAIL PROTECTED]:
 The only thing I know is that the code here worked for me:

 http://wiki.lazarus.freepascal.org/Hardware_Access#Serial_Communication

That looks interesting; I'll try some experiments.

 Maybe the printer needs some time to rest somewhere. Put some Sleep's
:P

Actually, I put in a showmessage('Printing Complete!'); which did
the trick. So it's clearly not a Lazarus issue...
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Strange behaviour sending data to a serial port.

2008-07-31 Thread Dave Coventry
Thanks Felipe.

2008/7/31 Felipe Monteiro de Carvalho [EMAIL PROTECTED]:
 The only thing I know is that the code here worked for me:

 http://wiki.lazarus.freepascal.org/Hardware_Access#Serial_Communication

That looks interesting; I'll try some experiments.

 Maybe the printer needs some time to rest somewhere. Put some Sleep's
:P

Actually, I put in a showmessage('Printing Complete!'); which did
the trick. So it's clearly not a Lazarus issue...
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] TStringGrid, One click, multiple events.

2008-07-27 Thread Dave Coventry
Hi,

I'm sure this has been covered often, but none of my searches seems to find it.

I have a routine to remove a row from a TStringGrid if the user selects it.

The problem is that the onSelection event seems to be trigered twice:


procedure TForm1.StringGrid1Selection(Sender: TObject; aCol, aRow: Integer);
var i:integer;
begin
  if messageDlg('Remove
'+StringGrid1.Cells[aCol,aRow]+'?',mtInformation,[mbYes,mbNo],0)=mrYes
then
  begin
for i:=arow to StringGrid1.RowCount-2 do
begin
  StringGrid1.Cells[0,i]:=StringGrid1.Cells[0,i+1];
  StringGrid1.Cells[1,i]:=StringGrid1.Cells[1,i+1];
end;
StringGrid1.RowCount:=StringGrid1.RowCount-1;
  end;
end;

The user will click the item to be removed, the dialog will appear
asking for confirmation to delete the row, but on clicking yes, while
the row is deleted as expected, the dialog pops up again, asking the
user if the next line should be deleted.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Colouring StringGrids

2008-07-15 Thread Dave Coventry
Hi,

I'm using the following code to (unsuccessfully) colour the fields of
a row in a tstringgrid if the second column is empty.

  if StringGrid2.Cells[1,i]='' then
  begin
PriceHeader:=true;
StringGrid2.Repaint;
  end;


procedure TForm1.StringGrid2DrawCell(Sender: TObject; aCol, aRow: Integer;
  aRect: TRect; aState: TGridDrawState);
var oldColour:TColor;
  oldBrush: TBrush;
begin
  with StringGrid2 do
  begin
if PriceHeader then
begin
  oldcolour:=font.Color;
  oldBrush:=Canvas.Brush;
  Brush.Color:=clNavy;
  font.Color:=clWhite;
  Canvas.FillRect(aRect);
  font.Color:=oldColour;
  Canvas.Brush:=oldBrush;
  PriceHeader:=false;
end;
  end;
end;

Can anyone give me a clue as to why it's not working?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Colouring StringGrids

2008-07-15 Thread Dave Coventry
Hi Graeme,

It's quite interesting when set the DefaultDrawing to false: the grid
isn't written at all.

Not quite what I'm after...

2008/7/15 Graeme Geldenhuys [EMAIL PROTECTED]:
 On Tue, Jul 15, 2008 at 1:15 PM, Dave Coventry [EMAIL PROTECTED] wrote:

 Can anyone give me a clue as to why it's not working?

 Have you tried setting DefaultDrawing = False?


 Regards,
  - Graeme -


 ___
 fpGUI - a cross-platform Free Pascal GUI toolkit
 http://opensoft.homeip.net/fpgui/
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


[Lazarus] Printing a formatted page

2008-06-22 Thread Dave Coventry
Is there any way of setting up a page in RTF, say, and reformatting so
that it can be drawn on TPrinter.Canvas?

Currently I'm measuring the positions of lines and text in millimetres
and scaling them up so that I can use Printer1.Canvas.Moveto(470,625)
and Printer1.Canvas.LineTo(880,625).
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Printing a formatted page

2008-06-22 Thread Dave Coventry
On Sun, Jun 22, 2008 at 7:24 PM, Felipe Monteiro de Carvalho
 What do you need? Just the size of the paper?
The whole lot.
I want to write a letter to someone who's name is in a database.
So It's got to say:
Dear $Title $Firstname $Surname, Re yours of the inst. $Date etc, ect.
(I'm just using Perl variables to show the structure of the letter -
obviously in Pascal you don't preface variables with $)

Also to print out Invioces and Reciepts.

It's actually for Student registration, letters of acceptance, Courses
taken, price of each course, etc...

 If you are using normal paper, you can let LCL calculate the size by 
 simply giving the paper name to it:
Mostly just A4 pages.


 You will have a lot of difficulty to communicate with OpenOffice.
Yes, I realise that. I've had a look at the format of OpenOffice
documents and I think it would not be trivial to convert such a
document into a format that I could use to print a page with
TPrinter.Canvas. That's why I was thinking of Postscript and PCL.

 What is PCL?
PCL = Printer Control Language (IIRC)
It used to be the language to control old style plottters (with up to
eight pens!), and I think it was an IBM standard.

 I am building a CNC Machine, and I also need to read data from
 an external software. I analised Postscript and I arrived to the
 conclusion that it is too complex to build a Postscript interpreter
 (Postscript is a full programming language!).
Yeah, I know! I did a lot of work in Postscript some years ago, but I
don't remember enough about it to confidently try and convert a PS
file. The problem is that it uses a lot of recursion and popping and
pushing functions onto a stack so that it becomes quite complicated to
read.

However, a lot of people have done a lot of stuff with PS, so I was
hoping there was something out there I could use...

 We have decided now to build a PDF reading library for Free
 Pascal. We should start working on it in a few months.
Good luck!
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] What happened to TSQLQuery?

2008-06-20 Thread Dave Coventry
Hi,

I've developed my app on windows and needed to port it to Linux.

However, the 0.9.24  installation (Installed with the ubuntu apt-get
package tool) does not appear to have TSQLQuery or TPQConnection. Nor
does it have TPrintDialog.

How can I remedy this?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] What happened to TSQLQuery?

2008-06-20 Thread Dave Coventry
Where do I find these packages?

On Fri, Jun 20, 2008 at 4:03 PM, Felipe Monteiro de Carvalho
[EMAIL PROTECTED] wrote:
 On Fri, Jun 20, 2008 at 8:53 AM, Dave Coventry [EMAIL PROTECTED] wrote:
 However, the 0.9.24  installation (Installed with the ubuntu apt-get
 package tool) does not appear to have TSQLQuery or TPQConnection. Nor
 does it have TPrintDialog.

 You need to install Printers4Lazarus package from components/printers
 to have printing support.

 --
 Felipe Monteiro de Carvalho
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

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


Re: [Lazarus] Postgres Dlls not found

2008-06-08 Thread Dave Coventry
Telnet?

On Sat, Jun 7, 2008 at 6:14 PM, Marc Weustink [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:

 [snip]

 Without wanting to sound churlish, I am a bit of a loss to understand
 why the PQconnection needs to use the libpq.dll in the first place.
 I'm sure a lot of the Queries could be handled by communicating
 directly with the psql command line through ssh.

 Besides other disadvantages a windows machine hasn't ssh either, so
 those exe/dlls need to be installed too. So you still need some
 installation.

 Marc

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

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


Re: [Lazarus] Postgres Dlls not found

2008-05-31 Thread Dave Coventry
Yes, DLL hell it is.

That's why I was dismayed to see that PQconnection used the DLL (and
not just one, it uses several).

But I suppose if there's a good reason for it
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inactive Dataset

2008-05-29 Thread Dave Coventry
Ah.

I was uable to compile the fpc db libs but I managed to get access to
a broadband connection and downloaded the daily snapshot.

Now I can't load my app into Lazarus:



2008/5/28 Jalal [EMAIL PROTECTED]:
 123555

 Dave Coventry,

 As does explicitly using SQLQuery.Close prior to opening the Query. :(

 I suggest you use SQLQuery.Active := True (or False) instead of Open and
 Close.


 Alternatively, is there another way of extracting the information?

 If you don't need the db-aware visual controls you can use the libpq
 functions directly, they aren't hard to use. Some are:

 PQconnectdb
 PQstatus
 PQexec
 PQnfields
 PQntuples
 PQfname
 PQgetvalue
 PQclear
 PQfinish

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


attachment: error1.pngattachment: error2.png___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Postgres Dlls not found

2008-05-29 Thread Dave Coventry
Maybe I'm missing a DLL. Here are the DLLs that came with pgadmin3.

comerr32.dll
gssapi32.dll
iconv.dll
k5sprt32.dll
krb5_32.dll
libeay32.dll
libiconv2.dll
libintl3.dll
libpq.dll
libxml2.dll
libxslt.dll
msvcm80.dll
msvcp80.dll
msvcr71.dll
msvcr80.dll
pgaevent.dll
ssleay32.dll
zlib1.dll
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inactive Dataset

2008-05-28 Thread Dave Coventry
On Wed, May 28, 2008 at 10:45 AM, Graeme Geldenhuys
[EMAIL PROTECTED] wrote:
 You forgot the line:
   SQLQuery1.Next;

So I did!

However, putting it back in still gives me the same error.

As does explicitly using SQLQuery.Close prior to opening the Query. :(
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SQLQuery1: Field not Found: enquiryreferencenumber

2008-05-28 Thread Dave Coventry
Hi Joost,

On Wed, May 28, 2008 at 10:46 AM, Joost van der Sluis [EMAIL PROTECTED] wrote:
 And which version of fpc are you using? It could be a releaf if you use
 a recent 2.2.1 snapshot.
I'm using fpc 2.2.0.

Do you think that might be the cause?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inactive Dataset

2008-05-28 Thread Dave Coventry
Alternatively, is there another way of extracting the information?

On Wed, May 28, 2008 at 3:25 PM, Dave Coventry [EMAIL PROTECTED] wrote:
 Joost, Michael,

 Will it take long to fix? (are we talking a quick patch, or three weeks work?)

 I was supposed to demonstrate my app yesterday and had managed to get
 a bit of a dispensation because I was so close.

 However, I think they will probably drop my project if I can't
 demonstrate it today

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


Re: [Lazarus] Inactive Dataset

2008-05-28 Thread Dave Coventry
On Wed, May 28, 2008 at 3:37 PM, Graeme Geldenhuys
[EMAIL PROTECTED] wrote:
 If you go

   Query.Last;  // --- New line
   Query.First;

 Does it give an error on the call to Last?

Yes.

The error is on last.

Michael, It would be very kind of you if you could email them to me as
you offered.

I am, indeed on dialup, but the owner of the line has been very
understanding and, if push came to shove, I could download fpc.

Many thanks!

Dave
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inactive Dataset

2008-05-28 Thread Dave Coventry
Joost, Michael,

Will it take long to fix? (are we talking a quick patch, or three weeks work?)

I was supposed to demonstrate my app yesterday and had managed to get
a bit of a dispensation because I was so close.

However, I think they will probably drop my project if I can't
demonstrate it today
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inactive Dataset

2008-05-28 Thread Dave Coventry
Marc,

Thanks very much for looking at the code. My fault, the above example
is a cut and paste from the original code and my cutting knife must
have slipped!

In any case, the SQLQuery1.SQL.Text is not overwirrten in my code. :)



On Wed, May 28, 2008 at 4:21 PM, Marc Santhoff [EMAIL PROTECTED] wrote:
 Hi,

 I'm not really sure if this is a cp-error or the like, but ...

 Am Mittwoch, den 28.05.2008, 10:32 +0200 schrieb Dave Coventry:
 Sorry,

 I should have been more specific

 SQLQuery1.SQL.Text:='SELECT fname,
 sname,id,comboboxcourse,studentnumber,enquirydate,enquiryreferencenumber
 from registration WHERE fname=''Dave''';
   StringGrid1.RowCount:=2;
   SQLQuery1.SQL.Text:=sqlq;

 ... here you assign another string named sqlq and overwrite the nice SQL
 from above.

 Maybe that line is still in your code messing up the query?

 HTH,
 Marc

   SQLQuery1.Open;
   SQLQuery1.First;
   while not SQLQuery1.EOF do
   begin
 StringGrid1.Cells[0,i]:=SQLQuery1.FieldByName('fname').AsString;
 StringGrid1.Cells[1,i]:=SQLQuery1.FieldByName('sname').AsString;
 StringGrid1.Cells[2,i]:=SQLQuery1.FieldByName('id').AsString;
 StringGrid1.Cells[3,i]:=SQLQuery1.FieldByName('comboboxcourse').AsString;
 StringGrid1.Cells[4,i]:=SQLQuery1.FieldByName('studentnumber').AsString;
 StringGrid1.Cells[5,i]:=SQLQuery1.FieldByName('enquirydate').AsString;
 
 RecNumber:=RecNumber+','+SQLQuery1.FieldByName('enquiryreferencenumber').AsString;
 inc(i);
 StringGrid1.RowCount:=i+1;
   end;
   SQLQuery1.Close;

 On Wed, May 28, 2008 at 9:01 AM, Dave Coventry [EMAIL PROTECTED] wrote:
  Hi,
 
  I'm getting this: operation cannot be performed on an inactive dataset.
 
  Googling (I'm on a slow dialup on someone else's line) seems to
  indicate that the problem is with my Lazarus version.
 
  The version I'm using is 0.9.23 beta SVN rev 12712.
 
  I obviously can't download a new version of Lazarus...
 
  Can anyone advise me?
 
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


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

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


[Lazarus] SQLQuery1: Field not Found: enquiryreferencenumber

2008-05-27 Thread Dave Coventry
Hi.

Following Damien's instructions I have DROPped my original table and
created a new one in it's place:

CREATE table registration (
fname char(50),
sname char(50),
enquiryreferencenumber INT4 PRIMARY KEY DEFAULT nextval('reg_seq'))
WITHOUT OIDS;

I have run my INSERT Query under PQConnection1 using the following arguments:

  sqlq:='INSERT INTO registration (fname,sname) ';
  sqlq:=sqlq+'VALUES
('''+FName.Text+''','''+SName.Text+''')RETURNING
enquiryreferencenumber;';
  PQConnection1.Connected:=True;
  PQConnection1.ExecuteDirect('Begin Work;');
  PQConnection1.ExecuteDirect(sqlq);
  PQConnection1.ExecuteDirect('Commit Work;');
  PQConnection1.Connected:=False;

Then I have attempted to retrieve the enquiryreferencenumber using
SQLQuery1 as follows:
  SQLQuery1.SQL.Text:='SELECT enquiryreferencenumber FROM
registration WHERE fname='''+fname.Text+''' AND
sname='''+sname.Text+'''ORDER BY enquiryreferencenumber DESC LIMIT
1;';
  SQLQuery1.Open;
  
enquiryreferencenumber.Text:=SQLQuery1.FieldByName('enquiryreferencenumber').AsString;
  SQLQuery1.Close;

This gives me the following error:
 SQLQuery1: Field not Found: enquiryreferencenumber

Can anyone help?

Is it possible that the fact that the field 'enquiryreferencenumber'
is an integer and I'm accessing it AsString?

Running: SELECT enquiryreferencenumber from registration; in psql on
the linux machine give the following output:

 enquiryreferencenumber

 14
 15
 16
 17
 18

Any Ideas?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Connecting to a Postgres Database

2008-05-25 Thread Dave Coventry
Hi,

I'm using a windows machine (XP) running my app written with Lazarus
and trying to connect to a Postgres Server.

Whenever I turn the Connected field on my PQConnection component, I
get an error saying that it cannot find PostgreSQL client and
referencing libpq.dll.

Does anyone know what's happening?

Do I need a client to start the connection with the server?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Connecting to a Postgres Database

2008-05-25 Thread Dave Coventry
Hi.

I don't HAVE a windows postgres installation.

Do you have copies of the files? The best I could do was to was a
libpq.dll from v7.0.

Why are they needed, anyway? I don't see any mention of their
requirement in the wiki(s).

I'm not actually convinced that this is the problem; how do I test to
see if the Ubuntu server is allowing Postgres transactions?

Many thanks,

Dave Coventry


On Sun, May 25, 2008 at 5:28 PM, zeljko [EMAIL PROTECTED] wrote:
 On Sunday 25 May 2008 17:08, Dave Coventry wrote:
 Hi,

 I'm using a windows machine (XP) running my app written with Lazarus
 and trying to connect to a Postgres Server.

 Whenever I turn the Connected field on my PQConnection component, I
 get an error saying that it cannot find PostgreSQL client and
 referencing libpq.dll.

 Does anyone know what's happening?

 Do I need a client to start the connection with the server?

 find libpq.dll/libpq8X.dll somewhere and copy it to C:\Windows\System32
 (probably you can find libpq.dll in your windows postgres installation)

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

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


Re: [Lazarus] Connecting to a Postgres Database

2008-05-25 Thread Dave Coventry
On Sun, May 25, 2008 at 7:07 PM, Damien Gerard [EMAIL PROTECTED] wrote:
 However I have not use yet postgres with lazarus but I can make you an
 archive if needed

Hi Damien,

That would be great. I have googled quite a bit, but only come up with
the 7.0 version of libpq.dll

What would be the requirement be if I were to port my app to linux?
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Connecting to a Postgres Database

2008-05-25 Thread Dave Coventry
On Sun, May 25, 2008 at 6:49 PM, zeljko [EMAIL PROTECTED] wrote:
 postgres transactions ? I don't understand.
 If U can connect to XXX server usualy at port 5432 then it works, or it
 returns exception like : Is the server X running on port 5432 ? etc ...

 I see.

So, if I put http://192.168.1.20:5432 into my browser, then I should
see a message from postgreSQL? or an error message if it isn't
working?

TCP/IP isn't my long suit, I'm afraid.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Connecting to a Postgres Database

2008-05-25 Thread Dave Coventry
Thanks.

Certainly pgadmin has helped me to clear up the connection uncertainties.

I'll test it with my database later on today.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus