...

View Full Version : Variable Declaration Syntax Troubles...



Mapper99
10-08-2008, 07:32 PM
I am having trouble declaring a variable:

This code works:

var params = { "Expression": "HOUSE_NO = \'185\' AND ROAD_NAME = \'32A Ave\'" };
gp.execute(params);

This code does not work: (tempstreetno=185, tempstreetname=32A Ave)


var address = "\"HOUSE_NO = \'" + tempstreetno + "\' AND ROAD_NAME = \'" + tempstreetname + "\'\"";
var params = { "Expression": + address };
gp.execute(params);

Any ideas?

Thanks in advance,

Mapper

liorean
10-08-2008, 09:46 PM
This code does not work: (tempstreetno=185, tempstreetname=32A Ave)


var address = "\"HOUSE_NO = \'" + tempstreetno + "\' AND ROAD_NAME = \'" + tempstreetname + "\'\"";
var params = { "Expression": + address };
gp.execute(params);Just remove that and try again.

Mapper99
10-08-2008, 10:20 PM
Still no luck. I am creating a string that looks identical to the first set of code. I wasn't sure of you could pass a variable into an object declaration. Will this work?

Mapper99
10-08-2008, 11:21 PM
var params = { "Expression": + address };

should be:

var params = { "Expression":address };

no "+"

Works fine now!

liorean
10-09-2008, 02:42 AM
Which is exactly what I said...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum