[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [StrongED] Add at end of file?
"Richard Torrens (lists)" <Lists@xxxxxxxxxxxxxx> wrote:
> > If eg you put the extra text into a file called Extra, then you can
> > append that to a Target file with a command like
>
> > *Print Extra { >> Target }
>
> A thought. Don't quite see how to do it though.
What do you mean? You type the command as shown, putting the full filenames
into the two locations, eg:
*print adfs::4.$.extra { >> adfs::4.$.target }
The spaces around the "{" and ">>" and "}" are required. It's also possible
to use ">" rather than ">>" in a redirection command. Using ">" means the
output replaces the target file whereas ">>" means it's appended.
It works because 'print' merely sends the bytes of a file, one at a time, to
the VDU. In this case the redirection - the open and close curly brackets,
the two >> and another filename) tell RO to send them elsewhere,
specifically appending to an existing file.
I use a similar command quite often in obey files to write lines into logs,
eg:
*echo Now we will do this { >> adfs::4.$.mylogfile }
This way of using redirection can be a little more complicated in practice
than it looks here, because when one types a * command in a task window it
gets executed as you type it, but if you put the command in an Obey file and
then run that you need to take into account the way Obey files work. For
example if you're trying to get special characters into commands you
sometimes need to specify them in hexadecimal, eg "<20>" rather than as a
literal chaacter.
> > If eg one defines an alias
>
> > *Set Alias$AlterIt print extra { >> %*0 }
>
> > then one can issue
>
> > *Alterit Targetfile1
> > *Alterit Targetfile2
>
> > and so on. (It can be a little trickier than this to set up, but I'm
> > writing these notes on a windows machine, and am not about to experiment
> > with RO.)
- If that Set command is in an Obey file then the parameters used to run
that obey file will be put into the alias's definition which is not what is
required - the alias definition actually has to contain the percentage and
star - so they need defined symbolically. Worse, as it stands, inside an
Obey file RO will treat the line as
Set Alias$AlterIt print extra
and try to redirect its (non-existent) output somewhere. So the curly
brackets also need defined symbolically... Thus the Obey command processor
takes the line which is full of symbols, scans it, doesn't see parameter
names or redirection, then resolves symbols then stores the required
definition. Later when the Alias is actually used the parameters it sees
ARE used, and redirection actually occurs.
>
> > So if one has a file containing a list of target filenames, all one then
> > needs to do is insert "*Alterit " in front of each line, save the file,
> > set its type to Obey (or better TaskObey), then run it.
>
> Certainly the best suggestion so far! But I think Perl may be the best
> language. A bit slow on RISC OS!
Why use Perl when you can use the OS?
--
Jeremy C B Nicoll - my opinions are my own.
--
To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxxxxx