I have made a loop in MapBasic but is it only updating every other row in the table:
My code works from the bottom of the table upwards to generate start and end coordinates for polyline features:
Dim nrows as integer
Dim USX, USY, UEX, UEY as float
For nrows = TableInfo(WorTab, TAB_INFO_NROWS) to 1 Step - 1
Select * from WorTab where rowid = nrows
Dim ObjTYPE as integer
ObjType = ObjectInfo(Selection.obj, OBJ_INFO_TYPE)
If ObjType = 4 then
nPoints = ObjectInfo(Selection.obj, OBJ_INFO_NPNTS)
USX = ObjectNodeX(Selection.Obj,1,1)
USY = ObjectNodeY(Selection.Obj,1,1)
UEX = ObjectNodeX(Selection.Obj,1,nPoints)
UEY = ObjectNodeY(Selection.Obj,1,nPoints)
Update Selection Set SX = USX, SY = USY, EX = UEX, EY = UEY
nrows = nrows -1
Close Table Selection
Else
End if
I'd be very grateful if somebody could point out what I'm doing wrong and why nrows -1 is the wrong choice.