Community
    • Login

    Local active Variables

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 5 Posters 380 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alan WynneA
      Alan Wynne
      last edited by

      When Creating a new Run Command I want to do something like this:

      cmd /k && cd &CurrentActiveFilePath && C:\GCC\bin\g++.exe -o &ActiveFilenameWithoutExtension.exe >>&ActiveFilenameWithoutExtension.log

      This will invoke the compiler create the executable with the same name as the active file and also create a log file. I need access to the parameters &CurrentActiveFilePath and &ActiveFilenameWithoutExtension . in the run command popup. This run comand can be saved and executed against any file open and compile it provided i have the g++ compiler installed.

      Can anybody help with this?

      EkopalypseE mkupperM 2 Replies Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Alan Wynne
        last edited by

        @Alan-Wynne

        The manual contains them, search for FULL_CURRENT_PATH, for example.

        1 Reply Last reply Reply Quote 2
        • mkupperM
          mkupper @Alan Wynne
          last edited by

          @Alan-Wynne, besides what @Ekopalypse wrote I believe it would simplify things for you set up a run-g++.bat file that will deal with the details. It turns out to be surprisingly hard to run multiple commands using cmd /K from Notepad++ as you are dealing with parsing rules set up by Notepad++'s Run/Run thing plus the command processors rules for the cmd /K thing. Using C:\GCC\bin\run-g++.bat "$(FULL_CURRENT_PATH)" from Notepad++'s Run / Run menu will let your batch file take over the work of parsing the full file path to the file being edited in Notepad++ into a directory, the file name part, etc.

          C:\GCC\bin\run-g++.bat can be as elaborate as needed and will be easy to maintain and debug. You can take advantage of batch file things such as "%~dp1" to get the drive letter plus path for your file for the cd command or %~n1 to get the ActiveFilenameWithoutExtension part.

          Alan KilbornA 1 Reply Last reply Reply Quote 2
          • Alan KilbornA
            Alan Kilborn @mkupper
            last edited by

            @mkupper

            IMO, compiling like the OP shows is simple enough to do without creating a batch file. If it gets any more complicated, though, you are definitely right and a batch approach is the way to go.

            1 Reply Last reply Reply Quote 1
            • Alan WynneA
              Alan Wynne
              last edited by

              thanks for the input, i have foun a way to do what i need, using npp exec plugin… Create a script:

              npp_save
              cd "$(CURRENT_DIRECTORY)
              del “.\g++.$(NAME_PART).exe”
              C:\GCC\bin\g++.exe -g -o “g++.$(NAME_PART).exe” “$(FULL_CURRENT_PATH)”
              “.\g++.$(NAME_PART).exe”

              it does require npp to be running with admin priviladges though…

              Thanks for the input…

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Alan Wynne
                last edited by

                @Alan-Wynne said in Local active Variables:

                it does require npp to be running with admin priviladges though…

                I use NppExec daily to do similar tasks (in fact, many of the posts that mention gcc and NppExec in the same post in this Forum are my equivalent of the script you just posted), but I have never had to have Admin privileges to save or run an NppExec script.

                (Though, admittedly, you might need admin privileges to install the plugin – but once you’ve installed it, you can restart Notepad++ without privileges, and the plugin works.)

                But under normal usage, what you described should not require admin privileges. Possible exceptions I can think of include: 1) if the file you are compiling is protected, or (2) the directory it’s in is protected; or, (3) if it was because it wouldn’t let you save the NppExec script, then your %AppData%\Notepad++\Plugins\config\npes_saved.txt might have weird permissions.

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors