>The situation is this: although I have a shortcut that can be used to open
>the notepad to a new note, it opens this note in the unfiled folder.
>The note would then have to be filed manually to the appropriate
>folder. A script that would open the notepad to a new note in the
>required folder would be great, but I have no idea how to write one!
First try to create a new note and open the NotePad to it. It's not
really hard, everything is documented.
Go to Programmer's Reference, page 16-81.
You can also have a look at Programmer's Guide, page 19-32.
There it explains how to obtain a reference to the NotePad application.
So you'll need to store this reference in a local variable. Just do:
local frame theNotePadApp := <paste the code here to get a reference
to the NotePad application>;
The semi colon ends the command.
local indicates that this is a temporary variable which will be
destroyed when the function will return.
frame indicates that this variable is a frame (this is optional).
theNotePadApp is the name of our variable.
the colon followed by the equal sign is an assignment operator. It
means, put the reference into.
Add a comment for this line:
// Get a reference to the NotePad application.
Page 16-82 they say that the NotePad application may not exist.
Therefore, we gonna only work on it if it is present.
So just after found its reference, put an if statement:
if theNotePadApp then
begin
end; // if theNotePadApp then
Between begin and end, we gonna do the actual work.
Add a comment just after the begin:
// The NotePad application is present, we can work with it.
Now, page 16-82, they say that there are two methods we can call.
One which creates a new note and optionally adds it.
One which adds a new note that was created with the first method and
optionally display it in the notepad application (if it is open).
So the trick is:
a/ create the note, but don't add it to the soup.
b/ open the notepad application (or bring it to front if it wasn't).
c/ add the note to the notepad app and display it.
For step a, it's pretty straightforward.
The doc says:
<paperroll>:<Name of the method>( <list of parameters> )
which means that to call it, you need to:
a/ replace <paperroll> with the reference to the notepad application
you have. This is the object.
b/ put the colon to means that you're calling a method of this object.
c/ put the name of the method.
d/ put the list of parameters separated by commas and between
parentheses just as in the doc.
e/ put a semi-colon to end the statement.
Here, we have two parameters.
The first one is the content of the note. You don't want anything so
put an empty string there: "".
The second one is a boolean to know if you want to add the note. You
don't want to do it yet, so put nil.
What the Programmer's Reference doesn't say, sadly, is that the note
object is returned and it's of course a frame.
So put it in a local variable which you declare just like you did
before for the notepad application. Call it for example theNote.
Also put a comment just after (or before) this line to explain what
you're doing. (you know how to write comments, don't you?)
Then, still between begin and end, you need to open the notes application.
To do this, it's not very hard but it's not explained in these pages,
you need to call the Open method of the NotePad app which doesn't
take any argument: just put (). Look at page 2-20 of the Programmer's
Reference if you want to know more.
And finally, add the note and tell the note pad to display it by
calling the second notepad method documented page 16-82. You probably
want to file it to the default store (the store where new documents
and packages are created), so put nil for the third argument as
documented.
Replace the long comment at the top of the script to explain what
we're doing and test it.
Next step is to file the note to a give folder. It's not really hard,
it's just a matter of adding one line, but let's do it once you've
finished this 6 lines script and it works properly.
Paul
-- Home page: http://www.kallisys.com/ Newton-powered WebServer: http://newt.dyndns.org:8080/-- This is the Newtontalk mailinglist - http://www.newtontalk.net To unsubscribe or manage: visit the above link or mailto:newtontalk-request_at_newtontalk.net?Subject=unsubscribe
This archive was generated by hypermail 2.1.2 : Wed Oct 03 2001 - 12:01:02 EDT