include "mapbasic.def"
declare sub main
declare sub provincename
declare sub number
declare sub sumpopulation
declare sub exit
declare sub cityname
declare sub opentables
sub main
alter menu bar remove "查询[&Q]","帮助[&H]"
create menu "查询" as
"按省份" calling provincename,
"按编号" calling number,
"按人口" calling sumpopulation,
"退出" calling exit
create menu "搜索" as
"搜索城市" calling cityname
alter menu bar add "查询","搜索"
call opentables
end sub
sub opentables
open table "C:\Documents and Settings\杨玉满\My Documents\My Music\lu"
open table "C:\Documents and Settings\杨玉满\My Documents\My Music\xiaoshi"
open table "C:\Documents and Settings\杨玉满\My Documents\My Music\shi"
open table "C:\Documents and Settings\杨玉满\My Documents\My Music\xianlu"
open table "C:\Documents and Settings\杨玉满\My Documents\My Music\sheng"
map from lu,xiaoshi,shi,xianlu,sheng
set map
center (-0.559,0.870)
zoom entire
preserve zoom
display position
scale 1 units "mm" for 4 units "mi"
layer 1 editable on
layer 2 editable on
layer 3 editable on
layer 4 editable on
layer 5 editable on
layer 1 zoom(0,1000) units "km" on
layer 2 zoom(0,745) units "km" on
layer 4 zoom(0,745) units "km" on
end sub
sub provincename
dim a as string
dialog
title "按省份"
control statictext
title "请输入省份"
control edittext
value a into a
control okbutton
title "确定"
control cancelbutton
title "取消"
select*from sheng where sheng=a into query1
set window info
title "省份信息"
table query1
rec 1
position (0,64) units "mm"
width 100 units "mm"
height 50 units "mm"
front
end sub
sub number
dim b as integer
dialog
title "按编号"
control statictext
title "请输入编号"
control edittext
value b into b
control okbutton
title "确定"
control cancelbutton
title "取消"
select*from sheng where bianhao=b into query2
set window info
title "省份信息"
table query2
rec 1
position (0,80) units "mm"
width 100 units "mm"
height 50 units "mm"
end sub
sub sumpopulation
dim c as integer
dialog
title "按人口"
control statictext
title "请输入人口"
control edittext
value c into c
control okbutton
title "确定"
control cancelbutton
title "取消"
select*from sheng where renkou > c into query3
set window info
title "省份信息"
table query3
rec 1
position (0,80) units "mm"
width 100 units "mm"
height 50 units "mm"
end sub
sub cityname
dim x,y as float,win_id as integer
dim a as string
dialog
title "搜索"
control statictext
title "请输入要搜索的城市:"
control edittext
into a
control okbutton
title "确定"
control cancelbutton
title "取消"
open table "xiaoshi" interactive
map from xiaoshi,shi,lu,xianlu,sheng
win_id=frontwindow()
find using xiaoshi(xiaoshi)
find a
if commandinfo(cmd_info_find_rc)>=1 then
x=commandinfo(cmd_info_x)
y=commandinfo(cmd_info_y)
set map
window win_id
center(x,y)
else
note "location not found"
end if
set window info
title a
width 3 units "mm"
height 2 units "mm"
position (0,0)
print "x;"+round(x,0.001)+chr$(10)+
"y:"+round(y,0.001)
end sub
sub exit
close all
call opentables
end sub