Re: [fpc-pascal] Empty record inside another record ?

2008-02-17 Thread Skybuck Flying

What's the benefit of using objects ?

One drawback of objects already discovered:

Objects cannot have the same field identifiers.

A problem that does not exist with records, and empty records.

// object example, pointers and typecasts still necessary.

program Project1;

{$APPTYPE CONSOLE}

uses
 SysUtils;

type
PethernetHeader = ^TethernetHeader;
TethernetHeader = object
 SomeFields1 : packed array[0..13] of byte;
end;

PipHeaderVersion4 = ^TipHeaderVersion4;
TipHeaderVersion4 = object(TethernetHeader)
 SomeFields2 : packed array[0..19] of byte; // first problem, identifier 
redeclared, numbers used to fix it.

end;

TudpHeaderVersion4 = object(TipHeaderVersion4)
 SomeFields3 : packed array[0..7] of byte;
end;

TtcpHeaderVersion4 = object(TipHeaderVersion4)
 SomeFields4 : packed array[0..19] of byte;
end;

Tframe = object
 SomeFields5 : packed array[0..66000] of byte;
end;

procedure Main;
var
frame : Tframe;
begin
frame.SomeFields5[14] := 234;

// TethernetHeader(frame). // typecast not possible.

// with frame as TethernetHeader do // operator not applicable
// begin
//  SomeFields5[4] := 123;
// end;

// maybe pointers can help
writeln( PipHeaderVersion4(@Frame).SomeFields2[0] );
end;

begin
 try
Main;
 except
on E:Exception do
  Writeln(E.Classname, ': ', E.Message);
 end;
 readln;
end.

Bye,
 Skybuck. 


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


Re: [fpc-pascal] Empty record inside another record ?

2008-02-17 Thread Skybuck Flying

Well ok,

I see one benefit of using objects so far.

No extension field needed per record/object, makes the code less complex ;)

Bye,
 Skybuck.

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


[fpc-pascal] compiler asks for variants support

2008-02-17 Thread Marc Santhoff
Hi,

why does this program:


program novariant;
uses
sysutils;
var
a, b: double;
begin
b := 0.4237;
a := b**5;
writeln(floattostr(a));
end.


when running give that error message:

$ ./novariant

Program needs probably the variants unit.
Include the variants unit in your uses statements
as one of the first units.


An unhandled exception occurred at $08052E37 :
EVariantError : Invalid variant operation
  $08052E37


TIA,
Marc


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


Re: [fpc-pascal] compiler asks for variants support

2008-02-17 Thread Jonas Maebe


On 17 Feb 2008, at 17:19, Marc Santhoff wrote:


why does this program:


program novariant;
uses
sysutils;
var
a, b: double;
begin
b := 0.4237;
a := b**5;
writeln(floattostr(a));
end.


when running give that error message:


The ** operator for doubles is declared in the math unit. Without  
including the math unit, the only found ** operator is for variants.



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


[fpc-pascal] fpGUI (a Free Pascal GUI Toolkit) v0.6 has been released

2008-02-17 Thread Graeme Geldenhuys
Hi,

fpGUI version 0.6 has been released.

Five months after the previous release, v0.6 is finally here. As
always, lot has been improved
and added. For example: a newly supported platform (FreeBSD) and
64-bit support just to mention two.

Source and documentation are available for download at SourceForge:
  http://sourceforge.net/project/showfiles.php?group_id=182330

Release notes can be read at:
  http://sourceforge.net/project/shownotes.php?group_id=182330&release_id=577323

For more information on fpGUI visit:
 http://opensoft.homeip.net/fpgui/

Support newsgroup:
 news://opensoft.homeip.net


Regards,
  - Graeme -


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


Re: [fpc-pascal] compiler asks for variants support

2008-02-17 Thread Marc Santhoff
Am Sonntag, den 17.02.2008, 17:23 +0100 schrieb Jonas Maebe:
> On 17 Feb 2008, at 17:19, Marc Santhoff wrote:
> 
> > why does this program:
> >
> >
> > program novariant;
> > uses
> > sysutils;
> > var
> > a, b: double;
> > begin
> > b := 0.4237;
> > a := b**5;
> > writeln(floattostr(a));
> > end.
> >
> >
> > when running give that error message:
> 
> The ** operator for doubles is declared in the math unit. Without  
> including the math unit, the only found ** operator is for variants.

