[fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread Graeme Geldenhuys
Hi,

I need a new boolean type in my applications that support three
values. True, False and Null.  Null value means undefined and has
various uses and gets handled differently to True or False.  Is this
possible in Free Pascal?


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] Can I define a custom simple type for my applications?

2009-04-06 Thread dmitry boyarintsev
type
  TGraemeBoolean = (dbNil, dbFalse, dbTrue);
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread Mattias Gaertner
On Mon, 6 Apr 2009 19:21:50 +0200
Graeme Geldenhuys graemeg.li...@gmail.com wrote:

 Hi,
 
 I need a new boolean type in my applications that support three
 values. True, False and Null.  Null value means undefined and has
 various uses and gets handled differently to True or False.  Is this
 possible in Free Pascal?

TGraemeBoolean = (gbNull, gbTrue, gbFalse);

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


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread dmitry boyarintsev
oh sorry, by i've missprinted prefixes:
type
 TGraemeBoolean = (gbNil, gbFalse, gbTrue);

// gb prefix stands for Greame Boolean
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread Graeme Geldenhuys
On Mon, Apr 6, 2009 at 7:33 PM, dmitry boyarintsev
skalogryz.li...@gmail.com wrote:

 TGraemeBoolean = (gbNull = -1, gbFalse = 0, gbTrue =1);

 function dbBool(g: TGrameBoolean): Boolean; inline;
 function dbAssigned(gTGrameBoolean): Boolean; inline;

Dope! Now why didn't I think of that. :-)  Thank you very much!

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] Can I define a custom simple type for my applications?

2009-04-06 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said:
 
  TGraemeBoolean = (gbNull = -1, gbFalse = 0, gbTrue =1);
 
  function dbBool(g: TGrameBoolean): Boolean; inline;
  function dbAssigned(gTGrameBoolean): Boolean; inline;
 
 Dope! Now why didn't I think of that. :-)  Thank you very much!

Have a look at $packenum btw if you go that way.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread dmitry boyarintsev
 Have a look at $packenum btw if you go that way.
what's the reason? i guess it's not to be used for streaming operation.

btw, is there $packsets? (for sets aligment?)

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


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread Marco van de Voort
In our previous episode, dmitry boyarintsev said:
  Have a look at $packenum btw if you go that way.
 what's the reason? i guess it's not to be used for streaming operation.

Well, you never know. Shared memory is another possibility btw.

 btw, is there $packsets? (for sets aligment?)

No, not that I know.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread dmitry boyarintsev
 No, not that I know.
sets are always 32-bit size?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread Marco van de Voort
In our previous episode, dmitry boyarintsev said:
  No, not that I know.
 sets are always 32-bit size?

Oops I apparantly looked at outdated docs (on scenergy):

http://www.freepascal.org/docs-html/prog/progsu59.html#x66-640001.1.59


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


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread dmitry boyarintsev
 Oops I apparantly looked at outdated docs (on scenergy):

 http://www.freepascal.org/docs-html/prog/progsu59.html#x66-640001.1.59

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


Re: [fpc-pascal] Can I define a custom simple type for my applications?

2009-04-06 Thread Jonas Maebe


On 06 Apr 2009, at 22:08, Marco van de Voort wrote:


Oops I apparantly looked at outdated docs (on scenergy):

http://www.freepascal.org/docs-html/prog/progsu59.html#x66-640001.1.59


That documentation is not really complete. The supported settings are:
* FIXED, DEFAULT, NORMAL: the default behaviour, and behaves as  
described in the docs.
* 1, 2, 4: the set size depends on both the low and high value of the  
set element type (e.g., a set of 16..23 will be 1 byte in case of  
{$packset 1}), with
a) the lower bound rounded down to a multiple of the packset setting  
expressed in bits
b) the upper bound rounded up to 'a multiple of the packset setting  
(in bits)' minus 1 (e.g., 24 is a multiple of 8 bits in the above  
example - -1 = 23)
c) if the set size would be 3 bytes after the above calculation, it's  
changed to 4 bytes
d) if the set size would be greater than 4 bytes after the above  
calculation, it's changed to 32 bytes.
* {$packset 8} is also supported, but kind of nonsensical in the  
current implementation (will always be rounded up to 32 byte, since  
the set size will always be  4).



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