Mapinfo同一个表里怎么把一个对象的多个字段属性一次性复制到另一个对象的对应字段里啊?

如题,急!实际操作有效的话追加分!... 如题,急!实际操作有效的话追加分! 展开
 我来答
鸣乐清风
2010-01-14 · TA获得超过886个赞
知道小有建树答主
回答量:362
采纳率:0%
帮助的人:370万
展开全部
用mapbasic把下面这段代码copy,只需要修改标识的部分就可以了。

include "MapBasic.def"
include "ICONS.DEF"
include "menu.def"

Declare sub main
Declare sub Mcopy
Declare sub Mpaste

'下面的结构体要修改成跟你的表结构一致
Type RowRecord
id As integer
age As float
name As String
End Type
’以上修改

Global r_copy As RowRecord

sub main

Create ButtonPad "Utils" As
ToolButton
HelpMsg "Choose this button to display query dialog"
Calling Mcopy ID 1
Icon MI_ICON_COPY
DrawMode DM_CUSTOM_POINT
ToolButton
HelpMsg "Use this tool to draw a new route"
Calling Mpaste ID 2
Icon MI_ICON_PASTE
DrawMode DM_CUSTOM_POINT

Title "Utilities"
Width 2
Show
end sub

sub Mcopy
Dim x, y, x2, y2 As Float,
i, i_found, i_row_id, i_win_id As Integer,
s_table As Alias
i_win_id = FrontWindow()
If WindowInfo(i_win_id, WIN_INFO_TYPE) <> WIN_MAPPER Then
Note "This tool only works on Map windows."
Exit Sub
End If

' Determine the starting point where the user clicked.
x = CommandInfo(CMD_INFO_X)
y = CommandInfo(CMD_INFO_Y)

If CommandInfo(CMD_INFO_TOOLBTN) = 1 Then
' Then the user is using the point-mode tool.
' determine how many objects are at the chosen point.
i_found = SearchPoint(i_win_id, x, y)
Else
' The user is using the rectangle-mode tool.
' Determine what objects are within the rectangle.
x2 = CommandInfo(CMD_INFO_X2)
y2 = CommandInfo(CMD_INFO_y2)
i_found = SearchRect(i_win_id, x, y, x2, y2)
End If

If i_found = 0 Then
Beep ' No objects found where the user clicked.
Else
Print Chr$(12)
If CommandInfo(CMD_INFO_TOOLBTN) = 2 Then
Print "Rectangle: x1= " + x + ", y1= " + y
Print "x2= " + x2 + ", y2= " + y2
Else
Print "Point: x=" + x + ", y= " + y
End If

' Process the search results.
For i = 1 to i_found
' Get the name of the table containing a "hit".
s_table = SearchInfo(i, SEARCH_INFO_TABLE)
' note s_table

' Get the row ID number of the object that was a hit.
i_row_id = SearchInfo(i, SEARCH_INFO_ROW)

If Left$(s_table, 8) = "Cosmetic" Then
Print "Object in Cosmetic layer"
Else
' Fetch the row of the object the user clicked on.
Fetch rec i_row_id From s_table
'下面要修改,改成跟你表结构一样的列名字,列的数目也要一致
s_table = SearchInfo(i, SEARCH_INFO_TABLE)
s_table = s_table + ".col1"
r_copy.id = s_table

s_table = SearchInfo(i, SEARCH_INFO_TABLE)
s_table = s_table + ".col2"
r_copy.age = s_table

s_table = SearchInfo(i, SEARCH_INFO_TABLE)
s_table = s_table + ".col3"
r_copy.name = s_table

'以上
Print "复制完毕"

End If
Next
End If

end sub

sub Mpaste
Dim x, y, x2, y2 As Float,
i, i_found, i_row_id, i_win_id As Integer,
s_table As Alias
i_win_id = FrontWindow()
If WindowInfo(i_win_id, WIN_INFO_TYPE) <> WIN_MAPPER Then
Note "This tool only works on Map windows."
Exit Sub
End If

' Determine the starting point where the user clicked.
x = CommandInfo(CMD_INFO_X)
y = CommandInfo(CMD_INFO_Y)
If CommandInfo(CMD_INFO_TOOLBTN) = 2 Then
' Then the user is using the point-mode tool.
' determine how many objects are at the chosen point.
i_found = SearchPoint(i_win_id, x, y)
Else
' The user is using the rectangle-mode tool.
' Determine what objects are within the rectangle.
x2 = CommandInfo(CMD_INFO_X2)
y2 = CommandInfo(CMD_INFO_y2)
i_found = SearchRect(i_win_id, x, y, x2, y2)
End If

If i_found = 0 Then
Beep ' No objects found where the user clicked.
Else
Print Chr$(12)
If CommandInfo(CMD_INFO_TOOLBTN) = 1 Then
Print "Rectangle: x1= " + x + ", y1= " + y
Print "x2= " + x2 + ", y2= " + y2
Else
Print "Point: x=" + x + ", y= " + y
End If

' Process the search results.
For i = 1 to i_found
' Get the name of the table containing a "hit".
s_table = SearchInfo(i, SEARCH_INFO_TABLE)

' Get the row ID number of the object that was a hit.
i_row_id = SearchInfo(i, SEARCH_INFO_ROW)

If Left$(s_table, 8) = "Cosmetic" Then
Print "Object in Cosmetic layer"
Else
' Fetch the row of the object the user clicked on.
Fetch rec i_row_id From s_table

'以下要修改,结构跟表结构一样
Update s_table Set col1 = r_copy.id
Where RowID = i_row_id
Update s_table Set col2=r_copy.age
Where RowID = i_row_id
Update s_table Set col3=r_copy.name
Where RowID = i_row_id

'以上

End If
Next
End If

end sub

参考资料: mapbasic帮助

njdxtj
2010-01-06 · TA获得超过2130个赞
知道小有建树答主
回答量:1417
采纳率:35%
帮助的人:449万
展开全部
据我所知,不能实现这个功能,除非你写个小工具。
mapinfo支持全复制粘贴,好像不能选取字段粘贴吧?
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式