| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

FOR i=2 TO RECCOUNT()
GO i
SKIP -1
k_1d=_1d
k_1x=_1x
k_1t=_1t
GO i
REPLACE _1dxx WITH '_1DXX' FOR '_'\$k_1d AND '_'\$_1d AND RECNO()=i
REPLACE _1dxx WITH '_1DXX' FOR '_'\$k_1x AND '_'\$_1x AND RECNO()=i
REPLACE _1dxx WITH '_1DXX' FOR '_'\$k_1t AND '_'\$_1t AND RECNO()=i
FOR NOT '_'\$_1dxx AND ('_'\$k_1d OR '_'\$k_1x OR '_'\$k_1t) AND RECNO()=i
ENDFOR

[此贴子已经被作者于2020-9-12 21:17编辑过]

```USE b2 IN 0 ALIAS t1
USE b2 IN 0 ALIAS t2 AGAIN
SELECT t1
SET RELATION TO RECNO()+1 INTO "t2"
REPLACE ALL t2._1dxx  WITH IIF("_"\$t1._1d AND "_"\$t2._1d OR "_"\$t1._1x AND "_"\$t2._1x OR "_"\$t1._1t AND "_"\$t2._1t, "_1DXX", "");
t2._1dxxf WITH IIF(EMPTY(t2._1dxx), "_1DXXF", "")
SELECT * FROM t1```

```**转换结构格式
SELECT jnh, .F. _1dxx, ICASE(!EMPTY(_1d),1,!EMPTY(_1x),2,!EMPTY(_1t),3,0) _1dxt;
FROM b2 INTO CURSOR t1 READWRITE
SELECT _1dxt FROM t1 INTO CURSOR t2
SELECT t2
SET RELATION TO RECNO()+1 INTO "t1"
REPLACE ALL t1._1dxx  WITH t2._1dxt>0 AND t1._1dxt==t2._1dxt
SELECT jnh,;
IIF(_1dxx,"_1DXX",IIF(_1dxt>0,"_1DXXF","      ")) _1dxx,;
ICASE(_1dxt==1,"_1D",_1dxt==2,"_1X",_1dxt==3,"_1T","   ") _1dxt FROM t1
** 原结构格式显示
SELECT jnh,;
IIF(!_1dxx AND _1dxt>0,"_1DXXF","      ") _1dxxf,;
IIF(_1dxx,"_1DXX","     ") _1dxx,;
IIF(_1dxt==1,"_1D","   ") _1d,;
IIF(_1dxt==2,"_1X","   ") _1x,;
IIF(_1dxt==3,"_1T","   ") _1t FROM t1
RETURN```

[此贴子已经被作者于2020-9-13 09:43编辑过]

FOR i=2 TO RECCOUNT()
GO i
SKIP -1
k_1d=_1d
k_1x=_1x
k_1t=_1t
GO i
REPLACE _1dxx WITH '_1DXX' FOR '_'\$k_1d AND '_'\$_1d AND RECNO()=i
REPLACE _1dxx WITH '_1DXX' FOR '_'\$k_1x AND '_'\$_1x AND RECNO()=i
REPLACE _1dxx WITH '_1DXX' FOR '_'\$k_1t AND '_'\$_1t AND RECNO()=i
FOR NOT '_'\$_1dxx AND ('_'\$k_1d OR '_'\$k_1x OR '_'\$k_1t) AND RECNO()=i
ENDFOR

十多年前学了点VFP6.0，对SQL、数组等都未接触过，统计程序很原始，且丢了近十年，现因统计需要，又开始接触它。
自在此论坛以来，在老师们的帮助指导下，学到了许多知识，基本全新的，方法、知识、思维方式都是全新的，受益非浅。为了优化我的传统代码，特别是运行速度，能让几万条记录在较短的时间统计出结果，我在此陆续将需要解决的主要问题发上来，请老师们指点帮助，希望能一直关注此帖后续，谢谢！

**转换结构格式
SELECT jnh, .F. _1dxx, ICASE(!EMPTY(_1d),1,!EMPTY(_1x),2,!EMPTY(_1t),3,0) _1dxt;
FROM b2 INTO CURSOR t1 READWRITE
SELECT _1dxt FROM t1 INTO CURSOR t2
SELECT t2
SET RELATION TO RECNO()+1 INTO "t1"
REPLACE ALL t1._1dxx  WITH t2._1dxt>0 AND t1._1dxt==t2._1dxt
SELECT jnh,;
IIF(_1dxx,"_1DXX",IIF(_1dxt>0,"_1DXXF","      ")) _1dxx,;
ICASE(_1dxt==1,"_1D",_1dxt==2,"_1X",_1dxt==3,"_1T","   ") _1dxt FROM t1
** 原结构格式显示
SELECT jnh,;
IIF(!_1dxx AND _1dxt>0,"_1DXXF","      ") _1dxxf,;
IIF(_1dxx,"_1DXX","     ") _1dxx,;
IIF(_1dxt==1,"_1D","   ") _1d,;
IIF(_1dxt==2,"_1X","   ") _1x,;
IIF(_1dxt==3,"_1T","   ") _1t FROM t1
RETURN

SELECT t2
SET RELATION TO RECNO()+1 INTO "t1"

REPLACE ALL t1._1dxx  WITH t2._1dxt>0 AND t1._1dxt==t2._1dxt
t2的上1行与t1的当前行的_1dxt相等时，为.T.?

SELECT t2
SET RELATION TO RECNO()+1 INTO "t1"

REPLACE ALL t1._1dxx  WITH t2._1dxt>0 AND t1._1dxt==t2._1dxt
t2的上1行与t1的当前行的_1dxt相等时，为.T.?

Powered by Discuz, Processed in 0.057589 second(s), 8 queries.