Include "Mapbasic.def"
include "icons.def"
include "menu.def"

Global Xto,Yto,Xto2,Yto2,DeltaX,DeltaY,deltay2,deltay3,shag  As Float
Global n,rowi,Zapis,Zapis2,Nat,Kont,rowi2,rowi3,Ver,yes,yes2 as Integer
Global Opis,Natl,Kontl,nom,filler  As String
Global dom as object

Declare Sub Setka

Create buttonpad "Сетка"  as ToolButton
icon MI_ICON_CROSSHAIR
Cursor  MI_CURSOR_CROSSHAIR
DrawMode DM_CUSTOM_RECT
Calling Setka
helpmsg "\nСетка"
show


Sub Setka
Dim x1,y1,x2,y2,dx,dy,delta,dlt As Float
dim dom2 as Object
Dim sym_marker As Symbol
Set CoordSys table tableinfo(1,TAB_INFO_NAME) 
x1 = CommandInfo(CMD_INFO_X) 
y1 = CommandInfo(CMD_INFO_Y)
x2 = CommandInfo(CMD_INFO_X2) 
y2 = CommandInfo(CMD_INFO_Y2)
Shag=10
Dialog 
    Title "Параметры"
Control StaticText 
      Title "Шаг сетки" 
      Position 10, 5
    Control EditText 
      Value shag 
      Into shag 
      Width 30 
      Position 70, 5
control okbutton
control cancelbutton
If CommandInfo(CMD_INFO_DLG_OK) Then


'note tableinfo(1,TAB_INFO_COORDSYS_NAME)

DeltaX=shag DeltaY=shag Delta=shag
sym_marker = MakeFontSymbol(43,0,16,"Uzgeopunkt",0,0)

Set Style Symbol sym_marker 
       Delete From setka
       Commit Table setka
       Pack Table   setka  Data     Interactive
Add Map Layer setka
Set Map Layer  setka
Display  Global Global Symbol (43,0,16,"UZgeopunkt",0,0)

'Note CurrentSymbol()
Dy=Round(y1,shag)
While Dy < y2
Dx=Round(x1,shag)
if dlt<0 then
Dx=dx+Delta
end if
while Dx < x2
'note 1
Create Point Into variable dom2 (dx,dy)
'Alter Object  dom2
 '     Info OBJ_INFO_SYMBOL,sym_marker
	
'Symbol sym_marker
'insert Into setka(obj,col2,col3) values (dom2,dy,dx)
insert Into setka(obj) values (dom2)
Dx=Dx+DeltaX
Wend
dlt=dlt*(-1)
Dy=Dy+DeltaY
Wend

End if
End Sub