views:

58

answers:

1

Hi! I am using VBScript in a Manifold GIS Database to verify the distance between two longitude and latitude points using Trig function. The script for finding the distance run without any problems but the script for verifying whether the O-D is valid had syntax error. I really hope any of you could help me with this problem.

There were 2 new active columns that I created : Distance and VerifyDistance. Distance column was created to find the distance using Trig function. It ran successfuly but may need improvements in its messy structure. The VerifyDistance used the IF conditions and checked the value in another column named "Valid O/D". If the value is "OK", it will return the Distance value; otherwise, it will return a text value saying "O-D points are invalid" in this column.

As you can see, I am a newb in programming language. The VBScript can be seen below:

Function Distance
 Distance = sqr((111.21*Record.Data("Work Y-coord") - 111.21*Record.Data("Home Y-coord"))^2 + (85.30*Record.Data("Work X-coord") - 85.30*Record.Data("Home X-coord"))^2)

End Function

Function VerifyDistance
 If Record.Data("Valid O/D") = "OK"
    VerifyDistance = Record.Data("Distance")
 'document.write("Invalid O-D Points")
 Else
    VerifyDistance = "O-D Points are invalid."
 End If

End Function

Thanks a lot for helping me!

+2  A: 

You are missing Then here.

If Record.Data("Valid O/D") = "OK" Then
shahkalpesh
Thanks a lot for your help! What type variables should I assign for this column? I used float doubles for the distance but if the O-D points are invalid, the message won't show up.
Wolter Wantah
@Wolter: In VBScript, you cannot define a type with a variable as against VB (`dim myVariable` (in vbscript) vs `dim myNumber as Integer` (in Visual Basic)).
shahkalpesh
Thanks anyways!
Wolter Wantah