type of an attribute/property

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

type of an attribute/property

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:41 pm

by mike.price >> Fri, 10 Jan 2003 1:47:28 GMT

how can I find the type of a property of a class.
i.e I have a property from PropertyNDict and i need to know what type of data it is ( REAL, DATE INTEGER etc).

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: type of an attribute/property

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:41 pm

by allistar >> Fri, 10 Jan 2003 2:29:48 GMT
how can I find the type of a property of a class.
i.e I have a property from PropertyNDict and i need to know what type of data it is ( REAL, DATE INTEGER etc).

The Property class has a "type" property (of type Type). (Try and say that fast!).

When comparing types it's best to compare the names of primitive types rather than actual types themselves, e.g:

//don't do:
if (property.type = Integer) then
//do something
endif;

//instead do:
if (property.type.name = "Integer") then
//do something
endif;

This is because the Integer class object is different depending on
what schema you are in. I.e. there is an Integer class object for RootSchema and one for your subschema as well, so the comparison may
fail even when you want it to succeed.

Here is a hint for getting all properties on a class:

vars
property: Property;
cls: Class;begin

cls := Supplier;
foreach property in cls.allProperties do
write property.name & " - " & property.type.name;
endforeach;
end;

You may find that handy.

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: type of an attribute/property

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:41 pm

by mike.price >> Fri, 10 Jan 2003 2:54:59 GMT

thanks....just the job.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: type of an attribute/property

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:42 pm

by torrie >> Mon, 13 Jan 2003 9:24:58 GMT

Hi

Just a small comment on using class names. I have found that is is a better idea to use Integer.name rather than "Integer" when refering to a type. eg use

//instead do:
if (property.type.name = Integer.name) then
//do something
endif;

If you are refering to one of your own classes and its name is changed then Jade will update the references automatically and it prevents silly spelling mistakes as the compiler will pick these up.


Torrie


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 15 guests