Re: [fpc-pascal] Timer in X11

2011-12-22 Thread michael . vancanneyt



On Thu, 22 Dec 2011, Graeme Geldenhuys wrote:


On 21 December 2011 18:06, Henry Vermaak wrote:

embedded devices, laptops have batteries, too.  You're wasting CPU and power
just spinning around a loop, so even if your app isn't active, it's still
waking up every 50ms.  I don't consider this very good programming practice.


I'm always interested in improvements. The 50ms code was done purely
to implement the Application.OnIdle() event. How else can I implement
an OnIdle event then?


I think it depends on what you mean with 'OnIdle'.
- An event which occurs once when an application falls Idle.
- An event which is triggered repeatedly when the application is idle.

As I understand it, Delphi and Lazarus implement the former, and 
don't need a timeout for it.


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

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Felipe Monteiro de Carvalho
On Thu, Dec 22, 2011 at 9:15 AM,   wrote:
> As I understand it, Delphi and Lazarus implement the former, and don't need
> a timeout for it.

Ops, you are correct, it is a one shot event:

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Forms_TApplication_OnIdle.html

I think I implemented it as a repetitive event. ops =D I guess I'll
need to fix this.

But you should not try to compare directly the LCL gtk2 or qt4
widgetsets with fpgui since gtk2 and qt4 do most of the real work.
Lazarus now has a X11 interface which can be used for direct
comparisons and it uses the timeout. In general I don't fully trust
select() to wakeup correctly yet. I guess that more testing would show
if it does, but I read in the web that X11 could use more then one
file descriptor for communication, so if I use a infinite select() the
application could hang in some corner cases.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 10:15,   wrote:
>
> I think it depends on what you mean with 'OnIdle'.
> - An event which occurs once when an application falls Idle.
> - An event which is triggered repeatedly when the application is idle.

fpGUI's OnIdle event used to fired only once, when the application
goes idle - but I found it much more useful to have an idle event that
fires repeatedly. Maybe I should make it configurable via the
fpgApplication instance, so the developer can decide how they want it
to work.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread michael . vancanneyt



On Thu, 22 Dec 2011, Felipe Monteiro de Carvalho wrote:


On Thu, Dec 22, 2011 at 9:15 AM,   wrote:

As I understand it, Delphi and Lazarus implement the former, and don't need
a timeout for it.


Ops, you are correct, it is a one shot event:

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Forms_TApplication_OnIdle.html

I think I implemented it as a repetitive event. ops =D I guess I'll
need to fix this.

But you should not try to compare directly the LCL gtk2 or qt4
widgetsets with fpgui since gtk2 and qt4 do most of the real work.
Lazarus now has a X11 interface which can be used for direct
comparisons and it uses the timeout. In general I don't fully trust
select() to wakeup correctly yet.


Strange statement.

If select() didn't do its job correctly, neither Qt or Gtk could do their
job, or any network related program, for that matter.

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


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 21 December 2011 16:53, Felipe Monteiro de Carvalho wrote:
> not alone here using FPC, so I shamelessly stole code from fpgui,

The joys of open-source software. :-)


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread michael . vancanneyt



On Thu, 22 Dec 2011, Graeme Geldenhuys wrote:


On 22 December 2011 10:15,   wrote:


I think it depends on what you mean with 'OnIdle'.
- An event which occurs once when an application falls Idle.
- An event which is triggered repeatedly when the application is idle.


fpGUI's OnIdle event used to fired only once, when the application
goes idle - but I found it much more useful to have an idle event that
fires repeatedly. Maybe I should make it configurable via the
fpgApplication instance, so the developer can decide how they want it
to work.


Well, the latter will consume CPU cycles, as indicated by others...
It all depends on what the programmer needs.

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


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Felipe Monteiro de Carvalho
On Thu, Dec 22, 2011 at 9:51 AM,   wrote:
> Strange statement.
>
> If select() didn't do its job correctly, neither Qt or Gtk could do their
> job, or any network related program, for that matter.

It is not about select working or not, it is about how many file
descriptors X uses to communicate:

http://fixunix.com/xwindows/91558-xconnectionnumber-select.html#post301681

