参数:
Value, RawData \Network , StartIndex ,\Hex1|IntX|\Float4|\ASCII;
- Value:
需要打包的数据, 类型包含num、dnum, byte或string,不能用数组. - RawData:
打包后返回的数据,类型为 rawbytes - \Network
填写这个参数表示打包时采用大端法否则为小端法,当可选参数为IntX或Float4时才有意义. - StartIndex
将value打包时放入rawbytes中的起始地址 - \Hex1|IntX|\Float4|\ASCII
根据Value的数据类型选择
代码参考:(长字符串写入csv文本)
点击查看代码
PROC testPackRawBytes(string msg1\NUM num1\string msg3\string msg4\string msg5\string msg6)
VAR iodev ioDevice;
VAR rawbytes raw_data;
VAR string fileName;
fileName:=CDate()+" "+GetTaskName()+".csv";
if not existCSVFile(sPath,filename,tital) creatCSVFile sPath,fileName,tital;
ClearRawBytes raw_data;
PackRawBytes cdate()+","+CTime(),raw_data,1\ASCII;
IF Present(msg1) PackRawBytes ","+msg1,raw_data,(RawBytesLen(raw_data)+1)\ASCII;
IF Present(msg2) PackRawBytes ","+msg2,raw_data,(RawBytesLen(raw_data)+1)\ASCII;
IF Present(msg3) PackRawBytes ","+msg3,raw_data,(RawBytesLen(raw_data)+1)\ASCII;
IF Present(msg4) PackRawBytes ","+msg4,raw_data,(RawBytesLen(raw_data)+1)\ASCII;
IF Present(msg5) PackRawBytes ","+msg5,raw_data,(RawBytesLen(raw_data)+1)\ASCII;
IF Present(msg6) PackRawBytes ","+msg6,raw_data,(RawBytesLen(raw_data)+1)\ASCII;
PackRawBytes "\0D\0A",raw_data,(RawBytesLen(raw_data)+1)\ASCII;
Open sPath\File:=fileName,ioDevice\Append\Bin;
WriteRawBytes ioDevice,raw_data;
Close ioDevice;
ENDPROC
浙公网安备 33010602011771号