Hi Edward,
> I suppose this would work, but it's not "safe" in the sense that it
> will use the headline text, rather than a unique gnx, to identify
> nodes that should be clones.
To satisfy my curiosity... does, or can, findTopLevelNode() return the
gnx? And can the gnx be given to insertAfter() and insertAsNthChild()?
And if so, would this be the solution to making it "safe"?
> create a python script that would import the information directly into
> a Leo outline. It that works it will be much simpler than the way you
> are proposing.
OK, this sounds fine as long as the Python code isn't too complicated
for a newbie. :D The bulk of the information I want to import into Leo
is in the proprietary format of the ProvideX (PVX) language (somewhat
similar to VBasic), which is why I was using the intermediate file.
The information to be imported is stored natively in three forms:
a) Excel spreadsheet
b) tokenized PVX source code
c) a b-tree like PVX datafile
The first two cells of the Excel spreadsheet will become the cloned
node's headline and body text, respectively. Other cells need to be
looked at for selecting which rows to import.
Each of the above import sources will contain different headlines/body
text, and would need to be merged separately (e.g., three different
imports) into an existing .leo file.
I agree a Python script to import the above directly into Leo would be
the most direct way, but I don't see how b) and c) could be done. I also
don't know how a) would be handled, but I'm guessing someone has already
done this (maybe Python can open the Excel spreadsheet using DDE???).
The first import method I considered was leoRemote:
http://tinyurl.com/25r5pkj and in particular please read the last post
in the thread at http://tinyurl.com/293r57z
From PVX, I can easily open a TCP port to a listening server on the
same PC running PVX (and Leo) or on a different server box entirely.
That's easy.
What's confusing to me about the leoRemote thread I refer to above is this:
>Leoremote is not using network sockets, just local sockets for inter-
>process communication.
I don't understand the difference between "network sockets" and "local
sockets." Perhaps PVX just shields me from having to deal with the
difference.
Does "local socket" mean communication with Leo at 127.0.0.1, port 1?
And does "network socket" mean, say, a public IP port like
209.191.122.70, port 1?
If I wrote a PVX program to communicate with leoRemote, what would the
"conversation" look like? Something like ftp?
S=Server (leoRemote), C=Client (a PVX program)
C: [opens file handle at TCP address 127.0.0.1, port 1]
S: [sends a greeting banner? maybe the Leo version#?]
C: [somehow sends a command to Leo to open an existing file OR to create
a new file, and tells Leo the file name]
S: [tells C file was opened successfully (for an existing file or new
file), or that the file was not found (for an existing file)]
C: [if S sends an error back about the open, C deals with it, otherwise...]
A loop starts between C and S, ending when C closes the TCP connection:
C: [sends command to create new node or a new child node, with headline
text and optional body text]
S: [responds to client with gnx if successful insertion, else error]
- OR -
C: [sends command to insert a new CLONE node or new child CLONE node,
passing gnx and no body text]
S: [success or failure response]
In the case of using leoRemote, I think the Client has to be in charge
of keeping track of the gnx to be used for clone nodes? Can do, but
because there will be three separate import sessions, I'll also need a
way to retrieve the gnx of a node based on headline text:
C: [sends command to retrieve gnx with headline text of node's gnx to get]
S: [sends gnx, or error]
Or is there a better way?
--Todd
-------- Original Message --------
Subject: Re: Creating outline file programmatically - any samples?
From: Edward K. Ream <[email protected]>
To: [email protected]
Date: Monday, December 20, 2010 7:32:16 AM
On Sat, Dec 18, 2010 at 4:37 AM, taa, Leo Newbie<[email protected]> wrote:
Do I know what I'm doing? No. Do I know Python? No. But I can study the code
to try to figure things out as best I can. Then holler for help on this
forum. :D
Always a good plan :-)
So you want '~' to denote a clone? I suppose this would work, but
it's not "safe" in the sense that it will use the headline text,
rather than a unique gnx, to identify nodes that should be clones.
Before getting into details, I think it might be best to step back and
think of some alternatives. Rather than create a new file format, and
complex code to parse same, my inclination would be to create a python
script that would import the information directly into a Leo outline.
It that works it will be much simpler than the way you are proposing.
In other words, creating an intermediate file which you then import
creates a very complex unnecessary step. If you have information you
want to import, it will probably be much easier to open that
information in a Leo script, which then creates nodes using
p.insertAsNthChild or p.insertAfter.
HTH. Please feel free to continue this conversation. It's interesting.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.