I see.

Thanks, especially for answering quickly,
Marc


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


[fpc-pascal] run time error 208

2008-02-17 Thread Marc Santhoff
Hi,

what makes a calculation like this:


  result := 4*Q / (pi*ny*d);


throw an error:

  An unhandled exception occurred at $080897AB :
  Exception : Unknown Run-Time error : 208

and what is the cause and nature of error 208?

(I feel a little stupid, I've searched the .pdf-docs and the freepascal
site and wiki to no avail ...)

TIA,
Marc


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


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Florian Klaempfl
Jonas Maebe schrieb:
> 
> On 17 Feb 2008, at 18:48, Marc Santhoff wrote:
> 
>> and what is the cause and nature of error 208?
> 
> An unknown/unsupported fpu exception (in the FreeBSD rtl at least, on
> other platforms this is mapped to rte 207).
> 

At least it should be mapped to 207 on FreeBSD as well I suppose.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Jonas Maebe


On 17 Feb 2008, at 18:48, Marc Santhoff wrote:


and what is the cause and nature of error 208?


An unknown/unsupported fpu exception (in the FreeBSD rtl at least, on  
other platforms this is mapped to rte 207).



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


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Marc Santhoff
Am Sonntag, den 17.02.2008, 19:01 +0100 schrieb Jonas Maebe:
> On 17 Feb 2008, at 18:48, Marc Santhoff wrote:
> 
> > and what is the cause and nature of error 208?
> 
> An unknown/unsupported fpu exception (in the FreeBSD rtl at least, on  
> other platforms this is mapped to rte 207).

That's why I knew I had seen this number, it's in the procedure
SignalToRunerror(), so I'm not so stupid after all. ;)

Is there any other way of examining the cause besides looking at the
values of the variables involved in the calculation?

Many thanks,
Marc


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


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Jonas Maebe


On 17 Feb 2008, at 19:19, Marc Santhoff wrote:


That's why I knew I had seen this number, it's in the procedure
SignalToRunerror(), so I'm not so stupid after all. ;)

Is there any other way of examining the cause besides looking at the
values of the variables involved in the calculation?


You could check whether signaltorunerror is maybe missing some entries  
in its case statement for SIGFPE reasons, and add any missing ones  
(and if so, submit a patch for that).



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


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Jonas Maebe


On 17 Feb 2008, at 19:15, Florian Klaempfl wrote:


Jonas Maebe schrieb:





An unknown/unsupported fpu exception (in the FreeBSD rtl at least, on
other platforms this is mapped to rte 207).



At least it should be mapped to 207 on FreeBSD as well I suppose.


I think so too.


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


[fpc-pascal] cthreads unit

2008-02-17 Thread ik
Hello,

I'm trying to use the pthread_self function that supposed to be
existed at cthreads unit.
However the compiler tell me that it does not know "pthread_self".

I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 .
Looking at the source of cthreads.pp, it does have an include for
pthread.inc file, that does contain dynamic/static linking of the
function, so what am I missing ?

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


Re: [fpc-pascal] cthreads unit

2008-02-17 Thread Jonas Maebe


On 17 Feb 2008, at 19:42, ik wrote:


I'm trying to use the pthread_self function that supposed to be
existed at cthreads unit.
However the compiler tell me that it does not know "pthread_self".


It's only imported into that unit (in the implementation), it's not  
exported. The cthreads unit only installs a thread manager, it does  
not expose any implementation details (that's the whole point of that  
unit).



I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 .
Looking at the source of cthreads.pp, it does have an include for
pthread.inc file, that does contain dynamic/static linking of the
function, so what am I missing ?


If you want to use the RTL support for threading, use the generic RTL  
routines and not OS-specific ones. There is e.g. a GetCurrentThreadId  
function (but don't count on it returning the same value as  
pthread_self).


If you want to program with pthreads directly, use the pthreads unit  
instead.



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


Re: [fpc-pascal] fpGUI (a Free Pascal GUI Toolkit) v0.6 has been released

2008-02-17 Thread Cesar Romero

Hi Graeme,

Great step, congrats.
Are there any new screnshot?

[]s


Cesar

Hi,

fpGUI version 0.6 has been released.

Five months after the previous release, v0.6 is finally here. As
always, lot has been improved
and added. For example: a newly supported platform (FreeBSD) and
64-bit support just to mention two.

Source and documentation are available for download at SourceForge:
  http://sourceforge.net/project/showfiles.php?group_id=182330

Release notes can be read at:
  http://sourceforge.net/project/shownotes.php?group_id=182330&release_id=577323

For more information on fpGUI visit:
 http://opensoft.homeip.net/fpgui/

Support newsgroup:
 news://opensoft.homeip.net


Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
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] run time error 208

2008-02-17 Thread Marc Santhoff
Am Sonntag, den 17.02.2008, 19:38 +0100 schrieb Jonas Maebe:
> On 17 Feb 2008, at 19:19, Marc Santhoff wrote:
> 
> > That's why I knew I had seen this number, it's in the procedure
> > SignalToRunerror(), so I'm not so stupid after all. ;)
> >
> > Is there any other way of examining the cause besides looking at the
> > values of the variables involved in the calculation?
> 
> You could check whether signaltorunerror is maybe missing some entries  
> in its case statement for SIGFPE reasons, and add any missing ones  
> (and if so, submit a patch for that).

The cause was an (easy to detect) division by zero. I expected such
errors to be caught ...

The code for FreeBSD in question looks like this:

case sig of
SIGFPE :
  begin
Case Info.si_code Of
FPE_INTDIV : Res:=200;  {integer divide fault. Div0?}
FPE_FLTOVF : Res:=205;  {Overflow trap}
FPE_FLTUND : Res:=206;  {Stack over/underflow}
FPE_FLTRES : Res:=216;  {Device not available}
FPE_FLTINV : Res:=216;  {Invalid floating point operation}
   Else
Res:=208; {coprocessor error}
End;
 sysResetFPU;
  End;
SIGILL,
SIGBUS,
SIGSEGV :
res:=216;
  end;

What model of the i386 would be the best one for making a start?

I'd at least try to get the programmers manual for looking at the FPU
exception codes. Or maybe someone know a better way to get the necessary
information ...

Marc


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


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Jonas Maebe


On 17 Feb 2008, at 20:43, Marc Santhoff wrote:


The code for FreeBSD in question looks like this:

case sig of
   SIGFPE :
 begin
   Case Info.si_code Of
   FPE_INTDIV : Res:=200;  {integer divide fault. Div0?}
   FPE_FLTOVF : Res:=205;  {Overflow trap}
   FPE_FLTUND : Res:=206;  {Stack over/underflow}
   FPE_FLTRES : Res:=216;  {Device not available}
   FPE_FLTINV : Res:=216;  {Invalid floating point  
operation}

  Else
   Res:=208; {coprocessor error}
   End;
sysResetFPU;
 End;
   SIGILL,
   SIGBUS,
   SIGSEGV :
   res:=216;
 end;

What model of the i386 would be the best one for making a start?


You shouldn't need any cpu/fpu flags info. grep -r /usr/include for  
FPE_INTDIV, and see if there isn't also a constant for a floating  
point division by zero in the same file.



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


Re: [fpc-pascal] cthreads unit

2008-02-17 Thread ik
Thanks, that works.

On Feb 17, 2008 8:50 PM, Jonas Maebe <[EMAIL PROTECTED]> wrote:
>
> On 17 Feb 2008, at 19:42, ik wrote:
>
> > I'm trying to use the pthread_self function that supposed to be
> > existed at cthreads unit.
> > However the compiler tell me that it does not know "pthread_self".
>
> It's only imported into that unit (in the implementation), it's not
> exported. The cthreads unit only installs a thread manager, it does
> not expose any implementation details (that's the whole point of that
> unit).
>
> > I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 .
> > Looking at the source of cthreads.pp, it does have an include for
> > pthread.inc file, that does contain dynamic/static linking of the
> > function, so what am I missing ?
>
> If you want to use the RTL support for threading, use the generic RTL
> routines and not OS-specific ones. There is e.g. a GetCurrentThreadId
> function (but don't count on it returning the same value as
> pthread_self).
>
> If you want to program with pthreads directly, use the pthreads unit
> instead.
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



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


Re: [fpc-pascal] fpGUI (a Free Pascal GUI Toolkit) v0.6 has been released

2008-02-17 Thread Graeme Geldenhuys
On 17/02/2008, Cesar Romero <[EMAIL PROTECTED]> wrote:
>
> Are there any new screenshot?


Visually things have stayed pretty much the same compared to the
previous release. The components simply work and behave better. :)
v0.6 contains a lot of bug fixes.  Three new visual things are the
Gauges component (pie, needle, progress etc), anti-aliased line
drawing and the Treeview component now supporting images.  Now that
this release is out, I will start paying attention to the theming
support and layout managers.


Regards,
  - Graeme -


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


Re: [fpc-pascal] run time error 208

2008-02-17 Thread Marc Santhoff
Am Sonntag, den 17.02.2008, 20:46 +0100 schrieb Jonas Maebe:
> On 17 Feb 2008, at 20:43, Marc Santhoff wrote:
> 
> > The code for FreeBSD in question looks like this:
> >
> > case sig of
> >SIGFPE :
> >  begin
> >Case Info.si_code Of
> >FPE_INTDIV : Res:=200;  {integer divide fault. Div0?}
> >FPE_FLTOVF : Res:=205;  {Overflow trap}
> >FPE_FLTUND : Res:=206;  {Stack over/underflow}
> >FPE_FLTRES : Res:=216;  {Device not available}
> >FPE_FLTINV : Res:=216;  {Invalid floating point  
> > operation}
> >   Else
> >Res:=208; {coprocessor error}
> >End;
> > sysResetFPU;
> >  End;
> >SIGILL,
> >SIGBUS,
> >SIGSEGV :
> >res:=216;
> >  end;
> >
> > What model of the i386 would be the best one for making a start?
> 
> You shouldn't need any cpu/fpu flags info. grep -r /usr/include for  
> FPE_INTDIV, and see if there isn't also a constant for a floating  
> point division by zero in the same file.

Ah, now I understand. But I'm stuck at the error number for fpc, is
rtl/objpas/sysconsts.pp the authoritative source?

Mine from 2.0.4 looks like this:


 200 : Result:=SDivByZero;
 201 : Result:=SRangeError;
 203 : Result:=SOutOfMemory;
 204 : Result:=SInvalidPointer;
 205 : Result:=SOverFlow;
 206 : Result:=SUnderFlow;
 207 : Result:=SInvalidOp;
 211 : Result:=SAbstractError;
 214 : Result:=SBusError;
 215 : Result:=SIntOverFlow;
 216 : Result:=SAccessViolation;


If I follow this scheme it'll be surely inconsistent afterwards and may
break existing code.

As you can see, the number 208 is not taken, yet.

Together with the list (and adapted comments reflecting those from the
FreeBSD source) the resulting code would be:

 begin
   Case Info.si_code Of
 FPE_INTOVF : Res:=205; {integer overflow}
 FPE_INTDIV : Res:=200;  {integer divide by zero}
FPE_FLTDIV : Res:=200; {floating point divide by zero}
 FPE_FLTOVF : Res:=205;  {floating point overflow}
 FPE_FLTUND : Res:=206;  {floating point underflow}
 FPE_FLTRES : Res:=???;  {floating point inexact result}
 FPE_FLTINV : Res:=???;  {Invalid floating point operation}
 FPE_FLTSUB : Res:=???; {subscript out of range}
   Else
 Res:=???; {coprocessor error}
   End;
   sysResetFPU;
 End;

Note the ???'s there I do not know, which way to go.

Marc


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


[fpc-pascal] Save image into BMP or JPEG using Free Pascal (Save screenshot of OpenGL scene)

2008-02-17 Thread Jakub Marian

Hello,

I need to save data stored in memory into .bmp or (which would be the better
variant) into .jpg file. Actually what I want to do is to save the OpenGL
screen (probably using glReadPixels() function) into image. I've downloaded
PasJPEG, but it doesn't seem to be working. When I try to compile example
program for PasJPEG, I get: 'Error: Wrong number of parameters specified for
call to "error_exit"'

Do you know any efficient way to save glReadPixels into .bmp or .jpeg file?
It would be very helpful for me.

I am looking forward for your answers. Thank you even for reading this post.
:-)

Jakub Marian
-- 
View this message in context: 
http://www.nabble.com/Save-image-into-BMP-or-JPEG-using-Free-Pascal-%28Save-screenshot-of-OpenGL-scene%29-tp15530582p15530582.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

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