Re: [fpc-pascal] for .. in loop implementation

2009-01-08 Thread Jeremy Cowgar

Marco van de Voort wrote:

In our previous episode, leledumbo said:

  

The latter one has iteration overheads, while the former can be optimized to
loop as many as needed. I'm not saying I'm the best Pascal programmer, but
in case there's a (better) solution to this (rather than extending the
language) please tell me.



Your assesment is correct as far as I can see. 


However IMHO that doesn't meant you are right. One single case of an
optimalization advantage, and then in a border case like iteration over a
constant set does not justify a language extension.
  


What is the negative of adding it? To me, I program in a language 
because it makes my life easy, not because each keyword has a 
certain/clear purpose and cannot be done any other method. The easier FP 
is for me to program in (or the less typing I have to do), the better FP 
is to me. I'm confused on why not to add it.


Jeremy

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


Re: [fpc-pascal] property of an array

2009-01-04 Thread Jeremy Cowgar

dmitry boyarintsev wrote:

1)
type
   StringArray : array of String;

defines a StringArray type to be dynamic array.
are you sure, that you have SetColumnNames defined as
procedure SetColumnNames(names : StringArray);
rather than:
procedure SetColumnNames(names : array of string);
???
  
Hm, you are right. When I was able to do SetColumnNames([...]); was 
before I changed to a defined type, trying to get around this problem.


Jeremy

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


[fpc-pascal] property of an array

2009-01-03 Thread Jeremy Cowgar

I am trying to make this work:

type
StringArray : array of String;

... later in code ...

procedure SetColumnNames(names : StringArray);
property ColumnNames : StringArray write SetColumnNames;

... later in code ...

procedure TMyObject.SetColumnNames(names : StringArray);
begin
... code to set column names ...
end;

... later in code ...

myObj.ColumnNames := [ 'Id', 'Name', 'Age' ];

I get an error on the above line:

Error: Ordinal expression expected

Any thoughts? Thanks!

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


[fpc-pascal] Message Boards or Mailing List?

