EnumHelper

Posted by Roger Blanchard on 12-Oct-2011 12:51

I have used this before but I am not sure how to handle this. I am trying to check the DataType of a column in a grid and the following works.

IF oColumn:DataType:ToString() = "System.Decimal" THEN

Could I use the EnumHelper to do this test?

IF EnumHelper:AreEqual( oColumn:DataType, System.Type:Decimal) THEN

All Replies

Posted by Admin on 12-Oct-2011 13:02

Could I use the EnumHelper to do this test?

 

I don't think so because a System.Type is not an Enum.

Posted by Roger Blanchard on 12-Oct-2011 13:03

Okay, Thanks. I thought I was missing something.

Posted by Admin on 12-Oct-2011 13:07

However, I'd rather compare the System.Type to Progress.Util.TypeHelper:GetType ("System.Decimal") .

Posted by jquerijero on 13-Oct-2011 09:31

You can try

TYPE-OF(Column:DataType, System.Decimal)

Posted by Admin on 13-Oct-2011 09:52

You can try

TYPE-OF(Column:DataType, System.Decimal)

Won't work.

This would check if a System.Type (whatever sticks in the DataType property is a System.Type instance) is a subtype of System.Decimal - and that will always return false.

Posted by jquerijero on 13-Oct-2011 09:55

Oooops, should be

TYPE-OF(Column:Value, System.Decimal)

Posted by Admin on 13-Oct-2011 10:02

Oooops, should be

>

TYPE-OF(Column:Value, System.Decimal)

At least for the Infragistics Grid that won't work: A Column does not have a value. A Cell has. But that might not be available without data.

TypeHelper:GetType () is the way to go.

Posted by jquerijero on 13-Oct-2011 10:09

You are correct. Just be careful with the casing as GetType will fail if the case is wrong.

In this case, I prefer;

IF oColumn:DataType:ToString() = "System.Decimal" THEN

Posted by Admin on 13-Oct-2011 10:17

You are correct. Just be careful with the casing as GetType will fail if the case is wrong.

Unfortunately that's true. It's bad that we have to pass in a quoted Type name.

If you want this changed, complain about this whenever you talk to someone from PSC. We need a typeof function as in C# (no dash here) where the attribute is validated at compile time and respects the USING statements as well.

By the way: The EMEA PUG Challenge was able to extend its capacities - so our registration is open again: http://www.pugchallenge.eu

A great way to discuss you needs to the language and tools with top Progress people (such as "Ms. GUI for .NET" Shelley Chase and "Mr. everything else" Ken Wilner).

This thread is closed