| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1216 人关注过本帖
标题:又来求教了,有了点小问题
取消只看楼主 加入收藏
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:12 
又来求教了,有了点小问题
IF USED('odrep') THEN
   SELECT odrep
ELSE
   SELECT 0
   USE odrep
ENDIF
LOCATE FOR odrep.month-odrep.pdtcode-odrep.spec-odrep.standn==tg1-tg2-tg3-tg4
IF FOUND()
   REPLACE hamx.team WITH odrep.team,hamx.rep WITH odrep.rep,hamx.regbj WITH odrep.regbj,hamx.supbj WITH odrep.supbj,hamx.repbj WITH; odrep.repbj,hamx.city WITH odrep.city,hamx.prov WITH odrep.prov
   USE IN odrep
ELSE
   REPLACE hamx.team WITH '非目标',hamx.rep WITH '非目标',hamx.regbj WITH 'XX',hamx.supbj WITH 'X',hamx.repbj WITH 'XXX'

   USE IN odrep
ENDIF

不好意思,又来求教。
以上代码,if found() 为真,那么后面的replace执行正确,可是else之后的replace却无法执行,我实在不明白
版主能否赐教。
谢谢
2014-04-13 23:42
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
版主,搞不定啊
我试了一下
如果用 IF .NOT. FOUND()
       REPL .....
那这也无法执行的。

感觉locate for之后,found()为.F. 就直接到endif了。
再不行只能用select了,哎。。。。
2014-04-14 06:24
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
以下是引用sdta在2014-4-14 00:01:57的发言:

Use In Odrep 的时机不对


版主,我的电脑今天错乱了,我在locate for语句后加了个browse
然后我点了300多下鼠标左键来关闭表。
居然这一次运行完全正确。
怎么回事?
2014-04-14 06:32
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
是locate for
之后要打开表,才能判断 if .not. found()  吗?
2014-04-14 06:35
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
以下是引用hu9jj在2014-4-14 07:33:49的发言:


brow命令之后,记录指针已经有了对应的记录,此时repl当然可以啦。

H版,我把代码都放上来,你帮我检查一下,行不?
2014-04-14 08:13
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
以下是引用hu9jj在2014-4-14 07:33:49的发言:


brow命令之后,记录指针已经有了对应的记录,此时repl当然可以啦。

H版,我locate for 表odrep
not found()情况下:  replace 表hamx with '非目标'  &&没有用到表odrep的东西啊?
这也会受影响吗?
2014-04-14 08:23
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
加了browse,else之后的语句是可以执行的,
是不是我不加browse,else就是个摆设?
2014-04-14 08:31
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
以下是引用sdta在2014-4-14 08:35:04的发言:

REPLACE Record ? hamx.team WITH '非目标',hamx.rep WITH '非目标',hamx.regbj WITH 'XX',hamx.supbj WITH 'X',hamx.repbj WITH 'XXX'

版主,这个record ? 啥意思啊,显示语法错误
2014-04-14 08:49
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
SET TALK OFF
SET SAFETY OFF
CLOSE TABLES
axx=0
SELECT hatemp.month as months,pdtcode,spec,type1,type2,boxes,standn,SUM(qty) as sqty,SUM(pdtvalu) as spdtvalu FROM hatemp GROUP BY hatemp.month,hatemp.pdtcode,hatemp.spec,hatemp.type1,hatemp.type2,hatemp.boxes,hatemp.standn INTO CURSOR tag1
FOR tg=1 TO RECCOUNT()
   SELECT hatemp.month as months,pdtcode,spec,type1,type2,boxes,standn,SUM(qty) as sqty,SUM(pdtvalu) as spdtvalu FROM hatemp GROUP BY hatemp.month,hatemp.pdtcode,hatemp.spec,hatemp.type1,hatemp.type2,hatemp.boxes,hatemp.standn INTO CURSOR tag1
   GO tg
   tg1=months
   tg2=pdtcode
   tg3=spec
   tg4=standn
   tg5=type1
   tg6=type2
   tg7=boxes
   tg8=sqty
   tg9=spdtvalu
   ? RECNO()
   USE hamx
   APPEND BLANK
   REPLACE hamx.month WITH tg1,hamx.pdtcode WITH tg2,hamx.spec WITH tg3,hamx.type1 WITH tg5,hamx.type2 WITH tg6,hamx.boxes WITH tg7,hamx.qty WITH tg8,hamx.pdtvalu WITH tg9,hamx.standn WITH tg4
   IF USED('odrep') THEN
      SELECT odrep
   ELSE
      SELECT 0
      USE odrep
   ENDIF
   LOCATE FOR odrep.month-odrep.pdtcode-odrep.spec-odrep.standn==tg1-tg2-tg3-tg4
   ? FOUND()
   *BROWSE
   IF FOUND()
      REPLACE hamx.team WITH odrep.team,hamx.rep WITH odrep.rep,hamx.regbj WITH odrep.regbj,hamx.supbj WITH odrep.supbj,hamx.repbj WITH odrep.repbj,hamx.city WITH odrep.city,hamx.prov WITH odrep.prov
      *USE IN odrep
   ELSE
      axx=axx+1
      REPLACE hamx.team WITH '非目标',hamx.rep WITH '非目标',hamx.regbj WITH 'XX',hamx.supbj WITH 'X',hamx.repbj WITH 'XXX'
      *USE IN odrep

   ENDIF
   USE IN odrep
   USE IN hamx   
ENDFOR
?axx
CLOSE TABLES
RELEASE ALL
各位有空了帮忙看看,标红的字体是出问题的地方,使用browse之后,标红的语句可以执行,否则repl结果为空值。
我放了个axx在else之后测试了一下,axx是可以计数的。只是repl不正确。
2014-04-14 08:53
andyee
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2014-2-12
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


用brow和不用brow的两次运行结果,请看图片
2014-04-14 08:54
快速回复:又来求教了,有了点小问题
数据加载中...
 
   



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

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