1 NX9+VS2012
2 3 #include <uf.h> 4 #include <uf_cfi.h> 5 #include <uf_ui.h> 6 7 using std::string; 8 9 10 11 UF_initialize(); 12 13 //内容1 14 //读取文本全部内容 15 //打开本地文本文档 16 int Chan = uc4504("D:\123.txt", 1, 79);//类型为只读,后缀类型txt为79。帮助有写到,自己去查。 17 18 //读取打开的文本文档 19 char *Cbuf; 20 int Num = uc4514a(Chan, &Cbuf);//只能读一行 21 22 UF_UI_open_listing_window(); 23 //循环去读每一行 24 while ( Num>=0 ) 25 { 26 //打印 27 strcat(Cbuf, " ");//拼接字符串换行 28 UF_UI_write_listing_window(Cbuf); 29 Num = uc4514a(Chan, &Cbuf); 30 } 31 32 //释放内存 33 UF_free(Cbuf); 34 35 //关闭文本文档 36 uc4540(Chan, 0); 37 38 39 //================================================================================= 40 41 42 43 /* 44 //内容2 45 //向文本写入内容 46 //打开本地文本文档 47 int Chan1 = uc4504("D:\456.txt", 3, 209);//类型为写和替换,后缀类型CPP为209。帮助有写到,自己去查。 48 49 //写入内容 50 uc4524(Chan1, "Hello,World"); 51 52 //关闭文本 53 uc4540(Chan1, 0); 54 55 56 //================================================================================= 57 58 59 //内容3 60 //读取部分内容 61 //打开txt 62 int WenJian = uc4504("D:\789.txt", 1, 79); 63 64 //读数据 65 char *OutDate; 66 int Date1 = uc4514a(WenJian, &OutDate); 67 68 UF_UI_open_listing_window(); 69 char BufLeft[256], BufRight[256];//左值,右值 70 while (Date1 >= 0) 71 { 72 //提取左右值 73 string S1 = OutDate; 74 string Strleft = (S1.substr(0, S1.find(",")));//提取左值 75 string Strright = (S1.substr(S1.find(",") + 1, S1.find("。")));//提取右值 76 77 //将string类型转换为字符数组 78 strcpy(BufLeft, Strleft.c_str()); 79 strcpy(BufRight, Strright.c_str()); 80 81 //打印 82 UF_UI_write_listing_window(BufLeft); 83 UF_UI_write_listing_window(" "); 84 85 Date1 = uc4514a(WenJian, &OutDate); 86 } 87 88 //释放内存 89 UF_free(OutDate); 90 91 //关闭文件 92 uc4540(WenJian, 0); 93 */ 94 95 UF_terminate(); 96 97 Caesar 98 2018年10月21日
老函数uc4514
1 //读取文本全部内容 2 //打开本地文本文档 3 int ioChannelNum = uc4504("C:\PS_List\List.txt", 1, 79); 4 5 //读取打开的文本文档 6 char readBuf[256]; 7 int readLen = uc4514(ioChannelNum, readBuf);//只能读一行 8 9 UF_UI_open_listing_window(); 10 11 //循环去读每一行 12 while ( readLen>=0 ) 13 { 14 //打印 15 strcat(readBuf, " ");//拼接字符串换行 16 UF_UI_write_listing_window(readBuf); 17 readLen = uc4514(ioChannelNum, readBuf); 18 } 19 20 //关闭文本文档 21 uc4540(ioChannelNum, 0);