I don't have time in the foreseeable future to find in which wierd
corner case XAddConnectionWatch is necessary and test that a
implementation which I come up with works, but Qt could pay someone to
stay all week testing wierd corner cases and find the most perfect
algoritm. For me, timeouting every second is already more then good
enough, it could even be each half second. Already at 50ms I could not
see my application with top in the top 20 CPU users (most of which
were using zero), so I seriously doubt the battery usage concerns
unless someone really measures it.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 21 December 2011 18:26, Felipe Monteiro de Carvalho <...> wrote:
>> just spinning around a loop, so even if your app isn't active, it's still
>> waking up every 50ms.  I don't consider this very good programming practice.
>
> I tested with top and it doesn't even show my application in the top
> 20 users of CPU.

I was just about to mention that, and would have been very surprised
if it did show CPU usage. I have always been careful with CPU usage in
fpGUI's event loop.


> It now adjusts the interval acoording to the installed timers, up to a
> maximum of 1 second.

Initially I thought that sounded like a good idea - but doesn't in now
do even more processing that without the GetSmallestTimerInterval()
function? Doing the timer loop, a math comparison for each timer etc.
But realistically it should still hardly register as a blip in the CPU
usage, so I guess it should be fine - especially if only one or so
timers are ever used in a application.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Henry Vermaak

On 22/12/11 09:15, Felipe Monteiro de Carvalho wrote:


It is not about select working or not, it is about how many file
descriptors X uses to communicate:

http://fixunix.com/xwindows/91558-xconnectionnumber-select.html#post301681

I don't have time in the foreseeable future to find in which wierd
corner case XAddConnectionWatch is necessary and test that a


I already mentioned this, but perhaps you didn't read it.  You don't 
need to test _any_ corner cases, that's the point of 
XAddConnectionWatch.  You get a callback that gives you a file 
descriptor which you can add/remove to the descriptors you check with 
select():


http://groups.google.com/group/comp.windows.x/browse_thread/thread/cd32588d173fffcf/4b750082b055422b?q=mity&rnum=5&hl=en#4b750082b055422b


algoritm. For me, timeouting every second is already more then good
enough, it could even be each half second. Already at 50ms I could not
see my application with top in the top 20 CPU users (most of which
were using zero), so I seriously doubt the battery usage concerns
unless someone really measures it.


Perhaps you should try powertop.

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


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread zeljko
On Thursday 22 of December 2011 09:43:28 Felipe Monteiro de Carvalho wrote:
> On Thu, Dec 22, 2011 at 9:15 AM,   wrote:
> > As I understand it, Delphi and Lazarus implement the former, and don't
> > need a timeout for it.
> 
> Ops, you are correct, it is a one shot event:
> 
> http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate
> 2/EN/html/delphivclwin32/Forms_TApplication_OnIdle.html
> 
> I think I implemented it as a repetitive event. ops =D I guess I'll
> need to fix this.
> 
> But you should not try to compare directly the LCL gtk2 or qt4
> widgetsets with fpgui since gtk2 and qt4 do most of the real work.
> Lazarus now has a X11 interface which can be used for direct
> comparisons and it uses the timeout. In general I don't fully trust
> select() to wakeup correctly yet. I guess that more testing would show
> if it does, but I read in the web that X11 could use more then one
> file descriptor for communication, so if I use a infinite select() the
> application could hang in some corner cases.

FYI, qt and gtk2 uses same source for timers and loops - glib2.
http://en.wikipedia.org/wiki/GLib
http://developer.gnome.org/glib/2.26/glib.html
I would try with it before reinventing wheel, because it works on all X11 
platforms (even on OS/2 and BeOS) and I'm pretty sure that it's installed by 
default.

zeljko


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

Re: [fpc-pascal] inline and other modifiers

2011-12-22 Thread Jonas Maebe


On 22 Dec 2011, at 02:27, nore...@z505.com wrote:

Another thing freepascal allows is for OVERLOAD to be declared one  
place

but not the other. Delphi is more strict in this regard.


That's fixed in svn trunk.


Also delphi is
more strict when it comes to PROGRAM name parsing. In freepascal the
program name can mismatch the file name, whereas delphi stops  
compiling

