X++按照如图的文本文件,取出对应的每个字段值,分配给相关的表字段。
View Code
class ReadTxt { } void ReadTxt() { System.IO.StreamReader m_streader; InteropPermission m_Perm = new InteropPermission(InteropKind::ClrInterop); Notes m_Notes; str s; int i=0; container c; ; m_Perm.assert(); m_streader = new System.IO.StreamReader(@"C:\Users\dingkui\Desktop\3.txt"); while(int642int(m_streader.Peek())>0) { s = m_streader.ReadLine(); m_Notes += s; s = s + " "; this.handleTxt(s); i++; } m_streader.Close(); m_streader.Dispose(); CodeAccessPermission::revertAssert(); } void handleTxt(str _s) { str s1,s2,s3; boolean flag = true; container c; int num=2,j; ; do { s1 = substr(_s,1,strfind(_s,',',0,strlen(_s))-1); s3 = strRtrim(s1); c = conIns(c,num,strRtrim(s3)); s2 = substr(_s,strlen(s1)+2,strlen(_s)); s2 = strLtrim(s2); //c = conIns(c,num,s2); _s = s2; num++; if(_s == "") { flag = false; continue; } } while(flag); for(j=1;j<=conlen(c);j++) { info(conpeek(c,j)); } pause; } static void main(Args _args) { ReadTxt rt; ; rt = new ReadTxt(); rt.AXReadTxt(); }
运行代码得到如图的结果