Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Variable Declaration Syntax Troubles...

    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

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by Mapper99 View Post
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fixed...

    var params = { "Expression": + address };

    should be:

    var params = { "Expression":address };

    no "+"

    Works fine now!

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Which is exactly what I said...


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •