Nhờ các anh chị giúp đỡ về mapbasic

Thảo luận trong 'Lập trình trong MapInfo' bắt đầu bởi dr4g0nwhjt3, 11/4/15.

  1. dr4g0nwhjt3

    dr4g0nwhjt3 New Member

    Tham gia ngày:
    1/12/14
    Bài viết:
    16
    Đã được thích:
    0
    Điểm thành tích:
    0
    Nghề nghiệp:
    Sinh viên
    Nơi ở:
    Gia Lai
    Cho em hỏi xí ạ. Sao em copy dãy code trên mạng về rồi bỏ vào mapbasic compile thì xuất hiện một vài lỗi (trong khi dãy code đó là hoàn toàn đúng) như là: mapbasic.def not found, menu.def not found, Invalid sub procedura name: M_FILE_EXIT. Vì em mới tiếp cận mapbasic nên mong anh chị giúp đỡ ạ
     
    Tags:
  2. homesick_vfu

    homesick_vfu Member

    Tham gia ngày:
    20/4/13
    Bài viết:
    110
    Đã được thích:
    0
    Điểm thành tích:
    16
    có thể vui lòng share code được k bạn. !
    m.n chỉ cho...
     
  3. poorbaby

    poorbaby Member

    Tham gia ngày:
    21/10/11
    Bài viết:
    369
    Đã được thích:
    11
    Điểm thành tích:
    18
    Nghề nghiệp:
    RS_GIS
    Nơi ở:
    Ha Noi
    Chắc là do bạn chưa khai báo menu, sub cho nó. Thử thêm vào mấy dòng này ở đầu:

    Include "MapBasic.def"
    Include "Menu.def"
    Declare Sub M_FILE_EXIT
     
  4. dr4g0nwhjt3

    dr4g0nwhjt3 New Member

    Tham gia ngày:
    1/12/14
    Bài viết:
    16
    Đã được thích:
    0
    Điểm thành tích:
    0
    Nghề nghiệp:
    Sinh viên
    Nơi ở:
    Gia Lai
    Do code dài quá nên em ko đưa lên ạ. Code này em cũng lấy từ diễn đàn về, compile thử nhưng lại có thông báo lỗi là không tìm thấy mấy thứ đó. Code đây ạ:
    p/s: Ngoài mấy lỗi trên ra còn có 2 lỗi nữa, anh chị compile thử sẽ thấy hiện ra ạ.
    Nhờ mấy anh chị giúp ạ
    Include "mapbasic.def"
    Include "menu.def"
    Type Matranb4
    h1 as float
    h2 as float
    h3 as float
    h4 as float
    End Type
    Type Diem
    tendiem as string
    x as float
    y as float
    vx as float
    vy as float
    svx as float
    svy as float
    End Type
    Type Tamgiac

    Tendiem as string
    d1 as integer
    d2 as integer
    d3 as integer


    End Type


    Declare Sub Main
    Declare Sub Thoat
    Declare Sub HienDiem
    Declare Sub TaoTableMoi
    Declare Sub Tocdodichchuyen(x as float,y as float,vx as float , vy as float , svx as float , svy as float,tle as float)
    Declare Sub Vemuiten(x as float , y as float,e1 as float,e2 as float, g as float ,tle as float)
    Declare Sub Biendangxoay(x as float , y as float, w as float)
    Declare Sub InMatran(MTIN() as Matranb4,tenfile as string)
    Declare Sub BienDang
    Declare Sub NhanMT( MT1() as Matranb4, MT2() as Matranb4, MTKQ() as Matranb4)
    Declare Sub ChuyenDuLieuMatran( MTDL() as Diem,VIJ() as Matranb4,A() as Matranb4,MS() as Matranb4)
    Declare Sub Ngichdao(MTBD() as Matranb4 , MTND() as Matranb4)
    Declare Sub Chuyenvi(MTBD() as Matranb4, MTCV() as Matranb4)
    Declare Sub Det33(MT3() as Matranb4,det as float)
    Declare Sub Det44(MT4() as Matranb4,det as float)
    Declare Sub Laydulieutamgiac(TGD() as Tamgiac)
    Declare Sub Thehiendiem(DI() as Diem)
    Declare Sub Trongtam(DDI() as Diem,xg as float,yg as float)
    Global DI() as Diem
    Global TG() as Tamgiac
    Global tile as integer
    Global Filename as String
    Sub Main()
    tile=5000000
    Create Menu "Tinh" As
    "Tao Table Lon/Lat" Calling TaoTableMoi,
    "(Hien Thi Diem" Calling HienDiem,
    "(Tinh Bien Dang" Calling BienDang
    Create Menu "Tinh Bien Dang" As
    "Tinh" As "Tinh",
    "(-",
    "Ket Thuc C.Trinh" Calling Thoat,
    "Thoat" Calling M_FILE_EXIT
    Alter Menu Bar Add "Tinh Bien Dang"


    End Sub


    Sub Thoat

    End Program


    End Sub
    Sub TaoTableMoi
    Close All Interactive
    Create Table "lonlat" (Field1 Char(10)) file "C:\Users\Phongtran\Documents\lonlat.tab" TYPE NATIVE Charset "WindowsVietnamese"
    Create Map For lonlat CoordSys Earth Projection 1, 0
    Map From lonlat
    Set Map Layer 1 Editable On
    Alter Menu Item HienDiem Enable
    Alter Menu Item TaoTableMoi Disable
    End Sub


    Sub HienDiem
    Filename=FileOpenDlg("","","XLS","Hay nhap file so lieu cho tinh bien dang")
    Register Table Filename
    Type "XLS"
    Into "C:\BienDang.Tab"


    Dim awin as integer
    Dim tenlop as String
    awin=frontwindow()
    tenlop=LayerInfo(awin,1,LAYER_INFO_NAME)
    if tenlop<>"Cosmetic1" then
    Set Coordsys table tenlop
    Set Map Layer 1 Editable on
    else
    tenlop=LayerInfo(1,2,LAYER_INFO_NAME)
    Set Coordsys table tenlop
    Set Map Layer 2 Editable on
    End if


    Dim i as integer
    i=1
    Redim DI(i)
    Open table "C:\BienDang.Tab"
    Fetch First From BienDang
    DI(i).tendiem = BienDang.col1
    DI(i).x= BienDang.col2
    DI(i).y= BienDang.col3
    DI(i).vx= BienDang.col4
    DI(i).vy= BienDang.col5
    DI(i).svx= BienDang.col6
    DI(i).svy= BienDang.col7


    Do while not EOT(BienDang)


    DI(i).tendiem = BienDang.col1
    DI(i).x= BienDang.col2
    DI(i).y= BienDang.col3
    DI(i).vx= BienDang.col4
    DI(i).vy= BienDang.col5
    DI(i).svx= BienDang.col6
    DI(i).svy= BienDang.col7


    i=i + 1
    Redim DI(i)


    Fetch Next From BienDang
    Loop
    Call Thehiendiem(DI())
    Close Table BienDang
    Alter Menu Item BienDang Enable
    Alter Menu Item HienDiem Disable
    Alter Menu Item TaoTableMoi Disable
    End Sub




    Sub BienDang


    Dim x,y,vx,vy,svx,svy,ex,ey,exy,e1,e2,w,g as float
    Dim i,max as integer
    max= ubound(DI) -1
    Call Laydulieutamgiac(TG())
    Dim DDI() as Diem
    ReDim DDI(3)
    Dim d as integer
    Dim tle as float
    tle = tile/10
    Dim se1,se2,sw,sg,sex,sey,sexy,xg,yg as float
    Dim V() ,A(),NA(),MTN(),MS(),MTN1() as Matranb4
    Dim st2,st3,st4,st6,st7,st8 as string*15
    Dim st,st1,st5,st9 as string*8
    Open File "ketqua.txt" for Output as #1
    Print #1, "TenDagiac"+" "+" LON "+" " + " LAT "+" " + "BienDangXoay_W"+" "+ " SaiSo_W "
    Print #1, " Name "+" "+ " (Độ) "+" " + " (Độ) "+" " + " (Radian/Năm) "+" "+ " (Radian/Năm) "
    For i=1 to (ubound(TG)-1)


    If (TG(i).d1 = TG(i).d2) or (TG(i).d1 = TG(i).d3) or (TG(i).d3 = TG(i).d2) then
    Print #1, "Tam giac duoc chon co 2 hoac 3 diem trung nhau "
    ElseIf (TG(i).d1 <= 0) or (TG(i).d2 <= 0) or (TG(i).d3 <= 0)or (TG(i).d1 > max)or (TG(i).d2 > max) or (TG(i).d3 > max) then
    Print #1, "Tam giac duoc chon khong phu hop do ngoai gia tri so diem trong luoi "
    Else
    d = TG(i).d1


    DDI(1).tendiem = DI(d).tendiem
    DDI(1).x=DI(d).x
    DDI(1).y=DI(d).y
    DDI(1).vx=DI(d).vx
    DDI(1).vy=DI(d).vy
    DDI(1).svx=DI(d).svx
    DDI(1).svy=DI(d).svy


    d = TG(i).d2


    DDI(2).tendiem = DI(d).tendiem
    DDI(2).x=DI(d).x
    DDI(2).y=DI(d).y
    DDI(2).vx=DI(d).vx
    DDI(2).vy=DI(d).vy
    DDI(2).svx=DI(d).svx
    DDI(2).svy=DI(d).svy


    d = TG(i).d3

    DDI(3).tendiem = DI(d).tendiem
    DDI(3).x=DI(d).x
    DDI(3).y=DI(d).y
    DDI(3).vx=DI(d).vx
    DDI(3).vy=DI(d).vy
    DDI(3).svx=DI(d).svx
    DDI(3).svy=DI(d).svy


    Call Trongtam(DDI(),xg,yg)
    Create text
    TG(i).tendiem
    (xg , yg) (xg + 0.2,yg + 0.2)
    Font MakeFont ("Helvetica",1,12,Black,Green)


    Call ChuyenDuLieuMatran( DDI() , V() ,A(),MS())
    Call Ngichdao(A(),NA())
    Call NhanMT(NA(),V(), MTN())
    Call NhanMT(NA(),MS(),MTN1())


    ex=MTN(1).h1
    ey=MTN(1).h4
    exy = ( MTN(1).h2 + MTN(1).h3)/2
    e1= (ex+ey)/2 + sqr(exy^2 + ((ex-ey)/2)^2)
    e2= (ex+ey)/2 - sqr(exy^2 + ((ex-ey)/2)^2)
    w= ( MTN(1).h2 - MTN(1).h3)/2
    g=atn(2*exy/(ey-ex))/2
    g=g*(180/3.141)

    sex=abs(MTN1(1).h1)
    sey=abs(MTN1(1).h4)
    sexy = ( abs(MTN1(1).h2) + abs(MTN1(1).h3))/2
    se1= (sex+sey)/2 + sqr(sexy^2 + ((sex+sey)/2)^2)
    se2= abs((sex+sey)/2 - sqr(sexy^2 + (abs(sex-sey)/2)^2))
    sw= abs( abs(MTN1(1).h2) - abs(MTN1(1).h3))/2
    sg=atn(2*sexy/abs(sey-sex))/2
    sg=sg*(180/3.141)
    st= Str$(xg)
    st1= Str$(yg)
    st2= Str$(e1)
    st3= Str$(e2)
    st4= Str$(w)
    st5= Str$(g)
    st6= Str$(se1)
    st7= Str$(se2)
    st8= Str$(sw)
    st9= Str$(sg)
    Print #1, TG(i).Tendiem + " "+ st + " " + st1 + " " +" " + st4 +" " + st8
    g = -g
    ' Call Vemuiten(xg,yg,e1,e2,g,tle)
    Call Biendangxoay(xg,yg,w)
    End If


    Next


    Close File #1


    Alter Menu Item BienDang Disable
    Alter Menu Item HienDiem Enable
    End Sub




    '...................................................................................................


    Sub Trongtam(DDI() as Diem,xg as float,yg as float)
    xg =0
    yg =0
    Dim i as integer
    For i=1 to 3
    xg = xg + DDI(i).x
    yg = yg + DDI(i).y
    If i = 3 then
    Create Line ( DDI(i).x , DDI(i).y ) ( DDI(1).x , DDI(1).y )
    Pen MakePen (1,2,Red)
    Else
    Create Line ( DDI(i).x , DDI(i).y ) ( DDI(i+1).x , DDI(i+1).y )
    Pen MakePen (1,2,Red)
    End If


    Next
    xg = xg/3
    yg = yg/3
    Create Point (xg,yg)
    Symbol (34,Red,8)


    End Sub




    '....................................................................................................


    Sub Thehiendiem(DI() as Diem)


    Dim i as integer
    Dim tl as float
    Dim hoi as logical
    tl=5/50
    Dim ten as string
    For i=1 to (ubound(DI)-1)
    Create Point (DI(i).x,DI(i).y)
    Symbol (34,Black,5)
    ten = DI(i).tendiem
    Create text
    ten
    (DI(i).x , DI(i).y) (DI(i).x + 0.2,DI(i).y + 0.2)
    Font MakeFont ("Helvetica",1,12,BLUE,WHITE)
    Next
    Hoi = Ask( " Ban co muon the hien toc do dich chuyen","Co","Khong")
    If Hoi = True then
    For i=1 to (ubound(DI)-1)
    Call Tocdodichchuyen(DI(i).x , DI(i).y ,DI(i).vx , DI(i).vy ,DI(i).svx , DI(i).svy ,tl)
    Next
    End If
    End Sub








    '....................................................................................................
    Sub Laydulieutamgiac(TGD() as Tamgiac)


    Filename=FileOpenDlg("","","XLS","Hay nhap file so lieu cho chon tam giac")
    Register Table Filename
    Type "XLS"
    Into "C:\Chontamgiac.Tab"
    Dim i as integer
    i=1
    Redim TGD(i)
    Open table "C:\Chontamgiac.Tab"
    Fetch First From Chontamgiac
    TGD(i).Tendiem = Chontamgiac.col1
    TGD(i).d1 = Chontamgiac.col2
    TGD(i).d2 = Chontamgiac.col3
    TGD(i).d3 = Chontamgiac.col4


    Do while not EOT(Chontamgiac)

    TGD(i).Tendiem = Chontamgiac.col1
    TGD(i).d1 = Chontamgiac.col2
    TGD(i).d2 = Chontamgiac.col3
    TGD(i).d3 = Chontamgiac.col4


    i=i + 1
    Redim TGD(i)


    Fetch Next From Chontamgiac
    Loop
    Close Table Chontamgiac
    End Sub


    '.......................................................................................................
    Sub ChuyenDuLieuMatran( MTDL() as Diem,VIJ() as Matranb4,A() as Matranb4,MS() as Matranb4)


    Redim MS(1)
    Redim VIJ(1)
    Redim A(4)
    VIJ(1).h1=(MTDL(1).vx - MTDL(2).vx)/1000
    VIJ(1).h2=(MTDL(1).vy - MTDL(2).vy)/1000
    VIJ(1).h3=(MTDL(1).vx - MTDL(3).vx)/1000
    VIJ(1).h4=(MTDL(1).vy - MTDL(3).vy)/1000

    MS(1).h1=abs((MTDL(1).svx - MTDL(2).svx)/1000)
    MS(1).h2=abs((MTDL(1).svy - MTDL(2).svy)/1000)
    MS(1).h3=abs((MTDL(1).svx - MTDL(3).svx)/1000)
    MS(1).h4=abs((MTDL(1).svy - MTDL(3).svy)/1000)


    Dim kx12,ky12,kx13,ky13 as float

    kx12 = distance(MTDL(1).x,MTDL(1).y,MTDL(2).x,MTDL(1).y,"m")
    ky12 = distance(MTDL(1).x,MTDL(1).y,MTDL(1).x,MTDL(2).y,"m")


    kx13 = distance(MTDL(1).x,MTDL(1).y,MTDL(3).x,MTDL(1).y,"m")
    ky13 = distance(MTDL(1).x,MTDL(1).y,MTDL(1).x,MTDL(3).y,"m")

    If MTDL(2).x > MTDL(1).x then
    kx12 = -kx12
    End If
    If MTDL(2).y > MTDL(1).y then
    ky12 = -ky12
    End If


    If MTDL(3).x > MTDL(1).x then
    kx13 = -kx13
    End If
    If MTDL(3).y > MTDL(1).y then
    ky13 = -ky13
    End If


    A(1).h1 = kx12
    A(2).h1 = ky12
    A(3).h2 = kx12
    A(4).h2 = ky12


    A(1).h3 = kx13
    A(2).h3 = ky13
    A(3).h4 = kx13
    A(4).h4 = ky13




    End Sub


    '................................................................................................
    Sub NhanMT( MT11() as Matranb4, MT22() as Matranb4, MTN() as Matranb4)






    Dim k1,k2,k3,k4 as float
    Dim i,s as integer
    s = ubound(MT22)
    Redim MTN(s)
    For i = 1 to ubound(MT22)
    k1 = MT11(1).h1 * MT22(i).h1
    k2 = MT11(2).h1 * MT22(i).h2
    k3 = MT11(3).h1 * MT22(i).h3
    k4 = MT11(4).h1 * MT22(i).h4
    MTN(i).h1 = k1+k2+k3+k4
    Next


    For i = 1 to ubound(MT22)
    k1 = MT11(1).h2 * MT22(i).h1
    k2 = MT11(2).h2 * MT22(i).h2
    k3 = MT11(3).h2 * MT22(i).h3
    k4 = MT11(4).h2 * MT22(i).h4
    MTN(i).h2 = k1+k2+k3+k4
    Next


    For i = 1 to ubound(MT22)
    k1 = MT11(1).h3 * MT22(i).h1
    k2 = MT11(2).h3 * MT22(i).h2
    k3 = MT11(3).h3 * MT22(i).h3
    k4 = MT11(4).h3 * MT22(i).h4
    MTN(i).h3 = k1+k2+k3+k4
    Next


    For i = 1 to ubound(MT22)
    k1 = MT11(1).h4 * MT22(i).h1
    k2 = MT11(2).h4 * MT22(i).h2
    k3 = MT11(3).h4 * MT22(i).h3
    k4 = MT11(4).h4 * MT22(i).h4
    MTN(i).h4 = k1+k2+k3+k4
    Next



    End Sub


    '.......................................................................................................................................................................






    Sub Ngichdao(MT4() as Matranb4 , MTND() as Matranb4)
    Dim MT33(),ND() as Matranb4
    Dim k,dt,b1,b2,b3 as float
    Dim i as integer
    Redim MT33(3)
    Redim MT4(4)
    Redim ND(4)
    Redim MTND(4)
    '1111111111111111111111111111111111111111111111
    For i=1 to 3
    b1 = MT4(i+1).h2
    b2 = MT4(i+1).h3
    b3 = MT4(i+1).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(1).h1 = k


    For i=1 to 4
    If i = 1 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>2 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(2).h1 = -k


    For i=1 to 4
    If i=1 or i=2 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>3 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(3).h1 = k


    For i=1 to 3
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(4).h1= -k








    '222222222222222222222222222222222222222222






    For i=1 to 3
    b1 = MT4(i+1).h1
    b2 = MT4(i+1).h3
    b3 = MT4(i+1).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(1).h2 = -k


    For i=1 to 4
    If i = 1 then
    b1 = MT4(i).h1
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>2 then
    b1 = MT4(i).h1
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(2).h2 = k


    For i=1 to 4
    If i=1 or i=2 then
    b1 = MT4(i).h1
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>3 then
    b1 = MT4(i).h1
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(3).h2 = -k


    For i=1 to 3
    b1 = MT4(i).h1
    b2 = MT4(i).h3
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2


    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(4).h2= k






    '33333333333333333333333333333333333333






    For i=1 to 3
    b1 = MT4(i+1).h1
    b2 = MT4(i+1).h2
    b3 = MT4(i+1).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3


    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(1).h3 = k


    For i=1 to 4
    If i = 1 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>2 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h4
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(2).h3 = -k


    For i=1 to 4
    If i=1 or i=2 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>3 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h4
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(3).h3 = k


    For i=1 to 3
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h4
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(4).h3= -k








    '4444444444444444444444444444444444444444444








    For i=1 to 3
    b1 = MT4(i+1).h1
    b2 = MT4(i+1).h2
    b3 = MT4(i+1).h3
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)


    k = dt
    ND(1).h4 = -k


    For i=1 to 4
    If i = 1 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h3
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>2 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h3
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(2).h4 = k


    For i=1 to 4
    If i=1 or i=2 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h3
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>3 then
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h3
    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(3).h4 = -k


    For i=1 to 3
    b1 = MT4(i).h1
    b2 = MT4(i).h2
    b3 = MT4(i).h3
    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k = dt
    ND(4).h4= k


    Dim ND2() as Matranb4
    Dim det as float
    Call Det44(MT4(),det)
    Call Chuyenvi(ND(),ND2())


    For i= 1 to 4
    MTND(i).h1 = ND2(i).h1/det
    MTND(i).h2 = ND2(i).h2/det
    MTND(i).h3 = ND2(i).h3/det
    MTND(i).h4 = ND2(i).h4/det
    Next


    End Sub


    '........................................................................................................
    Sub InMatran(MTIN() as Matranb4,tenfile as string)


    Dim i as integer
    Dim ghi as string
    ghi=" "
    Open File tenfile for Output as #1
    For i=1 to ubound(MTIN)
    ghi= ghi + Str$(MTIN(i).h1)+" "
    Next
    Print #1,ghi
    ghi=" "
    For i=1 to ubound(MTIN)
    ghi= ghi + Str$(MTIN(i).h2)+" "
    Next
    Print #1,ghi
    ghi=" "
    For i=1 to ubound(MTIN)
    ghi= ghi + Str$(MTIN(i).h3)+" "
    Next
    Print #1,ghi
    ghi=" "
    For i=1 to ubound(MTIN)
    ghi= ghi + Str$(MTIN(i).h4)+" "
    Next
    Print #1,ghi
    Close File #1
    End Sub
    '.................................................................................
    Sub Det44(MT4() as Matranb4,det as float)


    Dim MT33() as Matranb4
    Dim dt,b1,b2,b3,k1,k2,k3,k4 as float
    Dim i as integer
    Redim MT33(3)
    For i=1 to 3
    b1 = MT4(i+1).h2
    b2 = MT4(i+1).h3
    b3 = MT4(i+1).h4


    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k1 = dt* MT4(1).h1


    For i=1 to 4
    If i = 1 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4


    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>2 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4


    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k2 = dt* MT4(2).h1


    For i=1 to 4
    If i=1 or i=2 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4


    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    ElseIf i>3 then
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4


    MT33(i-1).h1 = b1
    MT33(i-1).h2 = b2
    MT33(i-1).h3 = b3
    End If
    Next
    Call Det33(MT33(),dt)
    k3 = dt* MT4(3).h1


    For i=1 to 3
    b1 = MT4(i).h2
    b2 = MT4(i).h3
    b3 = MT4(i).h4


    MT33(i).h1 = b1
    MT33(i).h2 = b2
    MT33(i).h3 = b3
    Next
    Call Det33(MT33(),dt)
    k4 = dt* MT4(4).h1


    det = k1 - k2 + k3 -k4


    End Sub
    '.........................................................................
    Sub Det33(MT3() as Matranb4,det as float)

    Dim a1,a2,a3,a4,a5,a6 as float
    a1= MT3(1).h1 * MT3(2).h2 * MT3(3).h3
    a2= MT3(1).h1 * MT3(3).h2 * MT3(2).h3
    a3= MT3(2).h1 * MT3(1).h2 * MT3(3).h3
    a4= MT3(2).h1 * MT3(3).h2 * MT3(1).h3
    a5= MT3(3).h1 * MT3(1).h2 * MT3(2).h3
    a6= MT3(3).h1 * MT3(2).h2 * MT3(1).h3


    det = a1 - a2 - a3 + a4 + a5 -a6


    End Sub
    '................................................................................
    Sub Chuyenvi(MTBD() as Matranb4, MTCV() as Matranb4)


    Dim a1,a2,a3,a4 as float
    Dim i as integer
    Redim MTCV(4)
    For i = 1 to 4
    a1=MTBD(i).h1
    a2=MTBD(i).h2
    a3=MTBD(i).h3
    a4=MTBD(i).h4
    If i=1 then
    MTCV(1).h1 = a1
    MTCV(2).h1 = a2
    MTCV(3).h1 = a3
    MTCV(4).h1 = a4
    ElseIf i=2 then
    MTCV(1).h2 = a1
    MTCV(2).h2 = a2
    MTCV(3).h2 = a3
    MTCV(4).h2 = a4
    ElseIf i=3 then
    MTCV(1).h3 = a1
    MTCV(2).h3 = a2
    MTCV(3).h3 = a3
    MTCV(4).h3 = a4
    ElseIf i=4 then
    MTCV(1).h4 = a1
    MTCV(2).h4 = a2
    MTCV(3).h4 = a3
    MTCV(4).h4 = a4
    End If
    Next


    End Sub
    Sub Tocdodichchuyen(x as float,y as float,vx as float , vy as float , svx as float , svy as float,tle as float)


    Dim x1,y1,x2,y2,x3,y3 as float
    x1= x + tle*vx
    y1= y + tle*vy
    x2= x1 + svx*tle*3
    y2= y1 - svy*tle*3
    x3= x1 - svx*tle*3
    y3= y1 + svy*tle*3
    Create Ellipse
    (x2,y2) (x3,y3)
    Pen MakePen(1,2,GREEN)
    Brush MakeBrush(01,Black,Black)
    Create Line (x,y) (x1,y1)
    Pen MakePen(1,59,Black)
    End Sub


    '....................................................
    Sub Vemuiten(x as float , y as float,e1 as float,e2 as float, g as float ,tle as float)


    Dim x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,e11,e22 as float
    e11=abs(e1)*tle
    e22=abs(e2)*tle
    x1 = x+ 1*e22
    x2 = x- 1*e22
    x3 = x + e22/3
    x4 = x - e22/3
    x5 = x + e22/3
    x6 = x - e22/3

    y1 = y + 2*e22
    y2 = y1
    y3 = y1
    y4 = y1
    y5 = y + 6*e22
    y6 = y5

    Dim mt1,mt2,mt3,mt4,mt as object
    Create Region Into Variable mt1
    1
    7 (x1,y1) (x3,y3) (x5,y5) (x6,y6) (x4,y4) (x2,y2) (x,y)
    Brush MakeBrush(02,Black,Green)
    Center (x,y)
    mt2 = RotateAtPoint(mt1,180,Centroid(mt1))
    Dim sx,sy as float
    sx = x
    sy = y - e11*6
    x1 = sx+ 1*e11
    x2 = sx- 1*e11
    x3 = sx + e11/3
    x4 = sx - e11/3
    x5 = sx + e11/3
    x6 = sx - e11/3

    y1 = sy + 2*e11
    y2 = y1
    y3 = y1
    y4 = y1
    y5 = sy + 6*e11
    y6 = y5


    Create Region Into Variable mt3
    1
    7 (x1,y1) (x3,y3) (x5,y5) (x6,y6) (x4,y4) (x2,y2) (sx,sy)
    Brush MakeBrush(02,Black,Green)
    Center (sx,sy*6*e11)
    mt3= RotateAtPoint(mt3,90,Centroid(mt1))
    mt4= RotateAtPoint(mt3,180,Centroid(mt1))
    mt = combine(mt1,mt2)
    mt = combine(mt,mt3)
    mt = combine(mt,mt4)
    mt = RotateAtPoint(mt,g,Centroid(mt1))
    Insert Into Lonlat(obj) values (mt)
    End Sub
    Sub Biendangxoay(x as float , y as float, w as float)
    Dim tle as float
    tle = 500
    Dim y1,x2,y2 as float
    y1=y + 1
    Dim o,ob,ob1,ob2,ob3,oo,oj as object
    o = CreatePoint(x,y)
    ob1 = CreateLine(x,y,x,y1)
    ob2 = RotateAtPoint(ob1,-5,Centroid(o))
    x2 = ObjectGeography(ob2 , OBJ_GEO_LINEENDX)
    y2 = ObjectGeography(ob2 , OBJ_GEO_LINEENDY)
    ob3 = CreateLine(x,y1,x2,y2)
    ob = combine(ob1,ob2)
    ob = combine(ob,ob3)
    oo= RotateAtPoint(ob,-5,Centroid(o))
    If w>0 then

    If w <= 1.0e-9 then
    Insert Into Lonlat(obj) values (ob)
    ElseIf w >1.0e-9 and w <=3.0e-9 then


    oo= combine(ob,oo)
    Insert Into Lonlat(obj) values (oo)
    ElseIf w>3.0e-9 and w <=5.0e-9 then
    oo = combine (ob,oo)
    oj = RotateAtPoint(ob,-10,Centroid(o))
    oo = combine (oj,oo)
    Insert Into Lonlat(obj) values (oo)
    Else
    oo = combine (ob,oo)
    oj = RotateAtPoint(ob,-30,Centroid(o))
    oo = combine (oj,oo)
    Insert Into Lonlat(obj) values (oo)
    End If
    Else
    oo= RotateAtPoint(ob,5,Centroid(o))
    If w >= -1.0e-9 then
    Insert Into Lonlat(obj) values (oo)
    ElseIf w >-3e-9 and w <=-1.0e-9 then
    oo= combine(ob,oo)
    Insert Into Lonlat(obj) values (oo)
    ElseIf w<-3.0e-9 and w >=-5.0e-9 then
    oo = combine (ob,oo)
    oj = RotateAtPoint(ob,10,Centroid(o))
    oo = combine (oj,oo)
    Insert Into Lonlat(obj) values (oo)
    Else
    oo = combine (ob,oo)
    oj = RotateAtPoint(ob,30,Centroid(o))
    oo = combine (oj,oo)
    Insert Into Lonlat(obj) values (oo)
    End If
    End if


    End Sub
     
  5. poorbaby

    poorbaby Member

    Tham gia ngày:
    21/10/11
    Bài viết:
    369
    Đã được thích:
    11
    Điểm thành tích:
    18
    Nghề nghiệp:
    RS_GIS
    Nơi ở:
    Ha Noi
    Compile lại có thấy bị lỗi j đâu nhỉ
     
  6. dr4g0nwhjt3

    dr4g0nwhjt3 New Member

    Tham gia ngày:
    1/12/14
    Bài viết:
    16
    Đã được thích:
    0
    Điểm thành tích:
    0
    Nghề nghiệp:
    Sinh viên
    Nơi ở:
    Gia Lai
    Em khắc phục được lỗi rồi ạ. Cảm ơn anh nhiều
     
  7. GEOMITECH

    GEOMITECH Moderator

    Tham gia ngày:
    31/10/11
    Bài viết:
    791
    Đã được thích:
    12
    Điểm thành tích:
    18
    Nghề nghiệp:
    GEOLOGIST
    Nơi ở:
    Hà Nội
    He he chúc mừng "bé nghèo" poorbaby nhé. Anh quả thật là bá đạo :D
     
  8. khánh

    khánh New Member

    Tham gia ngày:
    24/12/11
    Bài viết:
    2
    Đã được thích:
    0
    Điểm thành tích:
    0
    Mapbasic

    Mọi người có biết chỗ nào ở HN dạy Mapbasic ko ạ? Chỉ giúp t với
     
  9. GEOMITECH

    GEOMITECH Moderator

    Tham gia ngày:
    31/10/11
    Bài viết:
    791
    Đã được thích:
    12
    Điểm thành tích:
    18
    Nghề nghiệp:
    GEOLOGIST
    Nơi ở:
    Hà Nội
    Mapbasic đa phần là các cao thủ tự học thôi. Nếu bạn đã tiếp xúc với những dòng lệnh của bất kỳ ngôn ngữ lập trình nào thì đều có thể tiếp xúc rất nhanh với mapbasic. Tự học là một phương pháp rất hay của tất cả chúng ta. Bạn cứ nghiên cứu HELP của mapbasic trước rồi vướng đâu đưa lên đây anh em sẽ trợ giúp bạn. Nếu muốn nhanh bạn liên lạc với "bé nghèo" poorbaby nhé!
     

Chia sẻ trang này

Share
Đang tải...