[fpc-pascal] TCgiApplication in cgiapp unit - mostly deprecated

2009-11-27 Thread Graeme Geldenhuys
Hi,

Most of the methods in TCgiApplication (located in cgiapp unit) is
marked as deprecated. There is no documentation for this unit, so I do
not know much about it.

If all those methods are marked deprecated, what is replacing them?


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

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


Re: [fpc-pascal] TCgiApplication in cgiapp unit - mostly deprecated

2009-11-27 Thread Michael Van Canneyt



On Fri, 27 Nov 2009, Graeme Geldenhuys wrote:


Hi,

Most of the methods in TCgiApplication (located in cgiapp unit) is
marked as deprecated. There is no documentation for this unit, so I do
not know much about it.

If all those methods are marked deprecated, what is replacing them?


The whole cgiapp unit is deprecated, you should use the TCGIApplication 
from fpCGI. Lazarus has a package to create web applications with the fcl-web units.


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


Re: [fpc-pascal] make CPU_TARGET=arm OS_TARGET=linux ignores both flags

2009-11-27 Thread ik
That did not added the cross compile to the tar.

But  I was able to work with it anyway using package manager (still playing
with it, and when it will be ready I'll release it to AUR -> arch linux
community packages build).

I have another problem. I'm trying to create an Hello world for OpenMoko
(SHR unstable distro).
The file that FPC created for me is:
hello: ELF 32-bit LSB executable, ARM, version 1, statically linked, not
stripped

While SHR's programs signature is:
./e2fsck.e2fsprogs: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for
GNU/Linux 2.6.24, dynamically linked (uses shared libs), stripped

When I try to execute the hello binary it gives me the following error:
Illegal instruction

Debugging it with gdb gives the following:
Starting program: /var/volatile/tmp/hello

Program received signal SIGILL, Illegal instruction.
0x8638 in SYSTEM_SYSINITFPU ()
(gdb) bt
#0  0x8638 in SYSTEM_SYSINITFPU ()
#1  0x8654 in SYSTEM_FPC_CPUINIT ()
#2  0xaf18 in fpc_initializeunits ()
#3  0x807c in main () at /tmp/hello.pp:3

Is there a way to create FPC/program differently to make it work ? How I can
provide additional information about the problem if needed ?

Thanks,
Ido

http://ik.homelinux.org/


On Mon, Nov 23, 2009 at 4:44 PM, Jonas Maebe wrote:

>
> On 23 Nov 2009, at 15:37, ik wrote:
>
>  Is there a
>> way I can make a cross compiler zipinstall to install (at the end) as a
>> package in my linux ?
>>
>
> Try this:
>
> make OPT='dFPC_ARMEL -dFPC_ABI_EABI -Xd' OS=TARGET=linux CPU_TARGET=arm
> FPC=`pwd`/compiler/ppcrossarm zipdistinstall
>
>
>
> Jonas
> ___
> 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] private integer is an illegal counter variable

2009-11-27 Thread Juha Manninen
Hello,

If I define a private integer:

  TDemo = class(TCustomApplication)
  private
i: integer;
...

and in a protected method I use it:
  for i := 0 to List.Count - 1 do
...

then I get an error:
  Error: Illegal counter variable


Moving it to method's var section helps.
Method's var section is also better place for it in general, but still it 
should be legal to use a private member as counter var.

Bug or feature?


Regards,
Juha Manninen
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-27 Thread Jonas Maebe


On 27 Nov 2009, at 15:49, Juha Manninen wrote:


If I define a private integer:

 TDemo = class(TCustomApplication)
 private
   i: integer;
   ...

and in a protected method I use it:
 for i := 0 to List.Count - 1 do
   ...

then I get an error:
 Error: Illegal counter variable

Moving it to method's var section helps.
Method's var section is also better place for it in general, but  
still it

should be legal to use a private member as counter var.


The reason is that a for-loop tries to make a number of reasonable  
guarantees that the counter variable cannot be modified during the  
loop. E.g., direct assignments to a counter variable are forbidden  
inside the loop (except in TP-mode). If you use a private field, then  
any method of that class called in the body of the loop can easily  
(accidentally) change the value of the counter variable, completely  
messing up the loop.



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