and tells you error.


As Waldo Kitty mentioned, that's incorrect. And both FPC and Delphi  
require that unit names match the file name (except in case the FPC  
parameter -Un is used, and FPC also allows partial matches based on  
the first 8 characters of the unit/file name to accomodate 8.3 file  
systems).



Another thing I
noticed is you can just use a begin and end for freepascal without  
PROGRAM

declaration at the top of the program.. again less strict than delphi.


Delphi also allows that. Even gpc allows it, although it prints a  
warning.



Jonas

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


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Jonas Maebe


On 22 Dec 2011, at 10:39, Graeme Geldenhuys wrote:


On 21 December 2011 18:26, Felipe Monteiro de Carvalho <...> wrote:

I tested with top and it doesn't even show my application in the top
20 users of CPU.


I was just about to mention that, and would have been very surprised
if it did show CPU usage. I have always been careful with CPU usage in
fpGUI's event loop.


Power usage is not only related to how much cpu power you use.  
Repeatedly waking up the cpu for minor processing also consumes more  
power than letting letting it stay in a low-power power saving mode.



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


Re: [fpc-pascal] using exceptions

2011-12-22 Thread Marcos Douglas
On Wed, Dec 21, 2011 at 10:29 PM,   wrote:
> Marcos wrote:
>> I use Exceptions to check the integrity of classes. I have one
>> Exception for each class (E), most of the time.
>
>
> Another problem with errors is that sometimes it is hard for a class to
> return errors. In procedural programming you can usually return an error
> as a parameter but sometimes in class programming it is difficult for
> classes to just return errors.

It's not difficult, but is boring have always a parameter or function
return to return an error, and have to verify if error then... if not
error...  if error and error then... etc

> Exceptions are an attempt to solve the problem, but imo this still doesn't
> solve all problems and our applications are full of wild exceptions going
> off despite our attempts to solve the problem.. because people fail to
> check exceptions and catch them. usually I see code like this:
>
> Try
>
> Finally
>
>
> You don't see as much Try Except, it's more Try Finally. People ignore the
> exceptions because it's an accepted thing to do. Then the end user of the
> application gets a strange exception message instead of a user friendly
> one. For example, if a file is not found, I like to give a polite "Cannot
> find file" message.. but usually in delphi apps and examples all over the
> newsgroups you see just an EFileNotFound exception pop up instead. Or,
> with StrToInt, a similar obscure exception message to the end user instead
> of a more friendly one.

I use many try-except in my own code but, most of the time, just catch
my own exceptions because they are much more simpler to use. As I said
before, I have Exceptions in only 2 levels: user and Lib (API,
business rules, etc).
The User exceptions always show a user friendly message (I think that
you call Errors, right?). The Lib exceptions, for me, is the real
Exception. So, If I call a routine but the app is not connected on
DBMS... raise Exception; if a important property not been set... raise
Exception; if a file has not found, this is not a exception, but if
the app can not create a file... raise Exception.

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


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 11:50, Henry Vermaak  wrote:
>
> Perhaps you should try powertop.

Thanks for this. I never knew about powertop. I just ran it for a few
minutes. A fpGUI base app in idle rates 6th in the "top causes for
wakeups" on my system  - rated at 4% of total processes running. I
have no idea how that relates to actual power usage though. My USB
trackball (at 18%) and Firefox (at 16%) rated 2nd and 3th,
respectively. The kernel_scheduler got the number one spot with 20+%
share of all running processes.

I don't think fpGUI is doing too badly, but also not ideal. I'll see
if I can improve that code in fpGUI a bit.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Felipe Monteiro de Carvalho
On Thu, Dec 22, 2011 at 11:04 AM, zeljko  wrote:
> I would try with it before reinventing wheel, because it works on all X11
> platforms (even on OS/2 and BeOS) and I'm pretty sure that it's installed by
> default.

Interresting, but I don't think it will be necessary ... in rev 34359
I commited support for XAddConnectionWatch =D And I also don't like
very much gnome APIs, although it could be added as an alternative via
ifdefs if someone wants to go down this path.

But I could not fix OnIdle to adere to the Delphi specification
because that would affect assync call handling since there is only an
TApplication.Idle event which handles both. LCL-Gtk2 fires OnIdle like
a machine gun in a program with a timer, and I don't know if this is
correct or not, it would be good if someone with Delphi could test. If
it isn't correct or ideal then maybe we need a
TApplication.PartialIdle (called by Idle too to keep compatibility) to
handle things like AssynCall. I don't know where the hint update
belongs to, PartialIdle or Idle

The 1 second timeout needs to be kept anyway, because another thread
could queue an assync call, so we need to check that periodically.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread dhkblaszyk
  

The contributed unit section on the freepascal site does not work
anymore. Can someone please have a look and fix this? Is there an
alternative link available? 

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

Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread Jonas Maebe


On 22 Dec 2011, at 14:37, dhkblas...@zeelandnet.nl wrote:


The contributed unit section on the freepascal site does not work
anymore. Can someone please have a look and fix this? Is there an
alternative link available?


The location of the page changed, and there's an "alternative" link  
available on the front page of http://www.freepascal.org under  
"Contributed units".



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


Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 15:40, Jonas Maebe wrote:
>
> The location of the page changed, and there's an "alternative" link
> available on the front page of http://www.freepascal.org under "Contributed
> units".

While we are there. The "Toolbox" sponsor logo on the right. The
Toolbox Magazine has been sold long ago to a new publisher. The
"toolbox magazine" as we knew it, doesn't exist any more... they don't
publish Pascal/Delphi related articles any more. Is that logo still
needed on the free pascal website?


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread dhkblaszyk
  

On 22 dec '11, Jonas Maebe wrote: 

> On 22 Dec 2011, at 14:37,
dhkblas...@zeelandnet.nl [1]wrote:
> 
>> The contributed unit section on
the freepascal site does not work anymore. Can someone please have a
look and fix this? Is there an alternative link available?
> 
> The
location of the page changed, and there's an "alternative" link
available on the front page of http://www.freepascal.org [2] under
"Contributed units".

Well, that is exactly the link I'm talking about.
Clicking on this link will open an new page, the title is shown, but no
information. The browser shows an error occurred on the page. 

Webpage
error details 

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows
NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET
CLR 3.5.30729; .NET4.0C; .NET4.0E; .NET CLR 1.1.4322;
InfoPath.2)
Timestamp: Thu, 22 Dec 2011 13:52:30 UTC 

Message: Expected
identifier, string or number
Line: 365
Char: 7
Code: 0
URI:
http://www.freepascal.org/contrib/contribs.js [3] 

Message: 'fpWeb' is
undefined
Line: 23
Char: 5
Code: 0
URI:
http://www.freepascal.org/contrib/contribs.html [4] 

Regards, Darius 
 


Links:
--
[1] mailto:dhkblas...@zeelandnet.nl
[2]
http://www.freepascal.org
[3]
http://www.freepascal.org/contrib/contribs.js
[4]
http://www.freepascal.org/contrib/contribs.html
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 15:40, Jonas Maebe  wrote:
>
> The location of the page changed, and there's an "alternative" link
> available on the front page of http://www.freepascal.org under "Contributed
> units".

Something else. The new page looks nice, but you can't select text and
do copy-and-paste? Also I think somebody might need to go through that
info and see what doesn't exist any more. I just randomly picked one,
"File manager with sources in FPC". Can't copy and past any of the
description text. Also the link http://fc.freepascal.org/ doesn't
exist - I just get a "the connection has timed out" error in my
browser. There are many more like this.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread Marco van de Voort
In our previous episode, dhkblas...@zeelandnet.nl said:
> > 
> > The
> location of the page changed, and there's an "alternative" link
> available on the front page of http://www.freepascal.org [2] under
> "Contributed units".
> 
> Well, that is exactly the link I'm talking about.
> Clicking on this link will open an new page, the title is shown, but no
> information. The browser shows an error occurred on the page. 

It worked fine for me in Mozilla, but after I saw your user-agent, I tried
MSIE (9.0) and while I don't get any error messages, nothing shows.

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


Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said:
> > The location of the page changed, and there's an "alternative" link
> > available on the front page of http://www.freepascal.org under "Contributed
> > units".
> 
> While we are there. The "Toolbox" sponsor logo on the right. The
> Toolbox Magazine has been sold long ago to a new publisher. The
> "toolbox magazine" as we knew it, doesn't exist any more... they don't
> publish Pascal/Delphi related articles any more. Is that logo still
> needed on the free pascal website?

The swpat logo also seems to be outdated and brings you to a general FFII
page.


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


Re: [fpc-pascal] Contributed units on freepascal site

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 16:00, Marco van de Voort  wrote:
>
> It worked fine for me in Mozilla, but after I saw your user-agent, I tried
> MSIE (9.0) and while I don't get any error messages, nothing shows.


I can confirm that it works with Opera, Firefox and Chrome browsers.



-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC for ARM

2011-12-22 Thread Juha Manninen
2011/12/19 Marco van de Voort 

> FreeBSD and Linux x86 and x86_64 have internal assembler, but not linker.
> Though the FreeBSD/x86_64 internal assembler is only enable in trunk afaik.
>
> Be careful with binutils on ARM though, there are multiple ABIs, and the
> installed ones must match the device.
>

I ran "apt-get install binutils" in the already installed Ubuntu and it
worked.
I have understood ARM also supports many instruction sets like Thumb and
Thumb-2.
I have no idea which one is running now, but it is not important because it
works.
Thanks for help.

Is there an embedded web-server that would run on the ARM machine?

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

Re: [fpc-pascal] FPC for ARM

2011-12-22 Thread Marco van de Voort
In our previous episode, Juha Manninen said:
> I ran "apt-get install binutils" in the already installed Ubuntu and it
> worked.
> I have understood ARM also supports many instruction sets like Thumb and
> Thumb-2.
> I have no idea which one is running now, but it is not important because it
> works.
> Thanks for help.
> 
> Is there an embedded web-server that would run on the ARM machine?

Afaik most ARMs simply run httpd/apache.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] using exceptions

2011-12-22 Thread Bart
On 12/22/11, nore...@z505.com  wrote:

> You don't see as much Try Except, it's more Try Finally. People ignore the
> exceptions because it's an accepted thing to do. Then the end user of the
> application gets a strange exception message instead of a user friendly
> one. For example, if a file is not found, I like to give a polite "Cannot
> find file" message.. but usually in delphi apps and examples all over the
> newsgroups you see just an EFileNotFound exception pop up instead. Or,
> with StrToInt, a similar obscure exception message to the end user instead
> of a more friendly one.

I tend to spend more time on catching errors and displaying user
friendly and useful error messages than I do on writing the core
functionality of most of my (simple) programs.

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


Re: [fpc-pascal] using exceptions

2011-12-22 Thread Anton Shepelev
Marcos Douglas:

> It's  not  difficult,  but is boring have always a
> parameter or function return to return  an  error,
> and  have  to  verify  if error then... if not er-
> ror...  if error and error then... etc

If you mean having to write nested IFs to check  all
the  errors, then there are several ways to make the
error-checking in several calls "linearized":

http://www.digipedia.pl/usenet/thread/1169/284/

I prefer using GOTO statements:

begin
  Result := false; // Success flag
  [...]
  errMsg := errorOne;
  if not procOne  (...) then GOTO ERROR;
  errMsg := errTwo;
  if not procTwo  (...) then GOTO ERROR;
  errMsg := errThree;
  if not procThree(...) then GOTO ERROR;
  [...]
  Result := true
ERROR:
end

This way, the funtion returns an error  flag  and  a
correspoinding  message, and I prefer it to throwing
and catching Exceptions.   I  even  wrap  exception-
based  code  using external libraries in such proce-
dures to have an easier and cleaner error handling.

Also see:

http://www.theregister.co.uk/2006/01/11/exception_handling/

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


Re: [fpc-pascal] using exceptions

2011-12-22 Thread Marcos Douglas
On Thu, Dec 22, 2011 at 4:17 PM, Anton Shepelev  wrote:
> Marcos Douglas:
>
>> It's  not  difficult,  but is boring have always a
>> parameter or function return to return  an  error,
>> and  have  to  verify  if error then... if not er-
>> ror...  if error and error then... etc
>
> If you mean having to write nested IFs to check  all
> the  errors, then there are several ways to make the
> error-checking in several calls "linearized":
>
>    http://www.digipedia.pl/usenet/thread/1169/284/

No, I mean is better use try-except than nested IFs/GOTO/etc.

> I prefer using GOTO statements:
>
>    begin
>      Result := false; // Success flag
>      [...]
>      errMsg := errorOne;
>      if not procOne  (...) then GOTO ERROR;
>      errMsg := errTwo;
>      if not procTwo  (...) then GOTO ERROR;
>      errMsg := errThree;
>      if not procThree(...) then GOTO ERROR;
>      [...]
>      Result := true
>    ERROR:
>    end
>
> This way, the funtion returns an error  flag  and  a
> correspoinding  message, and I prefer it to throwing
> and catching Exceptions.   I  even  wrap  exception-
> based  code  using external libraries in such proce-
> dures to have an easier and cleaner error handling.
>
> Also see:
>
>    http://www.theregister.co.uk/2006/01/11/exception_handling/

Thanks for the tips... but, IMHO, the code above would be more simpler
like that:

begin
Result := False; // Success flag
[...]
procOne;
procTwo;
procThree;
[...]
Result := True;
  except
 on e: Exception do
   ShowMessage(e.Message);
  end;
end;

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


[fpc-pascal] Forward declarations

2011-12-22 Thread Timothy Groves
Can anyone think of a situation in which you would *have* to use forward 
declared functions?  I'm trying to come up with an example for such for 
my book, and I am drawing a blank.

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Rainer Stratmann
Am Thursday 22 December 2011 21:33:13 schrieb Timothy Groves:
> Can anyone think of a situation in which you would *have* to use forward
> declared functions?  I'm trying to come up with an example for such for
> my book, and I am drawing a blank.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal


procedure fwproc; forward;

procedure myprocedure;
begin
 fwproc;
end;

procedure fwproc;
begin

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Michael Fuchs
Am 22.12.2011 21:37, schrieb Rainer Stratmann:
> procedure fwproc; forward;
> 
> procedure myprocedure;
> begin
>  fwproc;
> end;
> 
> procedure fwproc;
> begin
> 
> end;

Bad example, in this case there is no need for implementing fwproc after
myprocedure.

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Mattias Gaertner
On Thu, 22 Dec 2011 15:33:13 -0500
Timothy Groves  wrote:

> Can anyone think of a situation in which you would *have* to use forward 
> declared functions?  I'm trying to come up with an example for such for 
> my book, and I am drawing a blank.

Traverse a html tree. For example with div and p nodes. Both div and
p nodes can have children that are div and p nodes.

procedure Proc(RootNode: TNode);

  procedure ReadChildrenv(Node: TNode); forward;

  procedure ReadP(Node: TNode);
  begin
...
ReadChildren(Node);
  end;

  procedure ReadDiv(Node: TNode);
  begin
...
ReadChildren(Node);
  end;

  procedure ReadChildren(Node: TNode);
  begin
for Child in Node do begin
  if Child is Div then ReadDiv(Child)
  else if Child is P then ReadP(Child);
end;
  end;

begin
  ReadChildren(RootNode);
end;

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Anton Shepelev
Timothy Groves:

> Can anyone think of a situation in which you would
> *have* to use  forward  declared  functions?   I'm
> trying  to come up with an example for such for my
> book, and I am drawing a blank.

Pascal User Manual and Report says:

Procecure (function) identifiers may be used be-
fore  the  procedure  (funtion)  declaration  if
there is a forward declaration.  Forward  decla-
rations  are  necessary to allow mutually recur-
sive procedures and functions that are not nest-
ed.  The form is as follows:

procedure Q(X:T); Forward;
procedure P(Y:T);
begin
  Q(A)
end;

procedure Q;
  { parameters and result types are not repeated }
begin
  P(B)
end;

But  are  "mutually  recursive  procedures and func-
tions" necessary?

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Mark Morgan Lloyd

Timothy Groves wrote:
Can anyone think of a situation in which you would *have* to use forward 
declared functions?  I'm trying to come up with an example for such for 
my book, and I am drawing a blank.


Classic recursive-descent parser? An expression is a sequence of terms, 
a term is a sequence of factors, one of the possibilities for a factor 
is a parenthesised expression.


However, there's probably still a way round that in a unit, by moving 
the first mention of one of those into the definition part. Or similarly 
you might be able to avoid it by using object definitions.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Timothy Groves

On 11-12-22 04:15 PM, Mark Morgan Lloyd wrote:
However, there's probably still a way round that in a unit, by moving 
the first mention of one of those into the definition part. Or 
similarly you might be able to avoid it by using object definitions.


Absolutely.  Because in both of those cases, you've already declared the 
procedure forward.


However, this section of the book is covering only ISO Pascal.  I will 
be covering more advanced Pascal implementations (especially FPC) later 
on, but for the beginning section, I will be assuming no access to such.


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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Timothy Groves

On 11-12-22 04:04 PM, Anton Shepelev wrote:

But are "mutually recursive procedures and functions" necessary?
Not at all.  But there is no other reason to use forward-declared 
procedures that I can think of, and I need *something* to demonstrate 
why you might need them.

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Rainer Stratmann
Am Thursday 22 December 2011 22:04:34 schrieb Anton Shepelev:
>Fward  decla-
>rations  are  necessary to allow mutually recur-
>sive procedures and functions that are not nest-
>ed.

Forward declarations are the only option in special situations:
If your program is huge and you only have this option to go on.
Later you can clean up step by step the code.
I search my project but didn't find a forward declaration anymore (so I did my 
homework). But I am sure that at some point it was necessary.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Tony Whyman
You could apply the same logic to the Pascal "label" statement. You can
(and should) always use a different construct and you could therefore
claim that the "label" statement is unnecessary because you cannot think
of a situation where there is no alternative -  but it exists. And
sometimes it is convenient to use. You could even go further and say
that the multiplication operator is unnecessary because you can always
achieve the same thing through repeated summation. But, of course, it is
more convenient to use multiplication.

Forward declared procedures exist in Jensen and Wirth Pascal and they
exist for the purpose of allowing the convenience of those who sometimes
find it easier or clearer to code an algorithm using mutual recursion.
Why do you need a deeper explanation?

Tony Whyman
MWA Software

On 22/12/11 21:24, Timothy Groves wrote:
> On 11-12-22 04:04 PM, Anton Shepelev wrote:
>> But are "mutually recursive procedures and functions" necessary?
> Not at all.  But there is no other reason to use forward-declared
> procedures that I can think of, and I need *something* to demonstrate
> why you might need them.
> ___
> 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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Rich Saunders
On 12/22/11 5:21 PM, Tony Whyman wrote:
> [explanation snipped] Why do you need a deeper explanation?
He is not asking for an explanation. (I think he knows what it is and
can see why it might be useful.)

He is asking for a compelling example as a use case that illustrates the
need for this language construct.

I haven't seen one in any replies yet.

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


[fpc-pascal] Darwin i386 socket polling

2011-12-22 Thread Andrew Brunner
I'm needing to figure out how socket signaling mechanisms work under darwin.

Windows and Linux work, Darwin however does not support ePoll.

Anyone have any experience with Sockets events under OSX i386?

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


Re: [fpc-pascal] Forward declarations

2011-12-22 Thread Jürgen Hestermann



Timothy Groves schrieb:
Can anyone think of a situation in which you would *have* to use 
forward declared functions?  I'm trying to come up with an example for 
such for my book, and I am drawing a blank.




Well, maybe this one:

---
type  SorterProcType  = function (String1,String2 : shortstring) : 
boolean;

function CompareIt1(String1,String2 : shortstring) : boolean; forward;
function CompareIt2(String1,String2 : shortstring) : boolean; forward;
function CompareIt3(String1,String2 : shortstring) : boolean; forward;
const SortCriteria : SortProcType = CompareIt1;

---

I don't know of another way that you can use one of the "CompareIt1/2/3" 
functions in the const declaration for "SortCriteria" (but maybe there 
is one).

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