我也是今天剛接觸mapbasic,屬于初學(xué)者,準(zhǔn)備認(rèn)真的學(xué)習(xí)一下,與希望和其他朋友交流一下。
本文的目的是和其他初學(xué)者共同學(xué)習(xí),探討交流。
本文里面如果出現(xiàn)錯(cuò)誤與不足還請(qǐng)高手門指出與糾正,謝謝!
---------------------------------------------------
第一節(jié) 函數(shù)的定義與主函數(shù)
-------------------------------------------------
Include "MapBasic.Def"'頭文件,MAPBAISC 開頭必須引入MapBasic.Def否則無法執(zhí)行MapBasic的語句和函數(shù)
Declare Sub Main '聲明的主函數(shù),下面的一樣都是功能函數(shù),
具體實(shí)現(xiàn)與功能以后會(huì)詳細(xì)講解,這里就不說了。
Declare Sub MnuHelp
Declare Sub MnuAbout
Declare Sub MnuExit
Declare Sub SetMsgWin
Declare Sub MnuKML_ConvertMap
Declare Sub KML_ConvertMap (ByVal nMap As Integer, ByVal sOutputFile As String)
Dim sErrorMsg As String
Sub Main
Create Menu "&Mapinfo2Google" As' 建立新目錄菜單,&M表示快捷鍵
"&Convert map window to KML file..." Calling MnuKML_ConvertMap, '當(dāng)點(diǎn)擊Convert map window to KML file...
調(diào)用MnuKM L_ConvertMap
"(-", '顯示橫杠
"&Help" Calling MnuHelp,'幫助,&H表示快捷鍵
"&About Mapinfo2Google..." Calling MnuAbout,'關(guān)于,&A表示快捷鍵
"E&xit Mapinfo2Google" Calling MnuExit'退出,&x表示快捷鍵
Alter Menu Bar Add "&Mapinfo2Google" '改變菜單條,簡單的說就是在MAPINFO最上面添加Mapinfo2Google的按鈕
End Sub
'-------------------- Menu Routines -------------------------------------
Sub MnuAbout
Note "Mapinfo to Google Earth Map Converter" & Chr$(10) & Chr$(10)'About Mapinfo2Google 里的內(nèi)容,& Chr$(10) 是 回車的意思。
& "Mapinfo2Google.mbx" & Chr$(10)
& "Version 1.2.1 (8th August, 2005)" & Chr$(10)
& "Copyright ?2005 by Cy Carter" & Chr$(10)
& "This is free software distributed under the terms of the GNU General" & Chr$(10)
& "Public License. See
http://www.gnu.org/licenses/licenses.html"
End Sub
sub MnuHelp'help里的內(nèi)容。
Note "HELP for program Mapinfo2Google " & Chr$(10) & Chr$(10)
& "Exports all visible layers except Rasters, Cosmetic or Thematic " & Chr$(10)
& "from the current map window to a Goggle Earth KML file." & Chr$(10) & Chr$(10)
& "Use Labels of a BASE table to assign a name to each object if required." & Chr$(10)
& "Only objects with centroid within the map window are exported." & Chr$(10)
End Sub
Sub MnuExit
End Program
End Sub
以上的內(nèi)容沒有什么難度的,只要學(xué)過 VC或者VB的應(yīng)該一看就懂。
今天就寫到這里,困了!近期會(huì)有下文,謝謝支持。
以上講的代碼在MAPINFO的所生成的作用就是,下圖
[
本帖最后由 whoami926 于 2008-3-5 09:24 編輯 ]