propertyValueType query

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

If I do a straight query using propertyValueType on an object's property I get numbers:

1 : 4818
2 : 4819
3 : 4821
4 : 4820
5 : 4822
6 : 4812
7 : 4817
8 : 4823
9 : 4824
10 : 4814
11 : 4813
12 : 4816
13 : 4815

...so unless I explicitly compare ie:

prop.propertyValueType==PropertyValueType.TwoD_SPATIAL

...it's tricky to get the type as something instantly understandable.

I've in the process of writing a little function to return a string, but the numbers are NOT in the same order as the types are listed in the help. I've got 8 out of the 13 pegged, but exact numbers for:

NO_VALUE
TwoD_SPATIAL
CUSTOM_VALUE
MARKER
MASK_INDEX

...are still eluding me. Either I'm not sure of the exact syntax to return the type (mask index, marker) or I don't understand how the property is implimented (custom, no value, 2D spatial).

Any ideas to nail these last few!?

Cheers,
Dave

ps - I'm using this code to test (indented lines have been completed to the best of my knowledge):

Code: Select all

function propertyValueTypeString(prop){
	var str="????"
	if(prop!=null){
		switch(prop.propertyValueType){
			case 4812: str="NO_VALUE"; break;
					case 4813: str="ThreeD_SPATIAL"; break;
					case 4814: str="ThreeD"; break;
			case 4820: str="TwoD_SPATIAL"; break;
					case 4815: str="TwoD"; break;
					case 4817: str="OneD"; break;
					case 4818: str="COLOR"; break;
			case 4816: str="CUSTOM_VALUE"; break;
			case 4822: str="MARKER"; break;
					case 4821: str="LAYER_INDEX"; break;
			case 4819: str="MASK_INDEX"; break;
					case 4823: str="SHAPE"; break;
					case 4824: str="TEXT_DOCUMENT"; break;
			}
		alert([prop.name,String(prop.propertyValueType),str])
		//return str
		}
	else{
		alert('Null value...')
		//return undefined
		}
	}
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Just using a simple script like this:

alert(PropertyValueType.NO_VALUE);

I get

NO_VALUE = 4812
TwoD_SPATIAL = 4815
CUSTOM_VALUE = 4819
MARKER = 4820
MASK_INDEX = 4822

Dan
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

Perfect - Thanks Dan.

The following code...

Code: Select all

str=""
arr=["NO_VALUE", "ThreeD_SPATIAL", "ThreeD", "TwoD_SPATIAL", "TwoD", "OneD", "COLOR", "CUSTOM_VALUE", "MARKER", "LAYER_INDEX", "MASK_INDEX", "SHAPE", "TEXT_DOCUMENT"]
for(a in arr){
	str+=eval("PropertyValueType."+arr[a])+ " : " +arr[a] + "\n"
	}
alert(str)
...returns...

4812 : NO_VALUE
4813 : ThreeD_SPATIAL
4814 : ThreeD
4815 : TwoD_SPATIAL
4816 : TwoD
4817 : OneD
4818 : COLOR
4819 : CUSTOM_VALUE
4820 : MARKER
4821 : LAYER_INDEX
4822 : MASK_INDEX
4823 : SHAPE
4824 : TEXT_DOCUMENT

So it is the same order, and everything is just fine. Going back with fresh eyes I cracked some of the syntax issues too.

Thanks for the pointer!

:D
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

I'm curious as to why you need the actual value of the PropertyValueType constants. You'll still need to do a comparison. A switch statement could use the constants as in:

Code: Select all

switch (prop.popertyValueType) {
    case PropertyValueType.ThreeD_SPATIAL:
        str = "3D Spatial"; break;
    case PropertyValueType.ThreeD:
        str = "3D"; break;
    /*  ...  */
    case PropertyValueType.NO_VALUE:
    default:
        str = "No Value"; break;
}
Peter
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

A fair point. I guess as with a lot of programming problems - you (or I in this case) get hung up over a particular specific of a problem, and you (I) focus on that.

In this case, the fact that the method appeared to return numbers rather than strings made me work in a particular direction, and it went from there.

One down... several trillion trillion trillion to go!!!

:D
mpowers

I'm having trouble trapping errors with try\catch when I try:

property.value and its
propertyValueType == NO_VALUE,

Has anyone else run into this? Any suggestions. I'm a bit of a noob to JS.

Thnx
Post Reply