ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Error in BRANT's AW SDK FUNCTIONS (Sdk)
Error in BRANT's AW SDK FUNCTIONS // SdkjohnJul 10, 2002, 6:39pm
I found an error for underground coordinates in the COORDINATES function of
it. Here is a fix :-) Sub coordinates(coord$) coord$ = LCase$(coord$) Dim nw2 As Variant Dim se11 As Variant Dim se2 As Variant Dim min As Boolean If InStr(1, coord$, "n", vbTextCompare) <> 0 And InStr(1, coord$, "s", vbTextCompare) <> 0 Then errorcode1 = 1: Exit Sub If InStr(1, coord$, "w", vbTextCompare) <> 0 And InStr(1, coord$, "e", vbTextCompare) <> 0 Then errorcode1 = 1: Exit Sub YAWcoord = 0 Xcoord = 0 Zcoord = 0 Ycoord = 0 u1 = 0 u2 = 0 u3 = 0 nw2 = -30000 se2 = -30000 se11 = -300000 On Error GoTo 1 For N = 1 To Len(coord$) If u1 <> 1 And Mid$(coord$, N, 1) = "w" Or Mid$(coord$, N, 1) = "e" Then For m = N To 1 Step -1 If Mid$(coord$, m, 1) = " " Or m = 1 Then nw$ = Mid$(coord$, m, N - m) nw2 = Val(nw$) If Mid$(coord$, N, 1) = "e" Then nw2 = -nw2 u1 = 1 GoTo 6 End If Next End If If u2 <> 1 And Mid$(coord$, N, 1) = "n" Or Mid$((coord$), N, 1) = "s" Then For m = N To 1 Step -1 If Mid$(coord$, m, 1) = " " Or m = 1 Then se$ = Mid$(coord$, m, N - m) se2 = Val(se$) If Mid$((coord$), N, 1) = "s" Then se2 = -se2 u2 = 1 GoTo 6 End If Next End If If u3 <> 1 And Mid$(coord$, N, 1) = "a" Then For m = N To 1 Step -1 If Mid$(coord$, m, 1) = " " Or Mid$(coord$, m, 1) = "-" Or m = 1 Then If Mid$(coord$, m, 1) = "-" Then min = True aa$ = Mid$(coord$, m, N - m) se11 = Val(aa$) If Mid$((coord$), m, 1) = "-" Then se11 = -se11 u3 = 1 GoTo 6 End If Next End If 6 Next For jm = Len(coord$) To 1 Step -1 If Mid$(coord$, jm, 1) = "e" Or Mid$(coord$, jm, 1) = "w" Or Mid$(coord$, jm, 1) = "n" Or Mid$(coord$, jm, 1) = "s" Then YAWcoord = 0: GoTo yyt If Mid$(coord$, jm, 1) = " " Then Exit For Next YAWcoord = Val(Mid$(coord$, jm + 1)) * 10 yyt: If nw2 = -30000 Or (se11 = -300000 And YAWcoord <> 0) Or se2 = -30000 Then errorcode1 = 1: Exit Sub Xcoord = nw2 * 1000 'Form1.sdk.AwSay se11 Ycoord = se11 * 1000 If min = True And VBA.Left(Ycoord, 1) <> "-" Then Ycoord = Val("-" & Ycoord) If se11 = -300000 Then Ycoord = 0 Zcoord = se2 * 1000 errorcode1 = 0 Exit Sub 1 errorcode1 = err End Sub strike rapierJul 10, 2002, 6:52pm
Probably irrelevant but I like the 1 I created
Sub Coordinates(Coords As String) Dim StrSplit As Variant, i As Integer, IntLength As Integer, StrSection As String, StrLeft As String Dim StrCoordsX As String, StrCoordsY As String, StrCoordsZ As String, StrCoordsYAW As Long Dim LngCoordsX As Long, LngCoordsY As Long, LngCoordsZ As Long, LngCoordsYAW As Long If CBool(InStr(1, Coords, " ")) = True Then Xcoord = 0 Ycoord = 0 Zcoord = 0 YAWcoord = 0 StrSplit = Split(Coords, " ") For i = 0 To UBound(StrSplit) StrSection = CStr(LCase(StrSplit(i))) StrRight = Right$(StrSection, 1) If StrRight = "" Or StrRight = "n" Or StrRight = "s" Or StrRight = "e" Or StrRight = "w" Or StrRight = "a" _ Or StrRight = "0" Or StrRight = "1" Or StrRight = "2" Or StrRight = "3" Or StrRight = "4" Or StrRight = "5" _ Or StrRight = "6" Or StrRight = "7" Or StrRight = "8" Or StrRight = "9" Then If StrRight = "e" Or StrRight = "w" Then If StrRight = "e" Then IntLength = Len(StrSection) - 1 StrCoordsX = Left$(StrSection, IntLength) LngCoordsX = CLng(Val(StrCoordsX)) LngCoordsX = 0 - (LngCoordsX * 1000) ElseIf StrRight = "w" Then IntLength = Len(StrSection) - 1 StrCoordsX = Left$(StrSection, IntLength) LngCoordsX = CLng(Val(StrCoordsX)) LngCoordsX = LngCoordsX * 1000 End If Xcoord = 0 - LngCoordsX ElseIf StrRight = "n" Or StrRight = "s" Then If StrRight = "s" Then IntLength = Len(StrSection) - 1 StrCoordsZ = Left$(StrSection, IntLength) LngCoordsZ = CLng(Val(StrCoordsZ)) LngCoordsZ = 0 - (LngCoordsZ * 1000) ElseIf StrRight = "n" Then IntLength = Len(StrSection) - 1 StrCoordsZ = Left$(StrSection, IntLength) LngCoordsZ = CLng(Val(StrCoordsZ)) LngCoordsZ = LngCoordsZ * 1000 End If Zcoord = 0 - LngCoordsZ ElseIf StrRight = "a" Then IntLength = Len(StrSection) - 1 LngCoordsY = CLng(Val(Left$(StrSection, IntLength))) LngCoordsY = LngCoordsY * 100 Ycoord = LngCoordsY ElseIf StrRight = "0" Or StrRight = "1" Or StrRight = "2" Or StrRight = "3" Or StrRight = "4" Or StrRight = "5" Or StrRight = "6" Or StrRight = "7" Or StrRight = "8" Or StrRight = "9" Then YAWcoord = CLng(Val(StrSection)) * 10 If YAWcoord >= 0 And YAWcoord <= 3600 Then YAWcoord = YAWcoord Else YAWcoord = 0 End If End If BolCoordSet = True End If Next i Else BolCoordSet = False Xcoord = 0 Ycoord = 0 Zcoord = 0 YAWcoord = 0 End If End Sub brantJul 11, 2002, 10:34am
If I were you, I would use a different coordinates function. As you can
see, that function is way too complicated for what it does, since I wrote it three years ago when I didn't fully understand the SDK. One of these days I'll get around to rewriting it. That said, I haven't encountered any errors - what did you change in it? [View Quote] johnJul 11, 2002, 1:34pm
Just made a boolean that changed to true if there was a - for the alt... lol
I noticed it.. odd... oh well :-) [View Quote] |