Skip to content

Commit

Permalink
fix(CompareRTFWithDataset) 文件被占用导致无法进行比较 (#31)
Browse files Browse the repository at this point in the history
使用终端命令复制一份副本,读取副本的内容,这样就可以规避文件被占用导致无法读取的问题。
  • Loading branch information
Snoopy1866 authored Jun 17, 2024
1 parent bd8c7b4 commit 20b4a84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions gbk/CompareRTFWithDataset.sas
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@
%end;


/*2. 调用 %ReadRTF 读取RTF文件*/
%ReadRTF(file = "&rtfloc", outdata = _tmp_rtf(drop = obs_seq), compress = yes, del_rtf_ctrl = yes);
/*2. 读取RTF文件*/
/*2.1 复制一份文件,规避文件已被外部打开导致读取冲突的问题*/
X "copy ""&rtfloc"" ""&rtfloc.-copy"" & exit";

/*2.2 调用 %ReadRTF 读取文件*/
%ReadRTF(file = "&rtfloc.-copy", outdata = _tmp_rtf(drop = obs_seq), compress = yes, del_rtf_ctrl = yes);

/*2.3 删除复制的文件*/
X "del ""&rtfloc.-copy"" & exit";

%if &readrtf_exit_with_error = TRUE %then %do;
X mshta vbscript:msgbox("&readrtf_exit_with_error_text",4144,"错误信息")(window.close);
Expand Down
11 changes: 9 additions & 2 deletions utf8/CompareRTFWithDataset.sas
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@
%end;


/*2. 调用 %ReadRTF 读取RTF文件*/
%ReadRTF(file = "&rtfloc", outdata = _tmp_rtf(drop = obs_seq), compress = yes, del_rtf_ctrl = yes);
/*2. 读取RTF文件*/
/*2.1 复制一份文件,规避文件已被外部打开导致读取冲突的问题*/
X "copy ""&rtfloc"" ""&rtfloc.-copy"" & exit";

/*2.2 调用 %ReadRTF 读取文件*/
%ReadRTF(file = "&rtfloc.-copy", outdata = _tmp_rtf(drop = obs_seq), compress = yes, del_rtf_ctrl = yes);

/*2.3 删除复制的文件*/
X "del ""&rtfloc.-copy"" & exit";

%if &readrtf_exit_with_error = TRUE %then %do;
X mshta vbscript:msgbox("&readrtf_exit_with_error_text",4144,"错误信息")(window.close);
Expand Down

0 comments on commit 20b4a84

Please sign in to comment.