2009-01-03 Thread Jeremy Cowgar
I am curious what is the best way to get help with Free Pascal? Seems  
there are two competing methods, the mailing list and then the message  
boards (http://community.freepascal.org:1/bboards/) ... Just wondering  
if there is a preferred method, if one is legacy the other a replacement  
or something.


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


[fpc-pascal] XPath Problem?

2006-10-02 Thread Jeremy Cowgar

Hello, I am trying to use the xpath unit... I am getting an

An unhandled exception occurred at $000E4268 :
EAccessViolation : Access violation
  $000E4268

Via gdb, I can see the place it's happening is xpath.pp:2470. Here is  
my simple test program:


program xpathtest;

uses dom, xpath;

var
  doc : TXMLDocument;
  root : TDOMElement;
  TP : TXPathVariable;

begin
  doc := TXMLDocument.Create;
  root := doc.CreateElement('abc');
  root.SetAttribute('id', '10');
  doc.AppendChild(root);

  TP := EvaluateXPathExpression('/abc/@id', doc);

  WriteLn(TP.AsText);

  doc.Destroy;
end.

--

Can anyone offer advise on how to make this work?

Thank you,

Jeremy

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


Re: [fpc-pascal] TDatabase, PostgreSQL and Mac OS X?

2006-09-27 Thread Jeremy Cowgar
Leonardo, Wow. That worked. I did a symlink from libpq.dylib to  
libpq.so and it works now.


Is there a proper way to do this on mac os x anyone?

Thanks Lenardo!

Jeremy

On Sep 27, 2006, at 7:55 AM, Leonardo M. Ramé wrote:

I don't know too much about OS X, but can't you simply rename  
libpq.dylib to libpq.so?


--- Jeremy Cowgar [EMAIL PROTECTED] wrote:


I have the following simple program that does not seem to be working.
Connectivity using postgres unit works fine. Here's the error and
then the program will follow. Thank you! Oh, a note. I do not have
libpq.so. I do have libpq.dylib. Also, my postgresql is installed in
a non-standard place, /usr/local/pgsql however other programs have
not had a problem with that thus far. I created symlinks to /usr/
local/pgsql/libpq* into /usr/lib but that did not solve the problem.

Jeremy


$ ./dbtest Connecting to database...
An unhandled exception occurred at $0007864C :
EInOutError : Can not load PosgreSQL client. Is it installed?  
(libpq.so)

   $0007864C
   $00054F87



program dbtest;

uses sqldb, pqconnection;

var
Fconnection  : tSQLConnection;

begin
writeln('Connecting to database...');

Fconnection := tpqConnection.Create(nil);
with Fconnection do
begin
DatabaseName := 'test';
open;
end;

writeln('Connected...');

Fconnection.Free;
end.

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




Leonardo M. Ramé
http://leonardorame.blogspot.com

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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


[fpc-pascal] TStringList Bug?

2006-09-26 Thread Jeremy Cowgar
Below is a simple program that I *think* is working wrong. I am new  
to Pascal, so I may very well be doing something wrong.


Can anyone comment?

Jeremy



program stringlistbug;

uses Classes;

var
SL : TStringList;
begin
SL := TStringList.Create;
SL.Delimiter := '|';
SL.DelimitedText := 'Hello World|How are you doing?';

writeln('One =', SL[0], '');
writeln('Two =', SL[1], '');
end.

(*
Output:
$ ./stringlistbug
One =Hello
Two =World

Shouldn't it be:
$ ./stringlistbug
One = Hello World
Two = How are you doing?
*)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TStringList Bug?

2006-09-26 Thread Jeremy Cowgar
I was hoping to use it to parse a pipe delimited file. This will not  
work as I do not want  chars as part of the result, I'd have to add  
it in, then subtract them out. That's kind of weird behavior that a  
delimiter would be forced (space) even when the delimiter field is set.


Thanks for the info though, I'll figure another way.

Jeremy

On Sep 26, 2006, at 11:27 AM, Michael Van Canneyt wrote:




On Tue, 26 Sep 2006, Jeremy Cowgar wrote:

Below is a simple program that I *think* is working wrong. I am  
new to Pascal,

so I may very well be doing something wrong.

Can anyone comment?


Space is always a delimiter.

You should use

SL.DelimitedText := 'Hello World|How are you doing?';

Michael.


Jeremy



program stringlistbug;

uses Classes;

var
SL : TStringList;
begin
SL := TStringList.Create;
SL.Delimiter := '|';
SL.DelimitedText := 'Hello World|How are you doing?';

writeln('One =', SL[0], '');
writeln('Two =', SL[1], '');
end.

(*
Output:
   $ ./stringlistbug
   One =Hello
   Two =World

Shouldn't it be:
   $ ./stringlistbug
   One = Hello World
   Two = How are you doing?
*)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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


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


[fpc-pascal] TDatabase, PostgreSQL and Mac OS X?

2006-09-26 Thread Jeremy Cowgar
I have the following simple program that does not seem to be working.  
Connectivity using postgres unit works fine. Here's the error and  
then the program will follow. Thank you! Oh, a note. I do not have  
libpq.so. I do have libpq.dylib. Also, my postgresql is installed in  
a non-standard place, /usr/local/pgsql however other programs have  
not had a problem with that thus far. I created symlinks to /usr/ 
local/pgsql/libpq* into /usr/lib but that did not solve the problem.


Jeremy


$ ./dbtest Connecting to database...
An unhandled exception occurred at $0007864C :
EInOutError : Can not load PosgreSQL client. Is it installed? (libpq.so)
  $0007864C
  $00054F87



program dbtest;

uses sqldb, pqconnection;

var
Fconnection  : tSQLConnection;

begin
writeln('Connecting to database...');

Fconnection := tpqConnection.Create(nil);
with Fconnection do
begin
DatabaseName := 'test';
open;
end;

writeln('Connected...');

Fconnection.Free;
end.

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


[fpc-pascal]TDatabase, TDataset, Mysql

2004-02-18 Thread Jeremy Cowgar
Greetings.

I am new to Pascal, and FPC. I am curious how I can learn more about
using TDatabase and TDataset in conjunction with MySQL, if that's even
possible. I have only seen references to these classes and am not
certian what they accomplish, or their interface, only that they are
used for database programming.

Thanks,

Jeremy



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]My object function is overriding real function

2004-02-18 Thread Jeremy Cowgar
Greetings.

I have a object that connects to a speech server, festival. In my
object, I define a function called close. This must close the socket
connection, which is done by the function close. Therefore, I am having
a problem, because simply calling close with the sin and sout parameters
results in an error because it is calling my objects close function
which takes no parameters.

How can I call a function that is not part of my object, but has the
same name as one of my object functions? Here is my simple code, for
example:

function TFestival.Open(host : string; port : integer) : integer;
var
h : THost;
addr : TInetSockAddr;
begin
h.NameLookup(host);
if h.LastError  0 then
  begin
Open := 1;
Exit;
  end;

addr.family := AF_INET;
addr.port   := ShortHostToNet(port);
addr.addr   := HostTonet(longint(h.IPAddress));

sock := Socket(AF_INET, SOCK_STREAM, 0);
if Not Connect(sock, addr, sin, sout) then
  begin
Open := 2;
Exit;
  end;

rewrite(sout);
reset(sin);

Open := 1;
end;

procedure TFestival.Close();
begin
close(sin);
close(sout);

Close := 0;
end;

I realize that I can simply rename my close procedure but I imagine that
I will run into similar situations as I continue to use Free Pascal.

Thank you for your help,

Jeremy



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal