Hello Mathias,
M> I did not understand that you could use the entries in a
M> command list as a script in itself. Not without using the
M> *Script Run command, that is.
That is how this particular "Special command list" works.
There are also some other Special Lists which are always run
as scripts, for example: Monitor, Reconfigure, Shutdown.
Some of the other Special Lists are seen as a collection
of individual items, which are not run as scripts.
For a complete list of different kinds of command lists,
see Help, Index "command lists - special lists" and scroll
to the bottom of the page.
M> ... Next I have a "more command" that looks like this ...
Because the whole command list "ClipCaptured" is run as a script
(every time you do a Cut or Copy or Append to the clipboard)
it is better not to use the More commands box.
Just use one command in each item's Left command. Then each item
in the command list is equivalent to one line in a script file.
Or if you prefer scripts in text files, only have one item
in the ClipCaptured list, with Left command: runfile.saveclip
________________________________________________
Because this script (either the script which IS the ClipCaptured
command list, or the file based script it runs, if you prefer)
is run every time you do a Cut or Copy, it's a good idea to make
it efficient; therefore it's best to avoid asking PP to do this:
- open the file
- append the date and time
- save and close the file
- open the file
- append a carriage return
- save and close the file
- open the file
- append the clipboard
- save and close the file
- open the file
- append a carriage return
- save and close the file
That is an exaggeration of how many writes you might be planning :-)
You can avoid all that hard disk activity, with either of these
two methods:
[A] [the easier way I think]
assemble the whole thing in a variable, including the date-time
and the clip and any CRs you want, then do only one write:
file.writeall(path, VarToWrite, "a")
[the "a" means append - otherwise it will replace the file's contents.]
in which case you are asking PowerPro to do only one file action:
- open the file
- append the value of your big variable
- save and close the file
[B] [much more difficult I think]
the other way to reduce disk activity is to use the low level
services in the file plugin, instead of higher level commands.
I'd better explain:
The file plugin has two very different groups of services:
- the higher level services which do the complete process every time
you run them: open it, read or write something, save and close it.
You can recognise this group because they all use a path in their
parameters, not "fh" for a file handle. They include:
file.writeall, file.readall
- the lower level services which split the process into smaller steps.
This group all require you to first use fh = file.open(filename,purpose)
[Where I wrote "purpose", choose one of "r" or "w" or "a" depending
whether you want to do a series of reads or writes or appends.
Where I wrote "fh" you can use any variable name to store the handle.]
Then you do several writes using any of the file plugin's low level
commands such as File.WriteLine(fh, str) or File.WriteString(fh, str).
You can recognise this group because they all use your fh variable,
instead of a path, to define which file to read or write.
Then to complete the series of commands you must do a file.close(fh)
I don't recommend method B unless you want to learn how to use
the file plugin very expertly. I just mentioned them so you will
be able to look through file.txt and pick carefully from the two
different kinds of services. You must not mix them up, like doing
a higher level command on a file which is currently "open".
Apart from only that fh group in the file plugin, all other file things
in PowerPro are what I described as the easier "higher level"
filing features, such as clip.tofileappend(...) and the Exec commands.
They open, read or write, then save and close the file.
_____________________________________________________
Phew! having got through that minefield, let's look at your script...
M> What I did not understand, though, was what that extra
M> "Clip.TextAppend()" should do. Can you explain? The manual says:
M> "Append following text to clipboard. If no text, a new line is appended."
M> What "following text"? There is nothing between the brackets.
Normally you use: Clip.TextAppend("literal text")
or: Clip.TextAppend(var1)
In those examples, "literal text", or the contents of your var1,
are what Help describes as "following text" which will be appended
to the clipboard.
If there is nothing between the brackets [which Help describes as
"If no text"] then it should append a new line to the clipboard.
x> Just to test it out, I added it to my script, and the result was that
x> the script went haywire. It appended and appended and appended stuff
x> in some kind of feedback loop. Scary!
I think that is because every time you do a Clip.TextAppend(...)
[no matter whether the brackets are empty or not]
Powerpro sees that the clipboard got changed and "captures" it.
So it runs your ClipCaptured list, which tells it to do another
Clip.TextAppend(...) which makes it run the ClipCaptured list
again ... forever.
Yes, you have discovered that you should not use Clip.TextAppend(...)
nor clip.copy, etc, in the ClipCaptured list or in a script run from it.
I didn't think of that -- I just included Clip.TextAppend() because
Sean used it in his message -- he never makes mistakes; this is his
first mistake I have ever seen :-)
OK so we have to make our big assembled VarToWrite, which we will
then write to the file with: file.writeall(path, VarToWrite, "a")
and we cannot use any clip appends to do it or we'll get an
infinite loop. So we should use string assembly tricks with ++
instead of any clipboard commands.
This is an ugly but safe way to add a CR to a variable:
esc(?"\r\n",?"\")
or for a double CR line space: esc(?"\r\n\r\n",?"\")
NB: Yahoo will split this next long line with its hard wordwrap:
VarToWrite = shortdate ++" "++ xtime ++ esc(?"\r\n",?"\")
++ clip.get ++ esc(?"\r\n",?"\")
;; make the above one line
file.writeall(path, VarToWrite, "a")
If you are still reading this, I admire your patience :)
Alan Martin
Attention: PowerPro's Web site has moved: http://www.ppro.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/