[fpc-pascal] Pascal grammar for FPC.

2009-11-27 Thread Pascal

Hello.

In order to get translations from FPC to Ada language, I have updated  
P2Ada translator http://sourceforge.net/projects/p2ada.

I add a new ObjP2Ada branch.

The grammar is based on:
reference guide for Free Pascal (FPC), version 2.2.4, March 2009
programmer's guide Turbo Pascal (TP), version 7.0, 1992
/user manual Think Pascal (THP), version 4.0, 1990
Code Warrior Pascal (CWP) language reference manual, version 11, 1998
Delphi Object Pascal Language Guide, version 7, 2002

I made a specific version of grammar with only syntax elements http:// 
blady.pagesperso-orange.fr/telechargements/p2ada/fpc-nov09.y

This file is yacc compatible.

It would be a great help if someone can check it versus FPC.
In the other hand, it may helps FPC developers to have a grammar  
summary for documentation.


Thanks, Pascal.
http://blady.pagesperso-orange.fr





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


[fpc-pascal] Split and Join

2009-11-27 Thread Juha Manninen
Hi,

FPC's strutils or other libraries still don't have functions for splitting a 
string to a list and joining a list of strings again to one string, given a 
delimiter as a parameter.
Something like:
  function Spit(Str: string; Delim: string; Result: TStringList): integer;
and
  function Join(List: TStringList; Delim: string): string;

They don't exist in Delphi's libraries either. It is weird because every 
programmer at some point will need such functions.
Similar functions are created again and again by many people.
Such functions can be found from many utility libs around.

I found an archived fpc-pascal thread from over 2 years ago:
"splitting string into array"
The same issues came up there but the offered solutions were not optimized 
enough for FPC's magnificent library (!?!)
I think that is stupid! The basic functions for this job don't need to be 
highly optimized. The func signatures I gave above use TStringList which is 
good enough for most cases but not highly optimized. Also, a string as a 
delimiter is not optimized if your delimiter is actually 1 char.
Anyway, this kind of general case function is easy to implement.
Pos, Copy, Add...

Then there could be variations of it. For Split:
  function Spit(Str: string; Delim: char; Result: TStringList): integer;
  function Spit(Str: string; Delim: char; Result: array of string): integer;

The last one could really be optimized, minimizing the SetLength calls and so 
on.

But now, I am making a demo program and need a simple Split functions. It can 
take 10 ms of 50 ms for its job, nobody cares. I have to include my own 
utility function there, at the same time knowing that every other programmer 
has such utility functions because the libraries don't have them. Uhhh...


Regards,
Juha Manninen
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Split and Join

2009-11-27 Thread Juha Manninen
Hi,

I can actually use TStringList's Delimiter and DelimitedText for basic 
splitting. This separates words of a text:

  List.Delimiter := ' ';
  List.DelimitedText := S;

I have programmed with Delphi for years without knowing it. Now I found it 
with a google search. Should have waited a little before sending the mail...
Anyway, a more optimized version of Split and a Join are still missing from 
library.


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


Re: [fpc-pascal] Split and Join

2009-11-27 Thread Michael Van Canneyt



On Fri, 27 Nov 2009, Juha Manninen wrote:


Hi,

FPC's strutils or other libraries still don't have functions for splitting a
string to a list and joining a list of strings again to one string, given a
delimiter as a parameter.
Something like:
 function Spit(Str: string; Delim: string; Result: TStringList): integer;
and
 function Join(List: TStringList; Delim: string): string;


Of course it does exist. Split can be implemented like this:

List:=TStringList.Create;
List.Delimiter:=Delim;
List.StrictDelimiters:=True;
List.DelimitedText:=Str;

And that's it.

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


Re: [fpc-pascal] Split and Join

2009-11-27 Thread Mattias Gaertner
On Fri, 27 Nov 2009 20:11:25 +0100 (CET)
Michael Van Canneyt  wrote:

> 
> 
> On Fri, 27 Nov 2009, Juha Manninen wrote:
> 
> > Hi,
> >
> > FPC's strutils or other libraries still don't have functions for splitting a
> > string to a list and joining a list of strings again to one string, given a
> > delimiter as a parameter.
> > Something like:
> >  function Spit(Str: string; Delim: string; Result: TStringList): integer;
> > and
> >  function Join(List: TStringList; Delim: string): string;
> 
> Of course it does exist. Split can be implemented like this:
> 
> List:=TStringList.Create;
> List.Delimiter:=Delim;
> List.StrictDelimiters:=True;
> List.DelimitedText:=Str;
> 
> And that's it.

Many other languages can do that in one line with their RTL.

Maybe as a special constructor.

List:=TStringList.CreateFromSplit(SomeText,Delim);


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


Re: [fpc-pascal] Split and Join

2009-11-27 Thread Michael Van Canneyt



On Fri, 27 Nov 2009, Mattias Gaertner wrote:


On Fri, 27 Nov 2009 20:11:25 +0100 (CET)
Michael Van Canneyt  wrote:




On Fri, 27 Nov 2009, Juha Manninen wrote:


Hi,

FPC's strutils or other libraries still don't have functions for splitting a
string to a list and joining a list of strings again to one string, given a
delimiter as a parameter.
Something like:
 function Spit(Str: string; Delim: string; Result: TStringList): integer;
and
 function Join(List: TStringList; Delim: string): string;


Of course it does exist. Split can be implemented like this:

List:=TStringList.Create;
List.Delimiter:=Delim;
List.StrictDelimiters:=True;
List.DelimitedText:=Str;

And that's it.


Many other languages can do that in one line with their RTL.

Maybe as a special constructor.

List:=TStringList.CreateFromSplit(SomeText,Delim);


That looks like a good suggestion, I'll add it as TStringList.CreateSplit.

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


Re: [fpc-pascal] Split and Join

2009-11-27 Thread Luca Olivetti

En/na Michael Van Canneyt ha escrit:



Of course it does exist. Split can be implemented like this:

List:=TStringList.Create;
List.Delimiter:=Delim;
List.StrictDelimiters:=True;
List.DelimitedText:=Str;



Never though of it. And join can be done too.
Pity that delimiter is a single character.
e.g., in python I can do

>>> l=('one','two','three')
>>> ', '.join(l)
'one, two, three'
>>> ', '.join(l).split(', ')
['one', 'two', 'three']



it's handy nevertheless.

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


[fpc-pascal] Re: Troubles with CGI and POST content

2009-11-27 Thread Sven Barth

Hi again!

(So... let's see where this message ends up ^^)

I tested your patch (with both i386 and x86_64), Joost and as far as I 
can tell the problem is solved.


I'll check if I can spot the problem, too (I don't know when, though).

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


Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-27 Thread Frank Peelo

Jonas Maebe wrote:


On 27 Nov 2009, at 15:49, Juha Manninen wrote:


If I define a private integer:

 TDemo = class(TCustomApplication)
 private
   i: integer;
   ...

and in a protected method I use it:
 for i := 0 to List.Count - 1 do
   ...

then I get an error:
 Error: Illegal counter variable

Moving it to method's var section helps.
Method's var section is also better place for it in general, but still it
should be legal to use a private member as counter var.


The reason is that a for-loop tries to make a number of reasonable 
guarantees that the counter variable cannot be modified during the loop. 
E.g., direct assignments to a counter variable are forbidden inside the 
loop (except in TP-mode). If you use a private field, then any method of 
that class called in the body of the loop can easily (accidentally) 
change the value of the counter variable, completely messing up the loop.


In any case, why would one want a loop counter to have any more than the 
minimum possible scope? Why would one want it to be a class data member 
at all? Surely it would be far better/neater/more elegant, if it is used 
by methods, to pass it as a parameter?


FP

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


Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-27 Thread Juha Manninen
On perjantai, 27. marraskuuta 2009 23:52:30 Frank Peelo wrote:
> > The reason is that a for-loop tries to make a number of reasonable
> > guarantees that the counter variable cannot be modified during the loop.
> > E.g., direct assignments to a counter variable are forbidden inside the
> > loop (except in TP-mode). If you use a private field, then any method of
> > that class called in the body of the loop can easily (accidentally)
> > change the value of the counter variable, completely messing up the loop.
> 
> In any case, why would one want a loop counter to have any more than the
> minimum possible scope? Why would one want it to be a class data member
> at all? Surely it would be far better/neater/more elegant, if it is used
> by methods, to pass it as a parameter?

Right, it is better define it locally. I did this experiment by accident when 
copying code around.
This is actually a good deviation from Delphi's rules. No problem here.

There are some other deviations which look weird for me, like treating 
"string" as a dynamic ansistring sometimes but as an old shortstring 
sometimes. That is in the default {$mode objfpc}.
Fortunately there is {$mode delphi} which behaves more logically.
I understand it is important to support also the old shortstring but it should 
be defined explicitly and "string" should always mean just one thing.

Well, I guess this has been discussed before...
I can always use mode delphi.

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


Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-27 Thread Jonas Maebe

On 27 Nov 2009, at 23:43, Juha Manninen wrote:

> I understand it is important to support also the old shortstring but it 
> should 
> be defined explicitly and "string" should always mean just one thing.

ansistring and shortstring always mean just one thing. "string" originally 
meant shortstring in Turbo Pascal, and in Delphi it means shortstring with 
{$h-} and ansistring with {$h+} (and {$h+} is the default in Delphi and in 
FPC's Delphi mode).


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


Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-27 Thread Mattias Gaertner
On Sat, 28 Nov 2009 00:43:39 +0200
Juha Manninen  wrote:

> On perjantai, 27. marraskuuta 2009 23:52:30 Frank Peelo wrote:
> > > The reason is that a for-loop tries to make a number of reasonable
> > > guarantees that the counter variable cannot be modified during the loop.
> > > E.g., direct assignments to a counter variable are forbidden inside the
> > > loop (except in TP-mode). If you use a private field, then any method of
> > > that class called in the body of the loop can easily (accidentally)
> > > change the value of the counter variable, completely messing up the loop.
> > 
> > In any case, why would one want a loop counter to have any more than the
> > minimum possible scope? Why would one want it to be a class data member
> > at all? Surely it would be far better/neater/more elegant, if it is used
> > by methods, to pass it as a parameter?
> 
> Right, it is better define it locally. I did this experiment by accident when 
> copying code around.
> This is actually a good deviation from Delphi's rules. No problem here.
> 
> There are some other deviations which look weird for me, like treating 
> "string" as a dynamic ansistring sometimes but as an old shortstring 
> sometimes. That is in the default {$mode objfpc}.
> Fortunately there is {$mode delphi} which behaves more logically.
> I understand it is important to support also the old shortstring but it 
> should 
> be defined explicitly and "string" should always mean just one thing.
> 
> Well, I guess this has been discussed before...

Yes, a lot.
And there are many reasons why there are so many string types nowadays.
Simply use {mode objfpc}{$h+} like lazarus suggests.


> I can always use mode delphi.

Then you will loose some fpc features.


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


Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-27 Thread Juha Manninen
On lauantai, 28. marraskuuta 2009 00:49:25 Jonas Maebe wrote:
> On 27 Nov 2009, at 23:43, Juha Manninen wrote:
> > I understand it is important to support also the old shortstring but it
> > should be defined explicitly and "string" should always mean just one
> > thing.
> 
> ansistring and shortstring always mean just one thing. "string" originally
>  meant shortstring in Turbo Pascal, and in Delphi it means shortstring with
>  {$h-} and ansistring with {$h+} (and {$h+} is the default in Delphi and in
>  FPC's Delphi mode).

So {$h+} is the important part here. Ok, I partly misunderstood the settings.

From Mattias:
> Then you will loose some fpc features.

fpc mode requires more strict syntax with function pointers (event handler 
assignment). It doesn't sound like a big deal. What else? I must study this 
little more.

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