Run a command per text line in SFK scripts with the SFK perline command.
sfk ... +perline "command #text"
for every chain text line run sfk commands(s)
like a sub function, passing the text as parameters.
options
-yes really execute. default is just to simulate
what would be done.
-setvar x put whole line text into variable x,
for easy use in a call without parameters.
-nohead does not display the [simulating:] info text.
-stoprc=n stop on return code >= n instead of default 9.
-nostop do not stop on errors regardless of rc.
command string format
each word, separated by whitespace, is a parameter.
to fill in the current chain text line use $text or #text.
perline uses a strict command format by default.
to insert characters $ or # as is type $$ or ##
with option -spat, slashpatterns like \t \q \xnn are supported.
to use multiple words as one parameter use -spat and \q ... \qquoted multi line parameters are supported in scripts
using parm trim. type "sfk script" for details.
recursion limit
if the called function calls another function by call
or perline this should not be nested too often,
otherwise sfk may crash.
see alsosfk run for the full command string format
sfk stacksize test available stack size
web referencehttp://stahlworks.com/sfk-perlineexamplessfk echo -lines 100 101 102+perline -spat "web -nodump \q.$text/xml/restart.xml\q"
on local ip's .100 .101 and .102
call a web command /xml/restart.xml. [17]
sfk sel mydir .jpg +perline -spat "echo <img src=\q#ufile\q width=\q400\q> +tofile -append print.html"
create a file print.html containing all .jpg files of
folder mydir, shown with 400 pixels width. [28]
sfk load in.txt +perline -setvar l "call doline" -yes +end
within a script: on every line set variable l with
the full line text, then call label doline.
sfk load foldernames.txt +perline "sfk list #qtext" -yes
load a file with folder names and list contained files.
qtext adds quotes around the names for safety.