mirror of
https://github.com/sasjs/core.git
synced 2026-01-07 17:40:05 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7406288d79 |
6
all.sas
6
all.sas
@@ -18831,7 +18831,7 @@ data _null_;
|
|||||||
put ' ';
|
put ' ';
|
||||||
put '-- open file and perform the substitution ';
|
put '-- open file and perform the substitution ';
|
||||||
put 'file = io.open(fpath,"r") ';
|
put 'file = io.open(fpath,"r") ';
|
||||||
put 'fcontent = file:read() ';
|
put 'fcontent = file:read("*all") ';
|
||||||
put 'file:close() ';
|
put 'file:close() ';
|
||||||
put 'fcontent = string.gsub( ';
|
put 'fcontent = string.gsub( ';
|
||||||
put ' fcontent, ';
|
put ' fcontent, ';
|
||||||
@@ -18846,7 +18846,7 @@ data _null_;
|
|||||||
put 'io.close(file) ';
|
put 'io.close(file) ';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%inc "%sysfunc(pathname(work))/ml_gsubfile.lua";
|
%inc "%sysfunc(pathname(work))/ml_gsubfile.lua" /source2;
|
||||||
|
|
||||||
%mend ml_gsubfile;
|
%mend ml_gsubfile;
|
||||||
/**
|
/**
|
||||||
@@ -19240,7 +19240,7 @@ data _null_;
|
|||||||
put '-- JSON.LUA ENDS HERE ';
|
put '-- JSON.LUA ENDS HERE ';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%inc "%sysfunc(pathname(work))/ml_json.lua";
|
%inc "%sysfunc(pathname(work))/ml_json.lua" /source2;
|
||||||
|
|
||||||
%mend ml_json;
|
%mend ml_json;
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
build.py
2
build.py
@@ -22,7 +22,7 @@ for file in files:
|
|||||||
for line in infile:
|
for line in infile:
|
||||||
ml.write(" put '" + line.rstrip().replace("'","''") + " ';\n")
|
ml.write(" put '" + line.rstrip().replace("'","''") + " ';\n")
|
||||||
ml.write("run;\n\n")
|
ml.write("run;\n\n")
|
||||||
ml.write("%inc \"%sysfunc(pathname(work))/" + name + ".lua\";\n\n")
|
ml.write("%inc \"%sysfunc(pathname(work))/" + name + ".lua\" /source2;\n\n")
|
||||||
ml.write("%mend " + name + ";\n")
|
ml.write("%mend " + name + ";\n")
|
||||||
|
|
||||||
ml.close()
|
ml.close()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ end
|
|||||||
|
|
||||||
-- open file and perform the substitution
|
-- open file and perform the substitution
|
||||||
file = io.open(fpath,"r")
|
file = io.open(fpath,"r")
|
||||||
fcontent = file:read()
|
fcontent = file:read("*all")
|
||||||
file:close()
|
file:close()
|
||||||
fcontent = string.gsub(
|
fcontent = string.gsub(
|
||||||
fcontent,
|
fcontent,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ data _null_;
|
|||||||
put ' ';
|
put ' ';
|
||||||
put '-- open file and perform the substitution ';
|
put '-- open file and perform the substitution ';
|
||||||
put 'file = io.open(fpath,"r") ';
|
put 'file = io.open(fpath,"r") ';
|
||||||
put 'fcontent = file:read() ';
|
put 'fcontent = file:read("*all") ';
|
||||||
put 'file:close() ';
|
put 'file:close() ';
|
||||||
put 'fcontent = string.gsub( ';
|
put 'fcontent = string.gsub( ';
|
||||||
put ' fcontent, ';
|
put ' fcontent, ';
|
||||||
@@ -39,6 +39,6 @@ data _null_;
|
|||||||
put 'io.close(file) ';
|
put 'io.close(file) ';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%inc "%sysfunc(pathname(work))/ml_gsubfile.lua";
|
%inc "%sysfunc(pathname(work))/ml_gsubfile.lua" /source2;
|
||||||
|
|
||||||
%mend ml_gsubfile;
|
%mend ml_gsubfile;
|
||||||
|
|||||||
@@ -389,6 +389,6 @@ data _null_;
|
|||||||
put '-- JSON.LUA ENDS HERE ';
|
put '-- JSON.LUA ENDS HERE ';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%inc "%sysfunc(pathname(work))/ml_json.lua";
|
%inc "%sysfunc(pathname(work))/ml_json.lua" /source2;
|
||||||
|
|
||||||
%mend ml_json;
|
%mend ml_json;
|
||||||
|
|||||||
@@ -30,4 +30,37 @@ run;
|
|||||||
iftrue=("&str1"="&str"),
|
iftrue=("&str1"="&str"),
|
||||||
desc=Check that simple replacement was successful,
|
desc=Check that simple replacement was successful,
|
||||||
outds=work.test_results
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test 2 - replace from additional line
|
||||||
|
*/
|
||||||
|
%global str2 strcheck2 strcheck2b;
|
||||||
|
%let file2=%sysfunc(pathname(work))/file2.txt;
|
||||||
|
%let pat2=replace/me;
|
||||||
|
%let str2=with/this;
|
||||||
|
data _null_;
|
||||||
|
file "&file2";
|
||||||
|
put 'line1';output;
|
||||||
|
put "&pat2";output;
|
||||||
|
put "&pat2";output;
|
||||||
|
run;
|
||||||
|
%mp_gsubfile(file=&file2, patternvar=pat2, replacevar=str2)
|
||||||
|
data _null_;
|
||||||
|
infile "&file2";
|
||||||
|
input;
|
||||||
|
if _n_=2 then call symputx('strcheck2',_infile_);
|
||||||
|
if _n_=3 then call symputx('strcheck2b',_infile_);
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&strcheck2"="&str2"),
|
||||||
|
desc=Check that multi line replacement was successful (line2),
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&strcheck2b"="&str2"),
|
||||||
|
desc=Check that multi line replacement was successful (line3),
|
||||||
|
outds=work.test_results
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user