Back-end build error

Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
Post Reply
meenbombs
Posts: 35
Joined: 20 November 2008, 15:54 PM

Back-end build error

Post by meenbombs »

I hired a contract programmer to write some code for me. He wrote it with the ZX-24a selected as the target device (accidentally) and it compiled with no problems. When I try to compile it for the ZX-328l (or any native device) I get the following error:

Error: one or more errors occurred in the back-end build process for "testnmea.zxb"
>Exit code: 1

I don't have a clue why the error and the programmer does not normally use Zbasic and is also clueless.



' Chris McMurrough June 2009
' Code for converting NMEA strings to Lat/Lon, UTM, and MGRS data

Private Sub ParseDegreeDecimalFromNMEA(ByVal NMEAString As String, ByRef LatDD As Single, ByRef LonDD As Single)
' Declare parsing variables
Dim ParseString As String = NMEAString
Dim tempi As Integer = 0
Dim tempd As Single = 0.0
Dim latString As String
Dim latChar As String
Dim lonString As String
Dim lonChar As String
' Make sure this string has the appropriate prefix and a min length
If (StrFind(ParseString, "$GPGGA,") = 1 And Len(NMEAString) > 36) Then
' discard the prefix
ParseString = Mid(ParseString, 8)
' discard the time
tempi = Cint(StrFind(ParseString, ","))
ParseString = Mid(ParseString, tempi + 1)
' store the lat
tempi = Cint(StrFind(ParseString, ","))
latString = Mid(ParseString, 1, tempi - 1)
ParseString = Mid(ParseString, tempi + 1)
' convert the lat string to decimal degrees by parsing the whole degrees and minute part
tempi = Cint(StrFind(latString, "."))
tempd = CSng(Left(latString, tempi - 3)) + CSng(Right(latString, 6)) / 60.0 ' get the leading degrees and the decimal part (rightmost 6 characters)
latString = CStr(tempd)
' store the lat char
tempi = Cint(StrFind(ParseString, ","))
latChar = Mid(ParseString, 1, tempi - 1)
ParseString = Mid(ParseString, tempi + 1)
' store the lon
tempi = Cint(StrFind(ParseString, ","))
lonString = Mid(ParseString, 1, tempi - 1)
ParseString = Mid(ParseString, tempi + 1)
' convert the lon string to decimal degrees by parsing the whole degrees and minute part
tempi = Cint(StrFind(lonString, "."))
tempd = CSng(Left(lonString, tempi - 3))
tempd = CSng(Right(lonString, 6)) / 60.0
tempd = CSng(Left(lonString, tempi - 3)) + CSng(Right(lonString, 6)) / 60.0 ' get the leading degrees and the decimal part (rightmost 6 characters)
lonString = CStr(tempd)
' store the lon char
tempi = Cint(StrFind(ParseString, ","))
lonChar = Mid(ParseString, 1, tempi - 1)
ParseString = Mid(ParseString, tempi + 1)
If (latChar = "N") Then
LatDD = CSng(latString)
Else
LatDD = CSng(latString) * -1.0
End If

If (lonChar = "E") Then
LonDD = CSng(lonString)
Else
LonDD = CSng(lonString) * -1.0
End If
Else
LatDD = 0.0
LonDD = 0.0
End If
End Sub

Private Sub LatLonToUTM(ByVal Lat As Single, ByVal Lon As Single, ByRef UTMNorthing As Single, ByRef UTMEasting As Single, ByRef UTMZone As String)
'Datum constants for WSG84/NAD83
Dim datum_a As Single = 6378137.0
Dim eccSquared As Single = 0.00669438
Dim eccPrimeSquared As Single = (eccSquared) / (1.0 - eccSquared)
Dim k0 As Single = 0.9996
Dim deg2rad As Single = 0.0174532925
'Calculation variables
Dim LonOrigin As Single
Dim N As Single
Dim T As Single
Dim C As Single
Dim A As Single
Dim M As Single
'Make sure the longitude is between -180.00 .. 179.9
Dim LonTemp As Single = (Lon + 180.0) - CSng(CInt(Floor((Lon + 180.0) / 360.0))) * 360.0 - 180.0
Dim LatRad As Single = Lat * deg2rad
Dim LonRad As Single = LonTemp * deg2rad
Dim LonOriginRad As Single
Dim ZoneNumber As Integer
Dim LatLetter As String
'First compute the zone number
ZoneNumber = CInt(Floor((LonTemp + 180.0) / 6.0)) + 1
If (Lat >= 56.0 And Lat < 64.0 And LonTemp >= 3.0 And LonTemp < 12.0) Then ZoneNumber = 32 End If ' Special zones for Svalbard If Lat >= 72.0 And Lat < 84.0 Then If LonTemp >= 0.0 And LonTemp < 9.0 Then ZoneNumber = 31 ElseIf LonTemp >= 9.0 And LonTemp < 21.0 Then ZoneNumber = 33 ElseIf LonTemp >= 21.0 And LonTemp < 33.0 Then ZoneNumber = 35 ElseIf LonTemp >= 33.0 And LonTemp < 42.0 Then ZoneNumber = 37 End If End If 'Now compute the zone letter LonOrigin = ((CSng(ZoneNumber) - 1.0) * 6.0 - 180.0) + 3.0 '+3 puts origin in middle of zone LonOriginRad = LonOrigin * deg2rad If (84.0 >= Lat) And (Lat >= 72.0) Then
LatLetter = "X"
ElseIf (72.0 > Lat) And (Lat >= 64.0) Then
LatLetter = "W"
ElseIf (64.0 > Lat) And (Lat >= 56.0) Then
LatLetter = "V"
ElseIf (56.0 > Lat) And (Lat >= 48.0) Then
LatLetter = "U"
ElseIf (48.0 > Lat) And (Lat >= 40.0) Then
LatLetter = "T"
ElseIf (40.0 > Lat) And (Lat >= 32.0) Then
LatLetter = "S"
ElseIf (32.0 > Lat) And (Lat >= 24.0) Then
LatLetter = "R"
ElseIf (24.0 > Lat) And (Lat >= 16.0) Then
LatLetter = "Q"
ElseIf (16.0 > Lat) And (Lat >= 8.0) Then
LatLetter = "P"
ElseIf (8.0 > Lat) And (Lat >= 0.0) Then
LatLetter = "N"
ElseIf (0.0 > Lat) And (Lat >= -8.0) Then
LatLetter = "M"
ElseIf (-8.0 > Lat) And (Lat >= -16.0) Then
LatLetter = "L"
ElseIf (-16.0 > Lat) And (Lat >= -24.0) Then
LatLetter = "K"
ElseIf (-24.0 > Lat) And (Lat >= -32.0) Then
LatLetter = "J"
ElseIf (-32.0 > Lat) And (Lat >= -40.0) Then
LatLetter = "H"
ElseIf (-40.0 > Lat) And (Lat >= -48.0) Then
LatLetter = "G"
ElseIf (-48.0 > Lat) And (Lat >= -56.0) Then
LatLetter = "F"
ElseIf (-56.0 > Lat) And (Lat >= -64.0) Then
LatLetter = "E"
ElseIf (-64.0 > Lat) And (Lat >= -72.0) Then
LatLetter = "D"
ElseIf (-72.0 > Lat) And (Lat >= -80.0) Then
LatLetter = "C"
Else
LatLetter = "Z"
End If
'store the UTM zone number and letter pair
If (ZoneNumber < 10) Then UTMZone = "0" + CStr(ZoneNumber) + LatLetter 'Pad with leading 0 Else UTMZone = CStr(ZoneNumber) + LatLetter End If 'calculate geometric values N = datum_a / Sqr(1.0 - eccSquared * Sin(LatRad) * Sin(LatRad)) T = Tan(LatRad) * Tan(LatRad) C = eccPrimeSquared * Cos(LatRad) * Cos(LatRad) A = Cos(LatRad) * (LonRad - LonOriginRad) 'calculate algorithm values M = datum_a * ((1.0 - eccSquared / 4.0 - 3.0 * eccSquared * eccSquared / 64.0 - 5.0 * eccSquared * eccSquared * eccSquared / 256.0) * LatRad - (3.0 * eccSquared / 8.0 + 3.0 * eccSquared * eccSquared / 32.0 + 45.0 * eccSquared * eccSquared * eccSquared / 1024.0) * Sin(2.0 * LatRad) + (15.0 * eccSquared * eccSquared / 256.0 + 45.0 * eccSquared * eccSquared * eccSquared / 1024.0) * Sin(4.0 * LatRad) - (35.0 * eccSquared * eccSquared * eccSquared / 3072.0) * Sin(6.0 * LatRad)) UTMEasting = CSng((k0 * N * (A + (1.0 - T + C) * A * A * A / 6.0 + (5.0 - 18.0 * T + T * T + 72.0 * C - 58.0 * eccPrimeSquared) * A * A * A * A * A / 120.0) + 500000.0)) UTMNorthing = CSng((k0 * (M + N * Tan(LatRad) * (A * A / 2.0 + (5.0 - T + 9.0 * C + 4.0 * C * C) * A * A * A * A / 24.0 + (61.0 - 58.0 * T + T * T + 600.0 * C - 330.0 * eccPrimeSquared) * A * A * A * A * A * A / 72.00)))) If Lat < 0.0 Then '10000000 meter offset for southern hemisphere UTMNorthing = UTMNorthing + 10000000.0 End If End Sub Sub Main() Dim NMEAString As String Dim UTMString As String Dim MGRSString As String NMEAString = "$GPGGA,183730,2115.000,N,15800.000,W,1,05,1.6,646.4,M,-24.1,M,,*75" 'location of Honolulu, HI Call ConvertNMEAToUTM(NMEAString, UTMString) Call ConvertNMEAToMGRS(NMEAString, MGRSString) End Sub Private Sub ConvertNMEAToMGRS(ByVal NMEAString As String, ByRef MGRSString As String) Dim UTM_NORTHING As Single Dim UTM_EASTING As Single Dim UTM_ZONE As String Dim MGRS_SQUARE As String Dim Lat As Single Dim Lon As Single Dim temp As Single = 0.0 Dim eastingOffset As Single = 25000.0 Call ParseDegreeDecimalFromNMEA(NMEAString, Lat, Lon) Call LatLonToUTM(Lat, Lon, UTM_NORTHING, UTM_EASTING, UTM_ZONE) ' compute the MGRS Square identifier, easting first ' compute the width of the AHJRSZ regions for this latitude If (Abs(Lat) < 24.0) Then eastingOffset = 50000.0 * ((24.0 - Abs(Lat)) / 24.0) ElseIf (Abs(Lat) < 48.0) Then eastingOffset = 100000.0 * ((48.0 - Abs(Lat)) / 24.0) temp = temp + 100000.0 ElseIf (Abs(Lat) < 72.0) Then eastingOffset = 100000.0 * ((72.0 - Abs(Lat)) / 24.0) temp = temp + 200000.0 End If 'eastingOffset = 50000 * ((90 - Abs(Lat)) / 90) ' compute the width of the AHJRSZ regions for this latitude temp = temp + UTM_EASTING Mod (eastingOffset * 2.0 + 600000.0) If (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 3 = 1) Then If temp < (eastingOffset) Then MGRS_SQUARE = "A" ElseIf (temp >= eastingOffset And temp < 100000.0 + eastingOffset) Or (Abs(Lon) Mod 6.0 >5.3 And Lon Mod 6.0 < 6.3) Then MGRS_SQUARE = "B" ElseIf (temp >= 100000.0 + eastingOffset And temp < 200000.0 + eastingOffset) Or (Abs(Lon) Mod 6.0 >4.3 And Lon Mod 6.0 < 5.3) Then MGRS_SQUARE = "C" ElseIf (temp >= 200000.0 + eastingOffset And temp < 300000.0 + eastingOffset) Or (Abs(Lon) Mod 6.0 >3.3 And Lon Mod 6.0 < 4.3) Then MGRS_SQUARE = "D" ElseIf (temp >= 300000.0 + eastingOffset And temp < 400000.0 + eastingOffset) Or (Abs(Lon) Mod 6.0 >2.3 And Lon Mod 6.0 < 3.3) Then MGRS_SQUARE = "E" ElseIf (temp >= 400000.0 + eastingOffset And temp < 500000.0 + eastingOffset) Or (Abs(Lon) Mod 6.0 >1.3 And Lon Mod 6.0 < 2.3) Then MGRS_SQUARE = "F" ElseIf (temp >= 500000.0 + eastingOffset And temp < 600000.0 + eastingOffset) Or (Abs(Lon) Mod 6.0 >0.3 And Lon Mod 6.0 < 1.3) Then MGRS_SQUARE = "G" ElseIf temp >= 600000.0 + eastingOffset Then
MGRS_SQUARE = "H"
End If
ElseIf (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 3 = 2) Then
If temp < (eastingOffset) Then MGRS_SQUARE = "J" ElseIf temp >= eastingOffset And temp < 100000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >5.3 And Lon Mod 6.0 < 6.3) Then MGRS_SQUARE = "K" ElseIf temp >= 100000.0 + eastingOffset And temp < 200000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >4.3 And Lon Mod 6.0 < 5.3) Then MGRS_SQUARE = "L" ElseIf temp >= 200000.0 + eastingOffset And temp < 300000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >3.3 And Lon Mod 6.0 < 4.3) Then MGRS_SQUARE = "M" ElseIf temp >= 300000.0 + eastingOffset And temp < 400000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >2.3 And Lon Mod 6.0 < 3.3) Then MGRS_SQUARE = "N" ElseIf temp >= 400000.0 + eastingOffset And temp < 500000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >1.3 And Lon Mod 6.0 < 2.3) Then MGRS_SQUARE = "P" ElseIf temp >= 500000.0 + eastingOffset And temp < 600000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >0.3 And Lon Mod 6.0 < 1.3) Then MGRS_SQUARE = "Q" ElseIf temp >= 600000.0 + eastingOffset Then
MGRS_SQUARE = "R"
End If
ElseIf (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 3 = 0) Then
If temp < (eastingOffset) Then MGRS_SQUARE = "S" ElseIf temp >= eastingOffset And temp < 100000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >5.3 And Lon Mod 6.0 < 6.3) Then MGRS_SQUARE = "T" ElseIf temp >= 100000.0 + eastingOffset And temp < 200000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >4.3 And Lon Mod 6.0 < 5.3) Then MGRS_SQUARE = "U" ElseIf temp >= 200000.0 + eastingOffset And temp < 300000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >3.3 And Lon Mod 6.0 < 4.3) Then MGRS_SQUARE = "V" ElseIf temp >= 300000.0 + eastingOffset And temp < 400000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >2.3 And Lon Mod 6.0 < 3.3) Then MGRS_SQUARE = "W" ElseIf temp >= 400000.0 + eastingOffset And temp < 500000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >1.3 And Lon Mod 6.0 < 2.3) Then MGRS_SQUARE = "X" ElseIf temp >= 500000.0 + eastingOffset And temp < 600000.0 + eastingOffset Or (Abs(Lon) Mod 6.0 >0.3 And Lon Mod 6.0 < 1.3) Then MGRS_SQUARE = "Y" ElseIf temp >= 600000.0 + eastingOffset Then
MGRS_SQUARE = "Z"
End If
End If
' compute the MGRS Square identifier, northing second
temp = UTM_NORTHING Mod 2000000.0
If (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 2 = 1 And CSng(Lat) >= 0.0) Then
If temp >= 0.0 And temp < 100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "A" ElseIf temp >= 100000.0 And temp < 200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "B" ElseIf temp >= 200000.0 And temp < 300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "C" ElseIf temp >= 300000.0 And temp < 400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "D" ElseIf temp >= 400000.0 And temp < 500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "E" ElseIf temp >= 500000.0 And temp < 600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "F" ElseIf temp >= 600000.0 And temp < 700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "G" ElseIf temp >= 700000.0 And temp < 800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "H" ElseIf temp >= 800000.0 And temp < 900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "J" ElseIf temp >= 900000.0 And temp < 1000000.0 Then MGRS_SQUARE = MGRS_SQUARE + "K" ElseIf temp >= 1000000.0 And temp < 1100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "L" ElseIf temp >= 1100000.0 And temp < 1200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "M" ElseIf temp >= 1200000.0 And temp < 1300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "N" ElseIf temp >= 1300000.0 And temp < 1400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "P" ElseIf temp >= 1400000.0 And temp < 1500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "Q" ElseIf temp >= 1500000.0 And temp < 1600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "R" ElseIf temp >= 1600000.0 And temp < 1700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "S" ElseIf temp >= 1700000.0 And temp < 1800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "T" ElseIf temp >= 1800000.0 And temp < 1900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "U" ElseIf temp >= 1900000.0 And temp < 2000000.0 Then MGRS_SQUARE = MGRS_SQUARE + "V" End If ElseIf (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 2 = 0 And Lat >= 0.0) Then
If temp >= 0.0 And temp < 100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "F" ElseIf temp >= 100000.0 And temp < 200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "G" ElseIf temp >= 200000.0 And temp < 300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "H" ElseIf temp >= 300000.0 And temp < 400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "J" ElseIf temp >= 400000.0 And temp < 500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "K" ElseIf temp >= 500000.0 And temp < 600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "L" ElseIf temp >= 600000.0 And temp < 700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "M" ElseIf temp >= 700000.0 And temp < 800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "N" ElseIf temp >= 800000.0 And temp < 900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "P" ElseIf temp >= 900000.0 And temp < 100000.00 Then MGRS_SQUARE = MGRS_SQUARE + "Q" ElseIf temp >= 1000000.0 And temp < 1100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "R" ElseIf temp >= 1100000.0 And temp < 1200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "S" ElseIf temp >= 1200000.0 And temp < 1300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "T" ElseIf temp >= 1300000.0 And temp < 1400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "U" ElseIf temp >= 1400000.0 And temp < 1500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "V" ElseIf temp >= 1500000.0 And temp < 1600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "A" ElseIf temp >= 1600000.0 And temp < 1700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "B" ElseIf temp >= 1700000.0 And temp < 1800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "C" ElseIf temp >= 1800000.0 And temp < 1900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "D" ElseIf temp >= 1900000.0 And temp < 200000.00 Then MGRS_SQUARE = MGRS_SQUARE + "E" End If ElseIf (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 2 = 1 And Lat < 0.0) Then If temp >= 0.0 And temp < 100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "V" ElseIf temp >= 100000.0 And temp < 200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "U" ElseIf temp >= 200000.0 And temp < 300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "T" ElseIf temp >= 300000.0 And temp < 400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "S" ElseIf temp >= 400000.0 And temp < 500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "R" ElseIf temp >= 500000.0 And temp < 600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "Q" ElseIf temp >= 600000.0 And temp < 700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "P" ElseIf temp >= 700000.0 And temp < 800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "N" ElseIf temp >= 800000.0 And temp < 900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "M" ElseIf temp >= 900000.0 And temp < 100000.00 Then MGRS_SQUARE = MGRS_SQUARE + "L" ElseIf temp >= 100000.00 And temp < 1100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "K" ElseIf temp >= 1100000.0 And temp < 1200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "J" ElseIf temp >= 1200000.0 And temp < 1300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "H" ElseIf temp >= 1300000.0 And temp < 1400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "G" ElseIf temp >= 1400000.0 And temp < 1500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "F" ElseIf temp >= 1500000.0 And temp < 1600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "E" ElseIf temp >= 1600000.0 And temp < 1700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "D" ElseIf temp >= 1700000.0 And temp < 1800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "C" ElseIf temp >= 1800000.0 And temp < 1900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "B" ElseIf temp >= 1900000.0 And temp < 200000.00 Then MGRS_SQUARE = MGRS_SQUARE + "A" End If ElseIf (CInt(Left(UTM_ZONE, Len(UTM_ZONE) - 1)) Mod 2 = 0 And Lat < 0.0) Then If temp >= 0.0 And temp < 100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "E" ElseIf temp >= 100000.0 And temp < 200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "D" ElseIf temp >= 200000.0 And temp < 300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "C" ElseIf temp >= 300000.0 And temp < 400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "B" ElseIf temp >= 400000.0 And temp < 500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "A" ElseIf temp >= 500000.0 And temp < 600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "V" ElseIf temp >= 600000.0 And temp < 700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "U" ElseIf temp >= 700000.0 And temp < 800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "T" ElseIf temp >= 800000.0 And temp < 900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "S" ElseIf temp >= 900000.0 And temp < 100000.00 Then MGRS_SQUARE = MGRS_SQUARE + "R" ElseIf temp >= 100000.00 And temp < 1100000.0 Then MGRS_SQUARE = MGRS_SQUARE + "Q" ElseIf temp >= 1100000.0 And temp < 1200000.0 Then MGRS_SQUARE = MGRS_SQUARE + "P" ElseIf temp >= 1200000.0 And temp < 1300000.0 Then MGRS_SQUARE = MGRS_SQUARE + "N" ElseIf temp >= 1300000.0 And temp < 1400000.0 Then MGRS_SQUARE = MGRS_SQUARE + "M" ElseIf temp >= 1400000.0 And temp < 1500000.0 Then MGRS_SQUARE = MGRS_SQUARE + "L" ElseIf temp >= 1500000.0 And temp < 1600000.0 Then MGRS_SQUARE = MGRS_SQUARE + "K" ElseIf temp >= 1600000.0 And temp < 1700000.0 Then MGRS_SQUARE = MGRS_SQUARE + "J" ElseIf temp >= 1700000.0 And temp < 1800000.0 Then MGRS_SQUARE = MGRS_SQUARE + "H" ElseIf temp >= 1800000.0 And temp < 1900000.0 Then MGRS_SQUARE = MGRS_SQUARE + "G" ElseIf temp >= 1900000.0 And temp < 200000.00 Then
MGRS_SQUARE = MGRS_SQUARE + "F"
End If
End If
MGRSString = CStr(UTM_ZONE) + " " + CStr(MGRS_SQUARE) + " " + CStr(UTM_EASTING Mod 100000.0) + " " + CStr(UTM_NORTHING Mod 100000.0)
End Sub

Private Sub ConvertNMEAToUTM(ByVal NMEAString As String, ByRef UTMString As String)
Dim UTM_NORTHING As Single
Dim UTM_EASTING As Single
Dim UTM_ZONE As String
Dim Lat As Single
Dim Lon As Single
Call ParseDegreeDecimalFromNMEA(NMEAString, Lat, Lon)
Call LatLonToUTM(Lat, Lon, UTM_NORTHING, UTM_EASTING, UTM_ZONE)
UTMString = CStr(UTM_ZONE) + " " + CStr(UTM_EASTING) + " " + CStr(UTM_NORTHING)
End Sub

The code as posted is free for non-commercial use. If used for commercial purposes, please contact szczepaniec@tactical-sc.com for limitations. Thanks.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Back-end build error

Post by dkinzer »

meenbombs wrote:When I try to compile it for the ZX-328l (or any native device) I get [an] error
The code that you posted compiles here with no errors using v2.7.0 of the compiler. It may be a certain setting in the project file is needed to cause the error or perhaps it is an installation problem. If you could reply with an attachment containing both the .bas file and the .pjt file that may be helpful.

Also, the --keep-files option will leave the back-end compiler intermediate files in place, allowing you to see the actual error message generated by the back-end compiler. Although you might not understand what those messages mean, they might allow us to deduce the cause of the problem. An alternative is to also include the --verbose option. This will cause the error output from the back-end compiler to be displayed in the Output window.

P.S. When posting code, wrapping the code text with code tags will preserve the formatting/indentation. The easiest way to accomplish this is to paste the code, select it using the mouse and then click the "Code" button below the Subject box.

[edit] Due to a silly error on my part, I retract the claim that the code compiles fine here. I haven't yet been able to compile it because of the formatting issues in the posted code.
Last edited by dkinzer on 08 June 2009, 7:07 AM, edited 1 time in total.
- Don Kinzer
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

Judging by the code the contract programmer is new at programming as well. There are no lookup tables for data, no constants, not very good structure, repetitive code, and no comments. The performance isn't going to be that great either because of the use of String parsing rather than using byte arrays.

The problem you reported is because the code attempts to use the Mod operator with a floating point value and the ZBasic compiler generates the incorrect backend code. See line 205 for example:

Code: Select all

ElseIf &#40;temp >= eastingOffset And temp < 100000.0 + eastingOffset&#41; Or &#40;Abs&#40;Lon&#41; Mod 6.0 > 5.3 And Lon Mod 6.0 < 6.3&#41; Then
The "Mod 6.0" part is the code causing the error.

A quick workaround is to use a function like this to calculate floating point mod values:

Code: Select all

Function FloatingPointMod&#40;ByVal leftOp as Single, ByVal rightOp as Single&#41; as Single
	FloatingPointMod = leftOp - Floor&#40;leftOp/rightOp&#41; * rightOp
End Function
Mike Perks
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: Back-end build error

Post by mikep »

dkinzer wrote:When posting code, wrapping the code text with code tags will preserve the formatting/indentation. The easiest way to accomplish this is to paste the code, select it using the mouse and then click the "Code" button below the Subject box.
Or you can post the file(s) as an attachment, if it is more than a snippet.
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

mikep wrote:The problem you reported is because the code attempts to use the Mod operator with a floating point value and the ZBasic compiler generates the incorrect backend code.
We have identified the source of the problem and a solution. Preliminary testing indicates that the solution is effective and, due to the nature of the change, it is relatively unlikely to have undesired side effects. We can post an experimental release (i.e. not yet fully tested) if it would be useful.
- Don Kinzer
meenbombs
Posts: 35
Joined: 20 November 2008, 15:54 PM

Thanks for the help

Post by meenbombs »

I forwarded the suggested fix to the programmer and he returned the project with no compile errors. I will test the code in the actual device tomorrow to make sure it all works. Thanks for the help and should I post code in the future I will take the suggestions you have given me.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

dkinzer wrote:We have identified the source of the problem and a solution.
The updated compiler in the new installer, available on the Downloads Page, corrects this issue.
- Don Kinzer
Post Reply