I am trying to calculate values for my NENA NextGen 9-1-1 parity fields by using the VBScript MOD operator. The results should be (E)ven, (O)dd, (Z)ero, or (B)oth. Here's what I have so far, although I do not get results with the ValueInfo expressions I have listed. I'm unsure if this is a problem with the parentheses or the MOD operator itself.
Left Parity
Right Parity
Any help is welcome.
Thank you.
Solved! Go to Solution.
The solution was to put the Zero part of the expression before the Odd/Even. Here are the final expressions:
Left Parity
Right Parity
I do something similar, but using Arcade. Here's my code:
Left Parity
var leftfrom = Boolean($feature.fromleft % 2)
var leftto = Boolean($feature.toleft % 2)
if($feature.fromleft == null || $feature.toleft == null) {
return null
}
else {
if($feature.fromleft == 0 && $feature.toleft == 0) {
return "Z"
}
else {
if(leftfrom == false && leftto == false) {
return "E"
}
if(leftfrom == true && leftto == true) {
return "O"
}
if(leftfrom == false && leftto == true) {
return "B"
}
if(leftfrom == true && leftto == false) {
return "B"
}
}
}
Right Parity
var rightfrom = Boolean($feature.fromright % 2)
var rightto = Boolean($feature.toright % 2)
if($feature.fromright == null || $feature.toright == null) {
return null
}
else {
if($feature.fromright == 0 && $feature.toright == 0) {
return "Z"
}
else {
if(rightfrom == false && rightto == false) {
return "E"
}
if(rightfrom == true && rightto == true) {
return "O"
}
if(rightfrom == false && rightto == true) {
return "B"
}
if(rightfrom == true && rightto == false) {
return "B"
}
}
}
It automatically applies the expressions as soon as you tab out from the address number fields.
@JoshSaad1 , we have to use ArcGIS Desktop's Attribute Assistant add-in for now and it does not use Arcade, it only uses VBScript. I will keep your solution in mind for when we switch to Pro.
Would you be willing to explain the "% 2" used in your function? I have run across this in several code blocks, but can't find it documented.
Thanks
I'm not a programmer, but from what I understand this is called a Modulo. It determines whether there is a remainder when dividing one number by another. Even numbers don't have remainders and return 0. Odd numbers return 1. The Boolean function interprets 1 as True, and 0 as False.
Update to the original post
The following expressions work for all cases except for zeros which results in (E)ven. The ValueInfo lines are 168 characters each.
Left Parity
Right Parity
I have tried a few variations to get the zeros to work but haven't found one yet that is less than 255 characters. The following two were tested but failed and each is 253 characters in length:
Suggestions?
The solution was to put the Zero part of the expression before the Odd/Even. Here are the final expressions:
Left Parity
Right Parity