Select to view content in your preferred language

Looking for a Parenthesis when there are ones there - help

206
5
Jump to solution
12-12-2024 02:59 PM
LorindaGilbert
Frequent Contributor

Hi,

Working on a new AR and it keeps telling me that it needs a Close Parenthesis.  I've checked this thing over and over and don't see any missing.  It is based on another script that works - hence my confusion.  Says it is on the first 'else if' line.

Thanks!

var addrtype = $feature.AddrType
var addrsub = $feature.AddrSubCode
var addrstat = $feature.AddrStatus
var lsotype = $feature.LSOType
var unit = $feature.Unit
 
if (addrtype == 1) {
addrstat = 'A';
}
else if ((addrtype = 3) && (addrsub = 'PRESUB') && (!IsEmpty(unit))) {
addrstat = 'R';
}
else if ((addrtype = 3) && (addrsub = 'MODEL')) {
addrstat = 'R';
}
else if ((addrtype = 3) && ((addrsub != 'MODEL') or (addrsub != 'PRESUB'))) {
addrstat = 'A';
}
else if (addrtype = 2) {
addrstat = 'A';
}
else {
addrstat = addrstat;
}
return addrstat;
0 Kudos
2 Solutions

Accepted Solutions
DavidSolari
MVP Regular Contributor

Line 16 uses "or" instead of "||", that might be leading to the error message.

View solution in original post

0 Kudos
DavidSolari
MVP Regular Contributor

You're also using the assignment operator "=" when you should be using the equality operator "==" in a bunch of places, that'll usually lead to bugs if it also isn't causing a syntax error.

View solution in original post

0 Kudos
5 Replies
DavidSolari
MVP Regular Contributor

Line 16 uses "or" instead of "||", that might be leading to the error message.

0 Kudos
DavidSolari
MVP Regular Contributor

You're also using the assignment operator "=" when you should be using the equality operator "==" in a bunch of places, that'll usually lead to bugs if it also isn't causing a syntax error.

0 Kudos
LorindaGilbert
Frequent Contributor

I knew it was something silly that I was missing.  That one has tripped me up several times - you'd think that I would learn to look for that one 😜

Thanks!

0 Kudos
jcarlson
MVP Esteemed Contributor

In addition to @DavidSolari 's advice, you might also try using the function When. It works the same as a big if/else block, but it's more concise.

return When(
  addrtype == 1, 'A',
  addrtype == 3 && addrsub = 'PRESUB' && !IsEmpty(unit), 'R',
  // and so on. the last line is the default "else" option
  addrstat
)
- Josh Carlson
Kendall County GIS
0 Kudos
LorindaGilbert
Frequent Contributor

I'll give this a try in the future, needed to get it working and in the hands of testers quickly.

Thanks.

0 Kudos