Menu

Macro problem

2007-08-08
2012-11-13
  • Nobody/Anonymous

    First of all, i think the notepad++ is great! :)
    But I have a little problem I don't know how to solve. I am writing a simple macro that will create an empty actionscript class just from a new file and the name of the class and the cursor is at the end. Example ( | shows where the cursor is, ##are comments (not part of file))

    ##beginning of file (new)
    SomeClass|
    ##end of file

    I want it to be changed like that:

    ##beginning of file (SomeClass.as)
    package com.dev.generic {
        public class SomeClass {
            |##means 2 tabspaces and the cursor should be there
        }
    }
    ##end of file

    Instead, I get:
    ##beginning of file (new)
    package com.dev.generic {
            public class SomeClass {

    }}
    ##end of file, and I get an opened save dialog

    OK, so since saving an unsaved document opens a windows choose file dialog and i don't belive the macro has a wrapper to also record the actions there. Is there another way to automatically set a name to a file through a macro?

    Still, why is there a difference in text output.

    I record the following

    SomeClass|        ##type ".as", press "shift+home", press "ctrl+x"
                      ##now i have copied the name of the desired file

    package com.dev.generic {
       public class | ##i type everything until here, then press "ctrl+v" to paste the name
                      ##then press "backspace" 3 times to delete the ".as" extension

    package com.dev.generic {
       public class SomeClass {

       }
       }|## type " {\n\n}\n}"

    ##then i press "LEFTARROW" and "BACKSPACE" to delete the last identation
    ##then i press "UP" two times to get to the empty line and "TAB" once and "RIGHT"
    ##to get the cursor in the desired position - idented two times just below "public" word.

    Sorry for the long post, but any advice is appreciated ( i really want to understand the macro capability to its fullest, because i think it's veery useful.)

    Yours,
    Zdravko

     
    • Nobody/Anonymous

      and of course the forum treats starting whitespaces as nothing, so i repost the results of my second response using the html npsp; entity

      ##start of file
          a
          |
      ##end of file

      There is an automatic identation, but if you saved the commands and try them as macros you get

      ##start of file
          a
      |
      ##end of file

      In macros there's no direct identation :(, i think it's a bug, i mean it should do whatever it does in the editor ;)

      But still, could you help me how i can do automatic saving from macros without need of "save as" dialog since it's not "doable" via a macro?

      Thanks,
      Zdravko 

       
      • Greg Bullock

        Greg Bullock - 2007-08-10

        A bug in the macro playback causes the missing indentation.  The PlayBack function should notify NP++ when adding characters, so NP++ can take appropriate action, such as adding indentation.

        I'm sending a suggested bug fix to Don.

        Regards.
        Greg

         
    • Nobody/Anonymous

      Hi, it's me again, I found the problem.

      So, suppose you type "\ta\n"
      In the editor you'll get
      ##start of file
         a
         |
      ##end of file

      There is an automatic identation, but if you saved the commands and try them as macros you get

      ##start of file
         a
      |
      ##end of file

      In macros there's no direct identation :(, i think it's a bug, i mean it should do whatever it does in the editor ;)

      But still, could you help me how i can do automatic saving from macros without need of "save as" dialog since it's not "doable" via a macro?

      Thanks,
      Zdravko