|
|
|
|
|
|
Convert files from windows to unix format This is done by replacing CR LF with LF.
$ include "seed7_05.s7i";
include "getf.s7i";
const proc: main is func
local
var string: file_name is "";
begin
for file_name range argv(PROGRAM) do
putf(file_name, replace(getf(file_name, "\r\n", "\n")));
end for;
end func;
Convert files from unix to windows format This is done by replacing LF with CR LF.
$ include "seed7_05.s7i";
include "getf.s7i";
const proc: main is func
local
var string: file_name is "";
begin
for file_name range argv(PROGRAM) do
putf(file_name, replace(getf(file_name, "\n", "\r\n")));
end for;
end func;
Copy all files from one directory to another directory This is done by using the predefined 'copy' function which copies whole directory hierarchies.
$ include "seed7_05.s7i";
const proc: main is func
begin
copy(argv(PROGRAM)[1], argv(PROGRAM)[2]);
end func;
Well normally you would use an operating system command for this. This example shows just how simple directory copying can be in a Seed7 script. Program that encodes and decodes with rot13This rot13 program reads from standard input and writes to standard output.
$ include "seed7_05.s7i";
const proc: main is func
local
var char: ch is ' ';
begin
ch := getc(IN);
while not eof(IN) do
if (ch >= 'a' and ch <= 'm') or (ch >= 'A' and ch <= 'M') then
ch := chr(ord(ch) + 13);
elsif (ch >= 'n' and ch <= 'z') or (ch >= 'N' and ch <= 'Z') then
ch := chr(ord(ch) - 13);
end if;
write(ch);
ch := getc(IN);
end while;
end func;
|
|