Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby kunkel321 » Thu Mar 20, 2014 4:08 pm

Hi Volker!
Many thanks for the feedback. :D
It actually did occur to me to append the name of the parent node to the save-to dir path--I just couldn't find how.

I'm not sure what you mean by 'save the "if".' :?:

I tried with note.plainText, but got an error:
Image
and the text files were not created.

if I use note.to.plain, then the text files are created, but I keep getting the error telling me there is a "=" at Line 1, Col 1...
===========

Extra note: Given that the "basedir = new File("C:/Users/swkunkel/CaseNotes", it.parent.text)" is is exactly the same on each line, I will attempt to condense my logic statement...
I'll put
IF parent = X or Y or Z
THEN basedir = new File("C:/Users/swkunkel/CaseNotes", it.parent.text)
ELSE
THEN basedir = ""


Thanks again :D
kunkel321
 
Posts: 131
Joined: Thu Aug 16, 2012 4:23 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby boercher » Fri Mar 21, 2014 12:44 am

kunkel321 wrote:I'm not sure what you mean by 'save the "if".'

This line
Code: Select all
c.find{ it.hasStyle('Student-Boy') || it.hasStyle('Student-Girl') }.each {
replaces
Code: Select all
c.findAll().each {
if (it.hasStyle('Student-Boy') | it.hasStyle('Student-Girl')) {

kunkel321 wrote:I tried with note.plainText, but got an error:

Right, replace ''note.plainText'' by ''note.to.plain'' .
kunkel321 wrote:if I use note.to.plain, then the text files are created, but I keep getting the error telling me there is a "=" at Line 1, Col 1...
===========

Well you should be able to find these equal signs... Of course I assume that your script lives in a .groovy file in the scripts directory and neither in a formula or in the script editor - does it?

Volker
boercher
 
Posts: 644
Joined: Tue Jul 26, 2011 7:13 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby kunkel321 » Fri Mar 21, 2014 4:18 pm

boercher wrote: ...Well you should be able to find these equal signs... Of course I assume that your script lives in a .groovy file in the scripts directory and neither in a formula or in the script editor - does it?
It does indeed live in the script folder... Now that you mention it though, I have recently gotten back into using Freeplane after messing about with MS OneNote for about 6 months... I was trying different editors and did experiments with the built-in FP Script Editor a little. I'm pretty sure I didn't save anything in it though... If I did, would it appear here?
Image

Is there maybe a way to clean out the "script editor cache?" Or is there such a thing?

To WIT, here is the script file open in Notepad++, with the file path and with colum 1, Ln 1 highlighted...
Image

There is no "=" in that position, and I'm pretty sure there never has been. (?) IDK.. Weird.
kunkel321
 
Posts: 131
Joined: Thu Aug 16, 2012 4:23 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby boercher » Mon Mar 24, 2014 12:23 am

There is nothing like a cache for the script editor. Make sure that what you execute is actually the script that you edit: Check the paths (e.g. Freeplane/1.3.x/scripts vs. Freeplane/1.2.x/scripts).

Volker
boercher
 
Posts: 644
Joined: Tue Jul 26, 2011 7:13 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby kunkel321 » Mon Mar 24, 2014 4:20 pm

The two script folders I see on my installation are 1.3x and 1.4x... 1.3x is the one that FP seems to be reading from. I did somehow have a couple groovy scripts in the 1.4x folder, but that doesn't seem to be the problem. If I make a change to my "ExtractNotes2" script (in 1.3x), then I immediately see the change upon running it in FP, so I'm sure that I'm running the right script. Also, I changed all of my old working scripts to ".txt" extensions just to be sure.

Here are some interesting observations:
I added a bit of junk code to line one, just so it would move everything else down.
Image

FP is still "seeing" the erroneous "=" at Ln 1, Col 1 though...

Also notice: If I do actually put an equals sign there...
Image

Then I get a different, more specific, error message. The second image shows the path of the errant script, whereas the top one just shows "Script1.groovy" rather than the path... Also, what seems relevant, is that even though the message says "Start up Failed." The text files *are* still created in the top example, whereas in the bottom one (where I put an actual "=") the script does not create the files.

So... Is it possible that (in the top example), the ExtractNotes2 script actually *is* executing correctly, but then Freeplane is erroneously trying to run "Script1?"

Perhaps I will try to reinstall FP and see if there's a difference...
kunkel321
 
Posts: 131
Joined: Thu Aug 16, 2012 4:23 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby kunkel321 » Mon Mar 24, 2014 6:18 pm

Update: I purged Freeplane from my system and reinstalled it. That did not help.

I then systematically deleted different parts of the map to see if that would help--and it did!
My "cCompleted" parent has 44 children (some "Student-Boy" and some "Student-Girl"). If I delete that parent, or even delete a large portion of the children, then the mysterious "= @ Ln 1, Col 1" error never happens... I tried it a couple dozen times and it is consistent... Also, I hadn't realized it at first, but even though the notes *are* created, not all of the notes from cCompleted are created (apparently it creates about 30 to 35 of them, then fails).

So what to do? Is there a Groovy command to "wait-until-process-is-done-before-looping?"
kunkel321
 
Posts: 131
Joined: Thu Aug 16, 2012 4:23 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby dpolivaev » Mon Mar 24, 2014 7:38 pm

I suggest that you open a bug report, upload there your script and your map to let us see whether we can observe the error. Looking for reasons without being able to see the event itself could take us years otherwise.

Regards,
Dimitry
User avatar
dpolivaev
Site Admin
 
Posts: 667
Joined: Sat Jul 23, 2011 1:21 pm

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby kunkel321 » Tue Mar 25, 2014 5:59 pm

Hi Dimitry,
Thanks for the reply.
My actual map has confidential client info, so I made a copy of it and spent about three hours changing all the info to fake stuff. Ironically, when I run the script on the fake map it runs and exits correctly. :evil:

Interesitngly, I also made an alternate version of the script, where I changed
Code: Select all
basedir = new File("C:/Users/swkunkel/CaseNotes", it.parent.text)
into
Code: Select all
basedir = new File("C:/CaseNotes", it.parent.text)
so that it would be easier for you to work with.

I had the path and everything correct, but various script errors popped up with that too.

I'm not going to follow up on that bug. I will make a ticket and upload the stuff for you to experiment with RE the "=" at Ln 1 bug... I'm not sure if it will be helpful for you though...
kunkel321
 
Posts: 131
Joined: Thu Aug 16, 2012 4:23 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby kunkel321 » Tue Mar 25, 2014 9:14 pm

Hey I think I captured that bug (and fed it to the mantis).

Yesterday I was pretty sure I'd systematically tried every node in the "cCompleted" folder, and not been able to find a bad node.
Today I was able to find it though! (At least I think). I was able to do it, because I figured out that ALL of the node notes were getting made into text files except ONE.

It's interesting that in the notes of the offending node, the following string of text was located...
Pasted from <https://outlook.office365.com/owa/?wa=wsignin1.0>
(It's leftover junk from OneNote) Surely that doesn't matter though... Indeed, I removed the line of text and it did not remedy the problem...

I then changed the node's Style to "Default" and synced and the problem was gone! I changed it back to "Student-Girl" and the problem stayed gone. So... A corrupt style assignment? IDK.

That particular node had been removed when I was purging the confidential stuff from my bug-report map. I've put it back in there and named the node "Kaytlynn Dimitry." The map is in the "forDimitry2.zip" folder
https://sourceforge.net/apps/mantisbt/f ... hp?id=2126
Please try it and see if you get the error. :)
kunkel321
 
Posts: 131
Joined: Thu Aug 16, 2012 4:23 am

Re: Need Groovy help: If node.parent (‘X’) Save .TXT to C://X

Postby boercher » Wed Mar 26, 2014 11:04 pm

As has been revealed in Bug 2126 the problem comes from using

node.note

with notes starting with an equal sign which indicates a formula, which are evaluated by node.note.

If one doesn't need formula and just wants to make sure that the script works you can use

node.noteText

This property is the untransformed HTML content of the note.

Volker
boercher
 
Posts: 644
Joined: Tue Jul 26, 2011 7:13 am

Previous

Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron