Hello again List
Further to my previous post on this moving-duplication problem, I
include the orig. message, below, plus some more details:
My problem is that I was moving objects around and somehow I ended up
with 3 recs the same (one hidden underneath another, such that there
only appeared to be 2). At the time I probably had the Info dialog open,
as I was testing my software's ability to change the lat/long integer
fields, according to the x/y where the object ended up, at Save time. I
have not been able to reproduce this "glitch", nor did I notice when it
happened.
Anyone got any ideas how this can happen ?
Thing is, there's no code involved in the moving of the objects; I
merely allow that layer to be editable (thererfore the objects movable).
When the user clicks on "save" I loop through the table, checking if any
of the stored numerical X and Y co-ords are different from those of the
graphical objects and, if they are (showing that the object has moved),
setting them to the new position's X/Y. I also check if an object (a
Facility) has been moved into another zone (another layer of irregular
polygons) and, if so, change the Faciliy's stored Zone.
Andrew Hare, some time back, said he'd had similar duplicate frecs
created hen he had the Info Tool open. When I was testing the rewriting
of moved X/Y vals I had my Info tool open at some time(s) but I don't
know if this has any bearing, and Andrew was inserting data when his
problem happened.
Below is the "save" code:
'________________________________________________
Sub SAVE_FAC_MAST
'________________
Dim loObj as Object,
lnZoneNo as SmallInt,
lnNewX, lnNewY as Integer
If ASK( "Save changes to position(s) of Facility(ies)?", "Yes", "No")
then
Print "Saving changes to position(s) of Facility(ies) ..."
Fetch first from FacMast
Do while not EOT( FacMast)
loObj = FacMast.Obj
lnNewX = INT( ROUND( CentroidX(
loObj), 1))
lnNewY = INT( ROUND( CentroidY(
loObj), 1))
If lnNewX <> FacMast.XCo_ord
Or lnNewY <> FacMast.YCo_ord then ' If centroid
X/Y different from stored X/Y (E & N)
lnRowID = FacMast.RowID
Set CoordSys Table FacMast
Update FacMast
Set YCo_ord = lnNewY,
XCo_ord = lnNewX
where RowID = lnRowID ' Change the N/E
values to the new Y/X coords in the OBJ
Select ZoneNumber from BusZoner
where loObj within BusZoner.Obj
into csrTemp NOSELECT ' What if
Facility moved over a Zone boundary?
lnZoneNo = csrTemp.ZoneNumber
Close Table csrTemp
If FacMast.Zone <> lnZoneNo then ' .. It HAS
moved to new zone
Update FacMast
Set Zone = lnZoneNo
where RowID = lnRowID ' Store new Zone
# in FacMast
End If
End If
Fetch Next from FacMast
Loop
Close Window Message
Set Map Layer "FacMast"
Selectable On
Editable off Label Visibility Zoom( 0, 1) Units "km"
Commit table FacMast
End if
End Sub
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l