Menu

FULL_CURRENT_PATH problems

NppExec
2018-04-01
2018-04-15
  • Mark Louis Tinney

    I apologize in advance for the length of this. I've been attempting to solve this problem myself and in order to avoid a lot of "but have you tried this" responses, I want to walk through everything I've done.

    I had to rebuild my PC's hard drive and I've completely forgotten how to set up NppExec to run Lua code for me. I'm trying to reinvent something I know I had working before and I'm running into trouble with it.

    Runtime Environment Description

    • 64-bit Notepad++ version 7.5.6 from a fresh download (today).
    • NppExec from SourceForge, NppExec20160628_dll_x64-2.zip
    • System Info
    Host Name:                 <redacted>
    OS Name:                   Microsoft Windows 10 Home
    OS Version:                10.0.16299 N/A Build 16299
    OS Manufacturer:           Microsoft Corporation
    OS Configuration:          Standalone Workstation
    OS Build Type:             Multiprocessor Free
    Registered Owner:         <redacted>
    Registered Organization:
    Product ID:                <redacted>
    Original Install Date:     11/20/2017, 9:11:22 AM
    System Boot Time:          3/31/2018, 10:58:55 PM
    System Manufacturer:       Gigabyte Technology Co., Ltd.
    System Model:              AB350-Gaming 3
    System Type:               x64-based PC
    Processor(s):              1 Processor(s) Installed.
                               [01]: AMD64 Family 23 Model 1 Stepping 1 AuthenticAMD ~3743 Mhz
    BIOS Version:              American Megatrends Inc. F7, 6/16/2017
    Windows Directory:         C:\WINDOWS
    System Directory:          C:\WINDOWS\system32
    Boot Device:               \Device\HarddiskVolume2
    System Locale:             en-us;English (United States)
    Input Locale:              en-us;English (United States)
    Time Zone:                 (UTC-06:00) Central Time (US & Canada)
    Total Physical Memory:     16,335 MB
    Available Physical Memory: 12,537 MB
    Virtual Memory: Max Size:  18,767 MB
    Virtual Memory: Available: 14,194 MB
    Virtual Memory: In Use:    4,573 MB
    Page File Location(s):     C:\pagefile.sys
    Domain:                    WORKGROUP
    Logon Server:             <redacted>
    Hotfix(s):                 10 Hotfix(s) Installed.
                               [01]: KB4048951
                               [02]: KB4053577
                               [03]: KB4054022
                               [04]: KB4056887
                               [05]: KB4058702
                               [06]: KB4074595
                               [07]: KB4087256
                               [08]: KB4088785
                               [09]: KB4090914
                               [10]: KB4088776
    Network Card(s):           1 NIC(s) Installed.
                               [01]: Realtek PCIe GBE Family Controller
                                     Connection Name: Ethernet 2
                                     DHCP Enabled:    Yes
                                     DHCP Server:     192.168.0.1
                                     IP address(es)
                                     [01]: 192.168.0.2
                                     [02]: fe80::f5ba:8ce0:7d9e:12b5
                                     [03]: 2607:fcc8:ab16:4300:5826:b385:18c6:c27e
                                     [04]: 2607:fcc8:ab16:4300:f5ba:8ce0:7d9e:12b5
    Hyper-V Requirements:      VM Monitor Mode Extensions: Yes
                               Virtualization Enabled In Firmware: No
                               Second Level Address Translation: Yes
                               Data Execution Prevention Available: Yes
    

    Actions Taken and Results Obtained

    • I appended my runtime directory to the PATH environmental variable and tested that this worked by opening a cmd window and typing just lua53.exe. The lua runtime window opened right up.
    • I closed that cmd window.
    • I opened Notepad++ and invoked NppExec with this command set:
    SET interpreter=lua53.exe
    SET exec="$(interpreter)" "$(FULL_CURRENT_PATH)"
    NPP_SAVE
    $(exec)
    if $(EXITCODE) != 0 goto exit
    NPP_CONSOLE 0
    NPP_RUN cmd /K "cmd /K $(exec) && pause"
    :exit
    
    • I used /K instead of /C to help me track down where the problem is - normally those would both be /C.
    • The results I got from that are that the console window flashed open and closed and a cmd window popped up with a title line that says exactly this:

      C:\Windows\System32\cmd.exe - cmd /K "lua53.exe" "F:\MyProjectFolder\TestCode\Test Code.lua"
      The first part is, indeed, my lua executable name and the second part is, indeed the full path name and file name for the window that was current when I invoked the command set through NppExec.
      The filename, directory name, or volume label syntax is incorrect.

      D:\Programs\Notepad++>

    • I tried isolating where the problem might be by running it this way (I removed the reference to what the interpreter was to interpret):
    SET interpreter=lua53.exe
    SET exec="$(interpreter)"
    NPP_SAVE
    $(exec)
    if $(EXITCODE) != 0 goto exit
    NPP_CONSOLE 0
    NPP_RUN cmd /K "cmd /K $(exec) && pause"
    :exit
    
    • That left me with an open console window with exactly this text in it:

      SET: interpreter = lua53.exe
      $(INTERPRETER) = lua53.exe
      SET: exec = "lua53.exe"
      $(EXEC) = "lua53.exe"
      NPP_SAVE: F:\MyProjectFolder\Test Code\TestCode.lua
      "lua53.exe"
      Process started >>>

    • I pressed ctrl-z and got this appended to what's already there and the console window remained open:

      ^Z
      <<< Process finished. (Exit code 0)
      IF: 0 != 0 goto exit
      NPP_RUN: cmd /K "cmd /K "lua53.exe" && pause"
      ================ READY ================

    • I alt-tabbed to an already-open cmd window and see that the lua executable was running.
    • That cmd window had a header that said exactly this:

      C:\Windows\System32\cmd.exe - cmd /K "lua53.exe" - lua53.exe

    • Obviously, the command is getting far enough in to start the interpreter.
    • That told me that issue had to be in the file name being generated by NppExec, but I tested for that as well.
    • Outside of NPP, I opened a cmd window and typed this:

      lua53.exe "F:\MyProjectFolder\TestCode\Test Code.lua"

    • It ran and dumped the output to the cmd window and the output was exactly what I would have expected from a successful run.

    It feels like the FULL_CURRENT_PATH variable isn't being set accurately, but that can't be true because the window title in the first run had the exactly correct path-and-file name (including the necessary double-quotes).

    Obviously, I've got something subtle wrong with this, but I don't know NppExec's interface well enough to spot it.

    Is there anyone out ther who can or has any idea of what else I should try to narrow in on the problem?

     

    Last edit: Mark Louis Tinney 2018-04-01
  • DV

    DV - 2018-04-02

    Any reason why so ancient version of NppExec is used? Currently the version 0.6 beta 1 is highly recommended.
    As for starting Lua, these two examples work for me, depending on what exactly you want to achieve:

    // Lua in NppExec's Console
    set local Lua = C:\Lua\bin\lua.exe // specify your path to Lua here
    npp_save
    "$(Lua)" "$(FULL_CURRENT_PATH)"
    

    and

    // Lua in a separate console window
    set local Lua = C:\Lua\bin\lua.exe // specify your path to Lua here
    npp_save
    npp_run cmd /c ""$(Lua)" "$(FULL_CURRENT_PATH)" && pause"
    
     

    Last edit: DV 2018-04-02
  • Mark Louis Tinney

    As to the "ancient" version, I pulled the most current "stable" (so claimed) version of NPPExec 64 available. A recently released beta is still not what I would normally call "stable".

    I did, however download and install it and had no change in the results.

    I"m going to try your command samples and see if I get better results.

    What was using before (when this worked) looked a lot like what I'm using now. I did the same sort of queries to find it and I copied it verbatim (except that I put my path-to-lua in my system PATH variable to simplify manual use of the run-time environment.

    I want it to kick the results back to me in the NPPExec Console rather than in a CMD window.

    I'll give that code a shot and see what happens.

    As an aside, I was under the impression that I'd get email notifications to posts and didn't check back right away.

    I've had a moment to paste in your command segment and it works just fine.

    Thanks!

     
  • Mark Louis Tinney

    Well, let me amend this.

    It worked once, with a simple "Hello world" program I was using to help me debug the problem.

    When I put anything more complex in there, I consistently get an error with the NPP_SAVE part that says exactly this:

    ; executing NPP_SAVE

    • could not save file

    The following lines are exactly this:

    "lua53.exe" "F:\TestProject\Test Code.lua"
    Process started (PID=12420) >>>

    <<<Process finished (PID=12420). Exit code 0.

    However, the very simple diagnostic code I put in the executable does not provide print.

    What would cause that "- could not save file" error?

     
  • DV

    DV - 2018-04-15

    The message "could not save the file" is a red herring here - in fact its meaning is "the file is not modified, so it can not be saved since there is nothing to save". There will be more correct behavior in the next version of NppExec.
    As for absent output, I can only say that e.g. print("123") works as expected.

     

Log in to post a comment.

MongoDB Logo MongoDB