Ý nghĩa hàm select 0 và if empty trong Visual Fox (3 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

toikhongvao

Thành viên mới
Tham gia
4/1/10
Bài viết
18
Được thích
2
trong đoạn code này, chức năng là đếm số bút toán của nhân viên. Khi chạy báo lỗi ở dòng 3, chọn bỏ qua thì báo lỗi tiếp ở dòng 7, bỏ qua thì nó bảo chọn file database thì chạy ngon lành, tới dòng cuối từ dưới đếm lên 4 thì báo lỗi chổ cn.

Mình chỉ muốn hỏi ý nghĩa câu select 0 và if empty
THX
[FONT=&quot]para [/FONT][FONT=&quot]namthang,cn[/FONT]
[FONT=&quot]mdir='bcao\dbf\'[/FONT]
[FONT=&quot]file_kq='kq'+cn+'.dbf'[/FONT]
[FONT=&quot]clos data[/FONT]
[FONT=&quot]set safe off[/FONT]
[FONT=&quot]wait wind nowa [/FONT][FONT=&quot]'Dang lay but toan cua teller..'[/FONT]
[FONT=&quot]use [/FONT][FONT=&quot]mdir+ 'ps&namthang.dbf' [/FONT][FONT=&quot]alia [/FONT][FONT=&quot]ps[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]* [/FONT][FONT=&quot]from [/FONT][FONT=&quot]ps [/FONT][FONT=&quot]into dbf [/FONT][FONT=&quot]temp [/FONT][FONT=&quot]where [/FONT][FONT=&quot](nsd='BDU' or nsd='TDM' or nsd='BCA' or nsd='TAU' or nsd='SSO' or nsd='TPK' or nsd='PGI' or nsd='DTG')[/FONT]
[FONT=&quot]wait wind nowa [/FONT][FONT=&quot]'Dang lay so luong but toan..'[/FONT]
[FONT=&quot]sele dist [/FONT][FONT=&quot]nsd,ngay,sbt,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]cn,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]dp,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]fx,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]gl,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln1,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln2,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln3,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln4,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln5,' ' [/FONT][FONT=&quot]as [/FONT][FONT=&quot]khac ;[/FONT]
[FONT=&quot]from [/FONT][FONT=&quot]temp [/FONT][FONT=&quot]into dbf [/FONT][FONT=&quot]ketqua [/FONT][FONT=&quot]orde by [/FONT][FONT=&quot]1,2,3[/FONT]
[FONT=&quot]clos data[/FONT]
[FONT=&quot]*[/FONT]
[FONT=&quot]wait wind nowa [/FONT][FONT=&quot]'Dang index...'[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]0[/FONT]
[FONT=&quot]use [/FONT][FONT=&quot]temp [/FONT][FONT=&quot]alia [/FONT][FONT=&quot]sl [/FONT][FONT=&quot]excl[/FONT]
[FONT=&quot]inde on [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt [/FONT][FONT=&quot]tag [/FONT][FONT=&quot]tmp[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]0[/FONT]
[FONT=&quot]use [/FONT][FONT=&quot]ketqua [/FONT][FONT=&quot]alia [/FONT][FONT=&quot]kq [/FONT][FONT=&quot]excl[/FONT]
[FONT=&quot]scan[/FONT]
[FONT=&quot]=[/FONT][FONT=&quot]seek[/FONT][FONT=&quot](nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt,'sl')[/FONT]
[FONT=&quot]wait wind nowa [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt[/FONT]
[FONT=&quot]do case[/FONT]
[FONT=&quot] case [/FONT][FONT=&quot]sl.buscd='DP'[/FONT]
[FONT=&quot]repl [/FONT][FONT=&quot]dp [/FONT][FONT=&quot]with [/FONT][FONT=&quot]'1'[/FONT]
[FONT=&quot]case [/FONT][FONT=&quot]sl.buscd='FX'[/FONT]
[FONT=&quot]repl [/FONT][FONT=&quot]fx [/FONT][FONT=&quot]with [/FONT][FONT=&quot]'1'[/FONT]
[FONT=&quot]case [/FONT][FONT=&quot]sl.buscd='GL'[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]sl[/FONT]
[FONT=&quot]loca while [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt=kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt [/FONT][FONT=&quot]for [/FONT][FONT=&quot]tk='7' or tk='8'[/FONT]
[FONT=&quot]if foun[/FONT][FONT=&quot]()[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]kq[/FONT]
[FONT=&quot]repl [/FONT][FONT=&quot]gl [/FONT][FONT=&quot]with [/FONT][FONT=&quot]'1'[/FONT]
[FONT=&quot]else[/FONT]
[FONT=&quot] sele [/FONT][FONT=&quot]kq[/FONT]
[FONT=&quot]repl [/FONT][FONT=&quot]khac [/FONT][FONT=&quot]with [/FONT][FONT=&quot]'1'[/FONT]
[FONT=&quot]endi [/FONT]
[FONT=&quot] case [/FONT][FONT=&quot]sl.buscd='LN'[/FONT]
[FONT=&quot]stor [/FONT][FONT=&quot]' ' [/FONT][FONT=&quot]to [/FONT][FONT=&quot]ln1,ln2,ln3,ln4,ln5,khac[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]sl[/FONT]
[FONT=&quot]seek [/FONT][FONT=&quot]kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt[/FONT]
[FONT=&quot]loca while [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt=kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt [/FONT][FONT=&quot]for [/FONT][FONT=&quot]trcd='W011'[/FONT]
[FONT=&quot]if foun[/FONT][FONT=&quot]()[/FONT]
[FONT=&quot] ln1='1'[/FONT]
[FONT=&quot]endi[/FONT]
[FONT=&quot]*[/FONT]
 
Tách làm 2 vì bài viết quá dài :D
[FONT=&quot]if empt[/FONT][FONT=&quot](m.ln1+m.ln2+m.ln3+m.ln4+m.ln5)[/FONT]
[FONT=&quot]seek [/FONT][FONT=&quot]kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt[/FONT]
[FONT=&quot]loca while [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt=kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt [/FONT][FONT=&quot]for [/FONT][FONT=&quot]trcd='W132' and tk='2'[/FONT]
[FONT=&quot]if foun[/FONT][FONT=&quot]()[/FONT]
[FONT=&quot] ln2='1'[/FONT]
[FONT=&quot]endi[/FONT]
[FONT=&quot] endi[/FONT]
[FONT=&quot]*[/FONT]
[FONT=&quot]if empt[/FONT][FONT=&quot](m.ln1+m.ln2+m.ln3+m.ln4+m.ln5)[/FONT]
[FONT=&quot]seek [/FONT][FONT=&quot]kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt[/FONT]
[FONT=&quot]loca while [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt=kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt [/FONT][FONT=&quot]for [/FONT][FONT=&quot]trcd='W132' and tk='7'[/FONT]
[FONT=&quot]if foun[/FONT][FONT=&quot]()[/FONT]
[FONT=&quot] ln3='1'[/FONT]
[FONT=&quot]endi[/FONT]
[FONT=&quot] endi[/FONT]
[FONT=&quot]*[/FONT]
[FONT=&quot]if empt[/FONT][FONT=&quot](m.ln1+m.ln2+m.ln3+m.ln4+m.ln5)[/FONT]
[FONT=&quot]seek [/FONT][FONT=&quot]kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt[/FONT]
[FONT=&quot]loca while [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt=kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt [/FONT][FONT=&quot]for [/FONT][FONT=&quot]trcd='W101' [/FONT]
[FONT=&quot]if foun[/FONT][FONT=&quot]()[/FONT]
[FONT=&quot] ln4='1'[/FONT]
[FONT=&quot]endi[/FONT]
[FONT=&quot] endi[/FONT]
[FONT=&quot]*[/FONT]
[FONT=&quot]if empt[/FONT][FONT=&quot](m.ln1+m.ln2+m.ln3+m.ln4+m.ln5)[/FONT]
[FONT=&quot]seek [/FONT][FONT=&quot]kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt[/FONT]
[FONT=&quot]loca while [/FONT][FONT=&quot]nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](ngay)+sbt=kq.nsd+[/FONT][FONT=&quot]dtos[/FONT][FONT=&quot](kq.ngay)+kq.sbt [/FONT][FONT=&quot]for [/FONT][FONT=&quot]trcd='W102' [/FONT]
[FONT=&quot]if foun[/FONT][FONT=&quot]()[/FONT]
[FONT=&quot] ln5='1'[/FONT]
[FONT=&quot]endi[/FONT]
[FONT=&quot] endi[/FONT]
[FONT=&quot]*[/FONT]
[FONT=&quot]if empt[/FONT][FONT=&quot](m.ln1+m.ln2+m.ln3+m.ln4+m.ln5)[/FONT]
[FONT=&quot] khac='1'[/FONT]
[FONT=&quot]endi[/FONT]
[FONT=&quot] sele [/FONT][FONT=&quot]kq[/FONT]
[FONT=&quot]repl [/FONT][FONT=&quot]ln1 [/FONT][FONT=&quot]with [/FONT][FONT=&quot]m.ln1,ln2 [/FONT][FONT=&quot]with [/FONT][FONT=&quot]m.ln2,ln3 [/FONT][FONT=&quot]with [/FONT][FONT=&quot]m.ln3,ln4 [/FONT][FONT=&quot]with [/FONT][FONT=&quot]m.ln4,ln5 [/FONT][FONT=&quot]with [/FONT][FONT=&quot]m.ln5,khac [/FONT][FONT=&quot]with [/FONT][FONT=&quot]m.khac[/FONT]
[FONT=&quot]othe [/FONT]
[FONT=&quot] repl [/FONT][FONT=&quot]khac [/FONT][FONT=&quot]with [/FONT][FONT=&quot]'1' [/FONT]
[FONT=&quot]endc[/FONT]
[FONT=&quot]ends[/FONT]
[FONT=&quot]wait clea [/FONT]
[FONT=&quot]wait wind nowa [/FONT][FONT=&quot]'Dang tong hop...'[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]nsd,ngay,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](dp)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]dp,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](fx)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]fx,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](gl)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]gl,;[/FONT]
[FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](ln1)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln1,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](ln2)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln2,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](ln3)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln3,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](ln4)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln4,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](ln5)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln5,;[/FONT]
[FONT=&quot]sum[/FONT][FONT=&quot]([/FONT][FONT=&quot]val[/FONT][FONT=&quot](khac)) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]khac ;[/FONT]
[FONT=&quot]from [/FONT][FONT=&quot]kq [/FONT][FONT=&quot]into dbf [/FONT][FONT=&quot]kqngay [/FONT][FONT=&quot]grou by [/FONT][FONT=&quot]1,2[/FONT]
[FONT=&quot]sele [/FONT][FONT=&quot]nsd,[/FONT][FONT=&quot]count[/FONT][FONT=&quot](ngay) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]songay,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](dp) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]dp,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](fx) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]fx,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](gl) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]gl,;[/FONT]
[FONT=&quot]sum[/FONT][FONT=&quot](ln1) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln1,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](ln2) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln2,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](ln3) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln3,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](ln4) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln4,[/FONT][FONT=&quot]sum[/FONT][FONT=&quot](ln5) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]ln5,;[/FONT]
[FONT=&quot]sum[/FONT][FONT=&quot](khac) [/FONT][FONT=&quot]as [/FONT][FONT=&quot]khac ;[/FONT]
[FONT=&quot]from [/FONT][FONT=&quot]kqngay [/FONT][FONT=&quot]into DBF [/FONT][FONT=&quot]file_kq [/FONT][FONT=&quot]grou by [/FONT][FONT=&quot]1[/FONT]
[FONT=&quot]clos data[/FONT]
[FONT=&quot]use [/FONT][FONT=&quot]file_kq [/FONT][FONT=&quot]alia [/FONT][FONT=&quot]kq [/FONT][FONT=&quot]excl[/FONT]
[FONT=&quot]alter table [/FONT][FONT=&quot]kq [/FONT][FONT=&quot]add column [/FONT][FONT=&quot]tongbt n(10) [/FONT][FONT=&quot]add column [/FONT][FONT=&quot]bquan n(10) add colum cn c(4)[/FONT]
[FONT=&quot]repl all cn with m.cn,[/FONT][FONT=&quot]tongbt [/FONT][FONT=&quot]with [/FONT][FONT=&quot]dp+fx+gl+ln1+ln2+ln3+ln4+ln5+khac,bquan [/FONT][FONT=&quot]with [/FONT][FONT=&quot]tongbt/songay [/FONT]
[FONT=&quot]wait clea[/FONT]
[FONT=&quot]clos data[/FONT]
 
Hàm select n dùng để mở vùng làm việc mới. Trong đó n là số nguyên dương.
Khi n= 0 nghĩa là mở vùng làm việc mới sau vùng thứ n ( tương đương n+1 )

Hàm if(empty(Fx)) dùng để kiểm tra xem Fx có bị rỗng không. Fx có thể là 1 file, 1 trường, 1 chuỗi text hoặc chuỗi ngày tháng
 
Cần người dạy Visual Fox

Chào bạn mình đang cần học Fox , bạn có thể dạy online giúp mình không, giá cả thỏa thuận.
Nếu được bạn hãy pm qua yahoo "hoaivong_1983"
Thanks bạn.
 
Web KT

Bài viết mới nhất

Back
Top Bottom