Question or two about MD's example extension

rcook's Avatar

rcook

19 Feb, 2024 03:37 PM

So I've now written a little Python and explored a little of the MoneyDance data model, with help from Mr. Toolbox and others here.

I'm now looking at the myextension example. I've set up Ant, unzipped the source, compiled, installed, and run -- all that seems to work. I've made a couple-of-lines modification to the example and redone everything, THAT seems to work.

Question 1: (really more of a confirmation) There won't be any debugging in eclipse or whatever IDE for this application, will there? One can't run it outside the MD environment. Has anyone tried to find a way to attach an external debugger to the MD JVM? I know that's theoretically possible, even done it once or twice, but don't remember much about it except that the environment you're attaching to would have to be set up for it.

Question 2: What is the private class ConsoleStream for? It is instantiated at the end of the AccountList constructor, into a local variable which is not accessed or accessible, as far as I can tell.

  1. 1 Posted by Stuart Beesley ... on 19 Feb, 2024 07:00 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    OK, so you are shifting to java....

    Q1.
    - Yup I have attached a debugger (IntelliJ) to the MD JVM. I use IntelliJ IDE/CE You will need to launch MD manually using the JVM debug commands - e.g.:

    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
    

    Refer my site for launch scripts that can launch MD manually with debug... Mike Bray has done this within Eclipse too..
    https://yogi1967.github.io/MoneydancePythonScripts/

    However, you will find it difficult depending on the moneydance.jar you use... Core MD is now Kotlin compiled down to java and hence the debug info does not always line up properly with the source (that is not normally present)... But yes, I have managed to do it in IJ. Mike Bray has also managed to do it in both IJ and Eclipse. (You cannot debug Python of course, only java). But if you only want to debug your own extension code, then it might work OK for you.

    Q2. PrintStream(new ConsoleStream()); is I imagine diverting the JVM's console stream. The override methods are taking the output and adding it to the accountList JTextArea and then calling .repaint() to refresh the display via a runnable... It does look like it's not being used, but if you are getting text added to the JTextArea then I suggest its working as the constructor could be diverting output and it doesn't need the result.. So does it work / actually do anything? Anyway, it's kind of confusing and I wouldn't do it that way myself. However, on reflection it does look like it isn't even being used.. Comment it out, what happens..? Really we need a better sample code as this one is very noddy and has some old stuff in it (like .processEvent() etc)

    FYI. To print to MD’s ‘console’ just use System.err.println() and other similar System.err print methods.

  2. 2 Posted by Stuart Beesley ... on 19 Feb, 2024 07:15 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Yup - you are right.. It does nothing.. I just download the sample, chopped that out.. No change.. I think that was for some sort of event feature that wrote to the console.. But it still works as-is without it - it seems....

  3. 3 Posted by Stuart Beesley ... on 19 Feb, 2024 07:37 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Refer this:

    https://stackoverflow.com/questions/60338798/why-does-printstream-p...

    You would probably have to use System.setOut() or System.setErr() for the PrintStream() to do anything. Or have code that operates on the variable created. For example, if it returned the variable and .handleEvent() could write MD events to that console.

    Anyway, as I said, much easier ways to do this I think.

  4. 4 Posted by Mike Bray (Quot... on 20 Feb, 2024 08:18 AM

    Mike Bray (Quote Loader Author)'s Avatar

    Hi, Stuart has covered most of the areas. I have my own debugging utility which prints to System.err. MD uses this for the console log so using System.err.println will print to the Console Log.

    As Stuart has mentioned I used to use Eclipse for my debugging but now us IDEA. Have a look at https://github.com/mrbray99/moneydanceproduction/wiki/Moneydance-In... for some information on this.

    It is not easy to debug the MD source but debugging your own source is straightforward once you have done the set up.

  5. 5 Posted by rcook on 20 Feb, 2024 03:35 PM

    rcook's Avatar

    I really hope I never feel the need to debug the MD source, though of course being able to step through it might help answer a question or two. But I was mostly thinking I'd be debugging my own code.

    Mike Bray's FileDisplay extension has many similarities to what I had in mind to do; I wanted to be able to view transactions after filtering by category, and eventually be able to change the category of some extensions with an eye to cleaning up the data (places where I forgot I had a category and created another, and now have transactions under both; places where I created a category starting with a capital letter, and now want to rename things so all categories are camelCase, that sort of thing).

    Mike, it does not seem that you've put your source on GitHub for public access; if there's some way I could talk you into sharing it, I think it would be a great starting point for what I have in mind. I'm willing to sign an NDA or whatever, I have no intention of attempting to sell a product with this work. And of course I'd be happy to share back with you anything I do, perhaps through 'pull request' or whatever.

    Thanks folks! It looks like this'll give me a hobby for a while!

  6. 6 Posted by dwg on 20 Feb, 2024 03:52 PM

    dwg's Avatar

    It seems to me that there are already some tools to do some of the things you talk about.

    For example the Find and Replace extension to perform some global substitutions - to change case for example.

    Also the Batch Change menu option to consolidate categories by moving transactions from one category to another then you can deleting the empty category.

  7. 7 Posted by Stuart Beesley ... on 20 Feb, 2024 05:28 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    FYI - You can fork:
    https://github.com/TheInfiniteKind/moneydance_open
    .. there are a few extensions there, including F&R ...

  8. 8 Posted by Mike Bray (Quot... on 21 Feb, 2024 02:50 PM

    Mike Bray (Quote Loader Author)'s Avatar

    Hi

    The source is in repository Moneydance, ie:https://github.com/mrbray99/Moneydance/tree/master/src

  9. 9 Posted by rcook on 21 Feb, 2024 03:22 PM

    rcook's Avatar

    I don't know how I missed that, sorry. And thanks.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac