如何将逗号分隔每行一对儿的文本读入变量
如何将逗号分隔每行一对儿的文本读入变量
DBF中有一个MEMO列名为“判断条件”,内容如下
纸张方向,o.ORIENTATION=0
左边距,ALLTRIM(STR(o.LeftMargin,10,4))='85.0500'
上边距,ALLTRIM(STR(o.TopMargin,10,4))='56.7000'
右边距,ALLTRIM(STR(o.RightMargin,10,4))='85.0500'
下边距,ALLTRIM(STR(o.BottomMargin,10,4))='56.7000'
纸宽,ALLTRIM(STR(o.PAGEWIDTH,10,4))='521.6500'
纸高,ALLTRIM(STR(o.PAGEHEIGHT,10,4))='737.1000'
我想用如下循环逐行地将逗号前的内容(如 纸张方向)赋值给变量op,将逗号后的内容(如 ALLTRIM(STR(o.LeftMargin,10,4))='85.0500'
)赋给变量cond
For i=1 to MEMLINES(判断条件)
op=xxxx
cond=yyyy
利用op和cond进行其它操作
Next
请问我的循环中怎么写?我知道mline(i)可以取到第i行内容,我就是不知道如何将逗号前的内容和逗号后的内容分别取出,赋给不同的变量
[解决办法]
[code=SQL][/code]
CLEAR
CREATE CURSOR CMEMO (MBZ M)
TEXT TO CSTR NOSHOW
纸张方向,o.ORIENTATION=0
左边距,ALLTRIM(STR(o.LeftMargin,10,4))='85.0500'
上边距,ALLTRIM(STR(o.TopMargin,10,4))='56.7000'
右边距,ALLTRIM(STR(o.RightMargin,10,4))='85.0500'
下边距,ALLTRIM(STR(o.BottomMargin,10,4))='56.7000'
纸宽,ALLTRIM(STR(o.PAGEWIDTH,10,4))='521.6500'
纸高,ALLTRIM(STR(o.PAGEHEIGHT,10,4))='737.1000'
ENDTEXT
INSERT INTO CMEMO VALUES (CSTR)
SCAN
LOCAL OP(MEMLINES(MBZ)),COND(MEMLINES(MBZ))
FOR J=1 TO MEMLINES(MBZ)
OP(J)=STREXTRACT(MLINE(MBZ,J),"",",",1)
COND(J)=STREXTRACT(MLINE(MBZ,J),",","")
? J,"行=",OP(J) &&效果
? J,"行=",COND(J) &&效果
ENDFOR
ENDSCAN
[解决办法]
ClearCreate Cursor CMEMO (MBZ M)TEXT TO CSTR NOSHOW纸张方向,o.ORIENTATION=0左边距,ALLTRIM(STR(o.LeftMargin,10,4))='85.0500'上边距,ALLTRIM(STR(o.TopMargin,10,4))='56.7000'右边距,ALLTRIM(STR(o.RightMargin,10,4))='85.0500'下边距,ALLTRIM(STR(o.BottomMargin,10,4))='56.7000'纸宽,ALLTRIM(STR(o.PAGEWIDTH,10,4))='521.6500'纸高,ALLTRIM(STR(o.PAGEHEIGHT,10,4))='737.1000'ENDTEXTInsert Into CMEMO Values (CSTR)lnArrayRowNum=Alines(aArray,Strtran(Strtran(CSTR,',A',Chr(13)+'A'),',o',Chr(13)+'o'))For I=1 To lnArrayRowNum ?aArray(I)Endfor