| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1276 人关注过本帖
标题:请教如下代码解释
只看楼主 加入收藏
巴顿将军
Rank: 1
来 自:西安电子科技大学
等 级:新手上路
帖 子:7
专家分:0
注 册:2017-2-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:6 
请教如下代码解释


select jbxx

sttsbm = alltrim(sdm)
if empty(sttsbm)
  sttsbm= " "
endif
  
sttqgbm = alltrim(qgdm)



stz = alltrim(thisform.text1.value)

if empty(stz)
    messagebox("请选择路径!","招生系统")
    return
endif  



if substr(stz,len(stz),1) != "\"
  stz = stz+"\"
endif

  
if thisform.optiongroup1.option1.value = 1 or thisform.optiongroup1.option14.value = 1
  stt1 = "'"+stz+"jbxx'"
  stz2 = stz+"jbxx"
if not file(stz2+".dbf")
    messagebox("文件jbxx不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else
   select 0
   use &stt1 alias dwjbxx
   select dwjbxx
   scatter memvar
   select dwjbxx
   use
   select jbxx
   gather memvar
 endif  
 endif
   
if thisform.optiongroup1.option2.value = 1 or thisform.optiongroup1.option14.value = 1
   stt1 = "'"+stz+"xtxx'"
   stz2 = stz+"xtxx"
if not file(stz2+".dbf")
    messagebox("文件xtxx不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

   select 0
   use &stt1 alias dwxtxx
   select dwxtxx
   scatter memvar
   select dwxtxx
   use
   select xtxx
   gather memvar
 endif
 endif

if thisform.optiongroup1.option3.value = 1 or thisform.optiongroup1.option14.value = 1

  stt1 = "'"+stz+"bxzy'"
   stz2 = stz+"bxzy"
if not file(stz2+".dbf")
    messagebox("文件bxzy不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else
  select bxzy
   zap
  append from &stt1
  endif
 endif


if thisform.optiongroup1.option4.value = 1 or thisform.optiongroup1.option14.value = 1
   
   stt3 = "'"+stz+"kskm'"
   stz4 = stz+"kskm"
if not file(stz4+".dbf")
    messagebox("文件kskm不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else
 *不要追加相同的记录
  select kskm
  append from &stt3
  endif  
  
  select distinct kskmm,kskm,kmtk from kskm into cursor yk group by kskmm order by kskmm
  select kskm
  zap
  append from dbf("yk")
  go top
  
 endif
 
if thisform.optiongroup1.option5.value = 1 or thisform.optiongroup1.option14.value = 1
   
   stt3 = "'"+stz+"ds'"
   stz4 = stz+"ds"
if not file(stz4+".dbf")
    messagebox("文件ds不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else
  select ds
   zap
  append from &stt3
  endif  
 endif
 
if thisform.optiongroup1.option6.value = 1 or thisform.optiongroup1.option14.value = 1

   stt3 = "'"+stz+"kc'"
   stz4 = stz+"kc"
if not file(stz4+".dbf")
    messagebox("文件kc不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else
  select kc
   zap
  append from &stt3
  endif  
 endif
 
if thisform.optiongroup1.option7.value = 1 or thisform.optiongroup1.option14.value = 1

   
   stt3 = "'"+stz+"mlk'"
   stz4 = stz+"mlk"
if not file(stz4+".dbf")
    messagebox("文件mlk不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else
  select mlk
   zap
  append from &stt3
 endif   
 endif
 
if thisform.optiongroup1.option8.value = 1 or thisform.optiongroup1.option14.value = 1
   
   stt3 = "'"+stz+"ssbm'"
   stz4 = stz+"ssbm"
if not file(stz4+".dbf")
    messagebox("文件ssbm不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
 endif

if file(stz4+".dbf")
  select ssbm
   zap
  append from &stt3
 endif  

endif

if thisform.optiongroup1.option10.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"ssbkwx'"
   stz4 = stz+"ssbkwx"
if not file(stz4+".dbf")
    messagebox("文件ssbkwx不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

  select ssbkwx
   zap
  append from &stt3
  endif
 endif
 
 if thisform.optiongroup1.option11.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"sscl'"
   stz4 = stz+"sscl"
if not file(stz4+".dbf")
    messagebox("文件sscl不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

  select sscl
   zap
  append from &stt3
  endif
 endif
 
 if thisform.optiongroup1.option12.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"ssbl'"
   stz4 = stz+"ssbl"
if not file(stz4+".dbf")
    messagebox("文件ssbl不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

  select ssbl
   zap
  append from &stt3
  endif
 endif
 
 if thisform.optiongroup1.option13.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"jkry'"
   stz4 = stz+"jkry"
if not file(stz4+".dbf")
    messagebox("文件jkry不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

  select jkry
   zap
  append from &stt3
  endif
 endif
 
  if  thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"fsk'"
   stz4 = stz+"fsk"
if not file(stz4+".dbf")
    messagebox("文件fsk不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

  select fsk
   zap
  append from &stt3
  endif
  
   stt3 = "'"+stz+"fsjs'"
   stz4 = stz+"fsjs"
if not file(stz4+".dbf")
    messagebox("文件fsjs不存在!","招生系统")
    if thisform.optiongroup1.option14.value != 1
        return
    endif
else

  select fsjs
   zap
  append from &stt3
  endif
  
 endif
   
 wait window "完成" timeout 2 at srows()/2,(scols()-len("完成"))/2

*endif
搜索更多相关主题的帖子: file 招生 
2017-03-01 08:19
mywisdom88
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:191
帖 子:3146
专家分:8408
注 册:2015-3-25
收藏
得分:5 
解释每行的意思?还是解释整段的思路。。
2017-03-01 08:50
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:0 
不少 哪不明白
2017-03-01 09:34
中国龙王
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:484
专家分:283
注 册:2006-5-17
收藏
得分:5 
不带问这样的。。。。你具体哪里不知道单独指出来。。。。。

不要为了打发无聊而做无聊的事!不要在虚幻的世界里做虚幻的事!
2017-03-01 10:25
mywisdom88
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:191
帖 子:3146
专家分:8408
注 册:2015-3-25
收藏
得分:0 
以下是引用巴顿将军在2017-3-1 08:19:55的发言:
........   
 wait window "完成" timeout 2 at srows()/2,(scols()-len("完成"))/2
.......


*!* 选择表 jbxx
select jbxx

*!* sdm 可能是表的字段名称
 sttsbm = alltrim(sdm)
 if empty(sttsbm)
   sttsbm= " "
 endif
   
 sttqgbm = alltrim(qgdm)


 stz = alltrim(thisform.text1.value)
 if empty(stz)
     messagebox("请选择路径!","招生系统")
     return
 endif  


*!* 如果stz路径最后1位不是\,就在最后加上\
 if substr(stz,len(stz),1) != "\"
   stz = stz+"\"
 endif

   
 if thisform.optiongroup1.option1.value = 1 or thisform.optiongroup1.option14.value = 1
   stt1 = "'"+stz+"jbxx'"
   stz2 = stz+"jbxx"

*!* 如果DBF文件不存在,就返回
if not file(stz2+".dbf")
     messagebox("文件jbxx不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else &&如果存在就打开
*============================
    select 0
    use &stt1 alias dwjbxx
* 上面2句,可以优化为
* if used('dwjbxx')
*    select dwjbxx
* else
    use &stt1 alias dwjbxx in 0
* endif  
*============================
    select dwjbxx
    scatter memvar &&把表 dwjbxx 当前记录中复制数据到数组 memvar
    select dwjbxx
    use &&关闭当前表,也就是关闭 dwjhxx 表
    select jbxx
    gather memvar &&把数组 memvar 的值替换到表 jbxx 的当前记录
  endif  
  endif

*!* 类似上面   
 if thisform.optiongroup1.option2.value = 1 or thisform.optiongroup1.option14.value = 1
    stt1 = "'"+stz+"xtxx'"
    stz2 = stz+"xtxx"
 if not file(stz2+".dbf")
     messagebox("文件xtxx不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

    select 0
    use &stt1 alias dwxtxx
    select dwxtxx
    scatter memvar
    select dwxtxx
    use
    select xtxx
    gather memvar
  endif
  endif

 if thisform.optiongroup1.option3.value = 1 or thisform.optiongroup1.option14.value = 1

   stt1 = "'"+stz+"bxzy'"
    stz2 = stz+"bxzy"
 if not file(stz2+".dbf")
     messagebox("文件bxzy不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else
   select bxzy
    zap
   append from &stt1
   endif
  endif


 if thisform.optiongroup1.option4.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"kskm'"
    stz4 = stz+"kskm"
 if not file(stz4+".dbf")
     messagebox("文件kskm不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else
  *不要追加相同的记录
  select kskm
   append from &stt3
   endif  
*=============================

   select distinct kskmm,kskm,kmtk from kskm into cursor yk group by kskmm order by kskmm &&去重复查询表 kskm 的结果到 生成临时表 yk
   select kskm
   zap &&清空 kskm表
   append from dbf("yk") &&把刚才生成的临时表复制过来

*上面4行,可以这样做
* 如果 表 kskm 是"DBF"表时,假设在 d:\abc 中
* select distinct kskmm,kskm,kmtk from kskm into table d:\abc\kskm group by kskmm order by kskmm
* 如果 表 kskm 是临时表
* select distinct kskmm,kskm,kmtk from kskm into cursor kskm group by kskmm order by kskmm readw

*=============================

   go top
   
  endif

*================================下面的语法都基本和上面的相同,没其他新的,就不写了
  
 if thisform.optiongroup1.option5.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"ds'"
    stz4 = stz+"ds"
 if not file(stz4+".dbf")
     messagebox("文件ds不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else
   select ds
    zap
   append from &stt3
   endif  
  endif
  
 if thisform.optiongroup1.option6.value = 1 or thisform.optiongroup1.option14.value = 1

    stt3 = "'"+stz+"kc'"
    stz4 = stz+"kc"
 if not file(stz4+".dbf")
     messagebox("文件kc不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else
   select kc
    zap
   append from &stt3
   endif  
  endif
  
 if thisform.optiongroup1.option7.value = 1 or thisform.optiongroup1.option14.value = 1

   
    stt3 = "'"+stz+"mlk'"
    stz4 = stz+"mlk"
 if not file(stz4+".dbf")
     messagebox("文件mlk不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else
   select mlk
    zap
   append from &stt3
  endif   
  endif
  
 if thisform.optiongroup1.option8.value = 1 or thisform.optiongroup1.option14.value = 1
   
    stt3 = "'"+stz+"ssbm'"
    stz4 = stz+"ssbm"
 if not file(stz4+".dbf")
     messagebox("文件ssbm不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
  endif

 if file(stz4+".dbf")
   select ssbm
    zap
   append from &stt3
  endif  

 endif

 if thisform.optiongroup1.option10.value = 1 or thisform.optiongroup1.option14.value = 1
     
     stt3 = "'"+stz+"ssbkwx'"
    stz4 = stz+"ssbkwx"
 if not file(stz4+".dbf")
     messagebox("文件ssbkwx不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

   select ssbkwx
    zap
   append from &stt3
   endif
  endif
  
  if thisform.optiongroup1.option11.value = 1 or thisform.optiongroup1.option14.value = 1
     
     stt3 = "'"+stz+"sscl'"
    stz4 = stz+"sscl"
 if not file(stz4+".dbf")
     messagebox("文件sscl不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

   select sscl
    zap
   append from &stt3
   endif
  endif
  
  if thisform.optiongroup1.option12.value = 1 or thisform.optiongroup1.option14.value = 1
     
     stt3 = "'"+stz+"ssbl'"
    stz4 = stz+"ssbl"
 if not file(stz4+".dbf")
     messagebox("文件ssbl不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

   select ssbl
    zap
   append from &stt3
   endif
  endif
  
  if thisform.optiongroup1.option13.value = 1 or thisform.optiongroup1.option14.value = 1
     
     stt3 = "'"+stz+"jkry'"
    stz4 = stz+"jkry"
 if not file(stz4+".dbf")
     messagebox("文件jkry不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

   select jkry
    zap
   append from &stt3
   endif
  endif
  
   if  thisform.optiongroup1.option14.value = 1
     
     stt3 = "'"+stz+"fsk'"
    stz4 = stz+"fsk"
 if not file(stz4+".dbf")
     messagebox("文件fsk不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

   select fsk
    zap
   append from &stt3
   endif
   
    stt3 = "'"+stz+"fsjs'"
    stz4 = stz+"fsjs"
 if not file(stz4+".dbf")
     messagebox("文件fsjs不存在!","招生系统")
     if thisform.optiongroup1.option14.value != 1
         return
     endif
 else

   select fsjs
    zap
   append from &stt3
   endif
   
  endif
   
  wait window "完成" timeout 2 at srows()/2,(scols()-len("完成"))/2

 *endif

[此贴子已经被作者于2017-3-1 11:14编辑过]

2017-03-01 11:13
hyswcyh
Rank: 8Rank: 8
等 级:贵宾
威 望:20
帖 子:391
专家分:896
注 册:2004-11-23
收藏
得分:5 
确实太长了。最好单独节选出来提问。
2017-03-01 12:11
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9799
专家分:26886
注 册:2012-2-5
收藏
得分:5 
帮助文件中都有明确解释

坚守VFP最后的阵地
2017-03-01 12:12
快速回复:请教如下代码解释
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019398 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved