replace - Replace current execution file.
replace([keep_variables: bool, ct:"string",error:variable,textfile:binaryfile:file:compilefile:"file", …]);
This function is used to replace current execution files.
At first, the current output buffer is clear, than the specify file is compile/run/read and the program stop.
If parameter textfile is used with a file, than the file is read.
If parameter binaryfile is used with a file, than the file is assumed to to be a compiled extenso file. The file is executed and the result return.
If parameter compilefile is used with a file, than the file is assumed to to be a source extenso file. The file is compile, executed and the result is return.
If parameter file is used with a file, or if only a file name is given, than there is 3 possibilities:
res={_{ replace(error:t,"/html/oijfwi"); t;}}.
{"errmsg":"At line=1,errcode=20 Can't open file: /usr/local/website/v5/html/oijfwi: No such file or directory",
"filename":"/usr/local/website/v5/html/tests/test.sn",
"cfile":"exceptions.c",
"errcode":20,
"filefrom":"/usr/local/website/v5/html/tests/test.sn",
"line":1,
"cline":540,
"compileuid":0,
"date":"2013-09-19 07:57:43"}.
Note: In the followings examples, the _ between the { should be removed to make it work.
res={_{ replace("/html/oijfwi"); }}. return .*Can't open file.*
res={_{ replace("/html/oijfwi.sn"); }}. return .*Can't open file.*
res={_{ replace(error:t,"/html/oijfwi"); t.errcode;}}. return 20.
res={_{ replace(error:t,"/html/oijfwi.sn"); t.errcode}}. return 20.
res={_{ replace(error:t,"/html/replace1.html"); t}}. return simple text file
res={_{ replace(); }}. return
res={_{ replace("/html/replace1.html"); }}. return simple text file
res={_{ replace(ct:"text/xml","/html/replace1.html"); }}. return simple text file
res={_{
remove("/tmp/tib.sn");
write(data:"test {{ a=5; a * 6; }}",file:"/tmp/tib.sn");
compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
replace("/tmp/tib.snc");
}}. return test 30
res={_{
remove("/tmp/tib.sn");
write(data:"test {{ a=5; a * 6; }}",file:"/tmp/tib.sn");
compile(error:t,src:"/tmp/tib.sn",dst:"/tmp/tib.snc");
replace(binaryfile:"/tmp/tib.snc");
}}. return test 30
res={_{
remove("/tmp/tib.sn");
write(data:"test {{ a=5; a * 6; }}",file:"/tmp/tib.sn");
replace(file:"/tmp/tib.sn");
}}. return test 30
res={_{
remove("/tmp/tib.sn");
write(data:"test {{ a=5; a * 6; }}",file:"/tmp/tib.sn");
replace("/tmp/tib.sn");
}}. return test 30
res={_{
remove("/tmp/tib.sn");
write(data:"test {{ a=5; a * 6; }}",file:"/tmp/tib.sn");
replace(compilefile:"/tmp/tib.sn");
}}. return test 30
Written by Pierre Laplante, <laplante@sednove.com>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
1.0 2014-09-09 21:24:14 laplante@sednove.com