Community
    • Login

    Problem launching NPP with file from IDE

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    17 Posts 3 Posters 944 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 KilbornA
      Alan Kilborn
      last edited by

      Spaces within paths should be handleable in this situation. However, reading your posting I don’t feel like all the information is there in order for me to offer any kind of opinion/help. Or, maybe it is simply me not understanding.

      I am bothered by this however: ...\notepad++.exe "\%1" and what bothers me is the backslash. Why do you feel this backslash is necessary there?

      Lycan ThropeL 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @Lycan Thrope
        last edited by PeterJones

        @Lycan-Thrope said in Problem launching NPP with file from IDE:

        I still need to know if there is a way to set a command line argument to encapsulate a parameter being handed to NPP to open, to avoid this kind of problem in the future.

        Putting quotes around it is the right way of doing it. And that’s a Windows thing, and how it handles command-line arguments with spaces, and is nothing specific to Notepad++.

        Your dBASE IDE might have different quoting rules in how it converts your external editor command into something that it launches through the OS. But that’s still specific to dBASE IDE, not Notepad++.

        Thus, this whole question seems to be Notepad++ agnostic: from your description, the same happened with MS notepad.exe, so I’m not sure why you thought here, rather than a dBASE IDE forum, was the best place to ask. (I’m reasonably confident that Alan’s question about the extra backslash is the right solution… but if there’s something beyond it, it probably doesn’t belong here unless you can show that a valid windows-style command line doesn’t properly open a file in Notepad++ from a Win+R or cmd.exe window)

        1 Reply Last reply Reply Quote 2
        • Lycan ThropeL
          Lycan Thrope @Alan Kilborn
          last edited by Lycan Thrope

          @Alan-Kilborn ,
          This was after I had tried without the \, but I added it wondering if the path was being truncated to not look into the directory since the error box showing the first part of the file path has the entire string up to and including the file that was being asked to be open, but on the second string, the \ was missing. It was just unfortunate that I grabbed that screenshot rather than the prior one.

          Now, in reference to the first part of your response and @PeterJones followup, this is the situation. When I put just the Windows notepad.exe in the alternate editor dialog, the path and file were accepted and opened.

          The space in the filepath was NOT accepted by the notepad++.exe. That’s what the experiment showed me, is that it was specific to Notepad++, because as is, my path was not being accepted by Notepad++ with the space in the filepath, so by reference, and my finding the fix, this is specific to Notepad++.

          I hope this better explains what I was trying to explain earlier. It just didn’t come out right.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Lycan Thrope
            last edited by PeterJones

            @Lycan-Thrope said in Problem launching NPP with file from IDE:

            The space in the filepath was NOT accepted by the notepad++.exe,

            There should be quotes around the filename before it gets to notepad++.exe. If there isn’t, it’s the fault of the command coming into Notepad++, not Notepad++ itself.

            I hope this better explains what I was trying to explain earlier.

            It’s still not enough information. As far as I can tell, you or the dBASE IDE is just not forming a valid command that is sent through system() or CreateProcess, and none of your “clarifications” have changed my mind.

            I just confirmed that Debug Info’s Command Line : ___ field will properly show whether or not the command was executed with quotes around the argument. For example, .\notepad++ license will give

            Command Line : license
            

            whereas .\notepad++ "license" will give

            Command Line : "license"
            

            Thus, if you don’t have Notepad++ running when you launch it from dBASE IDE, you should be able to tell what the actual command line was, and whether it was properly quoted.

            Lycan ThropeL 1 Reply Last reply Reply Quote 1
            • Lycan ThropeL
              Lycan Thrope @PeterJones
              last edited by Lycan Thrope

              @PeterJones ,
              Well, I just tried to grab a file from another directory that does have the space in it and this is what the Command Line: shows, and yet, it didn’t open the file itself without error.
              Command Line : -udl=Dark_dBASEPlus C:\Users\camilee\Documents\dBASEProjects\Custom Controls Lee\BaseForm.cfm

              This is the directory that shows in the IDE Navigator:
              C:\Users\camilee\Documents\dBASEProjects\Custom Controls Lee

              So this tells me it’s seeing it, and it is opening NPP in the correct directory because I can click the open file menu in NPP and it is in the correct directory, it just is refusing to open the file because it doesn’t see it and asks if it needs to be created.

              The space in the path, is being passed to NPP. It’s refusing to properly open the file that is pointed to, because of that space. MS Notepad accepts and opens the proper file when it is in the IDE External Source Editor, but NPP does not.

              Debug Info:
              Notepad++ v8.6.5 (64-bit)
              Build time : Mar 29 2024 - 17:04:43
              Path : C:\Program Files\Notepad++\notepad++.exe
              Command Line : -udl=Dark_dBASEPlus C:\Users\camilee\Documents\dBASEProjects\Custom Controls Lee\BaseForm.cfm
              Admin mode : OFF
              Local Conf mode : OFF
              Cloud Config : OFF
              Periodic Backup : ON
              OS Name : Windows 10 Home (64-bit
              OS Version : 22H2
              OS Build : 19045.4291
              Current ANSI codepage : 1252
              Plugins :
              CodeAlignmentNpp (14.1.107)
              ColumnsPlusPlus (1.0.2)
              ComparePlus (1.1)
              CSVLint (0.4.6.6)
              CsvQuery (1.2.9)
              EnhanceAnyLexer (1.4)
              MarkdownViewerPlusPlus (0.8.2)
              mimeTools (3.1)
              NppConverter (4.6)
              NppExec (0.8.4)
              NppExport (0.4)
              NppPluginDemo (4.3)
              NppSnippets (1.7.1)
              NppUISpy (1.2)
              PythonScript (2)
              TakeNotes (1.2.6)
              XMLTools (3.1.1.13)

              For reference, this is the User Manual text about Command Line Arguments that brought my attention to the space being a possible problem requiring quotes:
              For compatibility, Notepad++ will first try to identify the entire command line as a filename, even if it is unquoted. It is however not recommended to do this, as you should always quote the filename.

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Lycan Thrope
                last edited by PeterJones

                @Lycan-Thrope said in Problem launching NPP with file from IDE:

                The space in the path, is being passed to NPP. It’s refusing to properly open the file that is pointed to, because of that space.

                The same is true if you typed that from cmd.exe. The dBASE IDE needs to send it with quotes around the filename, because that is the correct way of generating a windows command line command for any command that includes a space inside one of the arguments

                Without the quotes around the path, notepad++ cannot and will not work. This is how Notepad++ has always been designed.

                Think of it this way: create four files in the same directory

                • blah
                • with
                • space.txt
                • blah with space.txt

                Run notepad++ blah with space.txt in that directory. Notice it opens the three individual files, not the file with spaces in the name. Now run notepad++ "blah with space.txt" , and it opens the single file with spaces in its name. Notepad++ needs the quotes around the parameter to tell it that it’s a single parameter, not three.

                If you cannot make dBASE IDE send the path properly quoted, the fault lies with dBASE IDE, not with notepad++, because those quotes are the ONLY way that Notepad++ (or any other application) can correctly disambiguate the three-file vs one-file versions I showed above.

                —
                update: Microsoft’s notepad.exe (at least the windows10 version; maybe not the tabbed “app” in windows11) treats everyone after notepad.exe as a SINGLE filename, including any spaces typed; but it can get away with that, because there is no way to open multiple files with one call to notepad.exe . That’s probably why notepad.exe “worked” from dBASE. And in my four-file example, whether or not you include quotes, notepad.exe will open the file-with-spaces, not the three individual files.

                update 2: if dBASE is incapable of creating a properly quoted command string, then write a .bat wrapper, where the contents of the .bat are just "c:\program files\Notepad++\notepad++" -udl=Dark_dBASEPlus "%*" , which has the effect of wrapping all the space-separated tokens from the unquoted command line, and passing them all to Notepad++ with the correct quotes.

                Lycan ThropeL 1 Reply Last reply Reply Quote 1
                • Lycan ThropeL
                  Lycan Thrope @PeterJones
                  last edited by

                  @PeterJones ,
                  It appears that the multiple file capability is the reason, then, from what I can see, that the spaced name, can’t be open meaning it is NPP specific. :-)

                  I saw your response, as I was going to post what is one of my workarounds without removing the spaces in directory names which has us create a template in the Command Window and name the file, which bypasses the space issue, as the Command Window already is pointed to the proper directory, and then only needs to send the filename to be opened.

                  This is a screenshot of the IDE’s Abbreviations template, similar to the Snippet capability in NPP, to enter a file name to open the file:
                  commandWindowTemplate.PNG

                  And this is the resultant debug info:
                  Notepad++ v8.6.5 (64-bit)
                  Build time : Mar 29 2024 - 17:04:43
                  Path : C:\Program Files\Notepad++\notepad++.exe
                  Command Line : baseform.cfm -udl=Dark_dBASEPlus
                  Admin mode : OFF
                  Local Conf mode : OFF
                  Cloud Config : OFF
                  Periodic Backup : ON
                  OS Name : Windows 10 Home (64-bit
                  OS Version : 22H2
                  OS Build : 19045.4291
                  Current ANSI codepage : 1252
                  Plugins :
                  CodeAlignmentNpp (14.1.107)
                  ColumnsPlusPlus (1.0.2)
                  ComparePlus (1.1)
                  CSVLint (0.4.6.6)
                  CsvQuery (1.2.9)
                  EnhanceAnyLexer (1.4)
                  MarkdownViewerPlusPlus (0.8.2)
                  mimeTools (3.1)
                  NppConverter (4.6)
                  NppExec (0.8.4)
                  NppExport (0.4)
                  NppPluginDemo (4.3)
                  NppSnippets (1.7.1)
                  NppUISpy (1.2)
                  PythonScript (2)
                  TakeNotes (1.2.6)
                  XMLTools (3.1.1.13)

                  So I guess it’s NPP’s ability to open multiple files in a command line, is what makes it a problem for my usage. That’s why I asked if there was some kind of commandline switch that could alter the NPP parsing of spaces in a filepath passed to it, because since NPP is a Win only editor, it would seem that the ability to accept longnames in filepaths that may include spaces would be a builtin mechanism, since as far as I know, every Windows filename tends to have a filename extension, whether it’s visible or not, and that would seem to be to me, a dead give away upon parsing a filepath that the actual filename has not yet been reached.

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Lycan Thrope
                    last edited by PeterJones

                    @Lycan-Thrope ,

                    Every Windows site with any clout recommends to always pass command line arguments that have spaces with quotes around them. It’s not just for Notepad++. Try running a script name script with spaces.py or script with spaces.pl with your favorite interpreter, without putting quotes around it, from the command line. See what happens. Try another editor that handles multiple files from the command line (MS notepad doesn’t count, at least not in Win10 – try scite, which I just confirmed; try some other editor that you have access to; see what happens).

                    In fact, in cmd.exe, try notepad++ blah<TAB> to get it to autocomplete, and note that even microsoft is smart enough that if the filename has spaces, it wants to put quotes around it.

                    If you cannot make dBASE properly quote the file names, then you will need to come up with a way to get around that limitation in dBASE – whether it’s by using just the filename, as you showed, or a batch wrapper, like I showed.

                    —
                    update: add images:
                    c2f3fe27-6d6a-44bf-87c7-8a8bfc8bc1f6-image.png
                    7eaa1740-5c4f-4802-ae7d-8c0344e94b27-image.png

                    Lycan ThropeL 1 Reply Last reply Reply Quote 0
                    • Lycan ThropeL
                      Lycan Thrope @PeterJones
                      last edited by Lycan Thrope

                      @PeterJones ,
                      I’m going to try the batch wrapper, and see if it works, so thanks for that clue option. I just can’t see forcing people to change their naming, which is why I asked if there was a command line switch, but if a bat will make it work, all the better as it doesn’t force people to change, but makes the process work.

                      Just by chance, because of that problem with spaces I never really got in the habit of creating filenames with spaces, but obviously became lax when it came to this directory naming issue with spaces since for most things, it has been able to work, since the DOS days. :-) I guess I’ll have to reinforce my habit for directory names as well, but if I hadn’t become lax, this issue wouldn’t have been found and someone else would have been scratching their head. :-)

                      Update: Yes, it works, similar to my work around template in the command window, so thank you for that, as I can offer that as an additional option beyond just making sure there are no spaces in filepath/filename or using my template. The two simple options is the .bat file or removing spaces as the least work required to launch a file from the IDE.

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @Lycan Thrope
                        last edited by PeterJones

                        @Lycan-Thrope said in Problem launching NPP with file from IDE:

                        I just can’t see forcing people to change their naming,

                        Windows has always said to use quotes around filenames that have spaces, when passing them as command-line arguments. The same is true on Linux. The problem is that certain applications (like dBASE IDE, apparently) do not properly use that rule when generating commands. It’s even documented in win32 API: CreateProcess

                        This is nothing new, and nothing that Notepad++ is “forcing” on anybody. It’s the way that Windows works, despite poorly written applications giving examples to the contrary.

                        Lycan ThropeL 1 Reply Last reply Reply Quote 0
                        • Lycan ThropeL
                          Lycan Thrope @PeterJones
                          last edited by Lycan Thrope

                          @PeterJones ,
                          Well, I don’t know about poorly written. The screenshot does show, that the IDE does enclose the path with quotes when it does have spaces, and doesn’t when it doesn’t in the command window when launching SciTE, just by chance, however, SciTE opened 3 empty documents instead of the one desired to be open.
                          idequotingpathwithspaces.PNG

                          So if I do the same with NPP, it just doesn’t open the files without my allowing it to via the error dialogs but it does open to the correct directory, if not the file. In this screenshot, you see the set command and that is me setting the External Editor Dialog to first the SciTE editor and the second one sets it to NPP, and then again attempting to open the same files. One is quoted, but it is the errored out spaces, and the other opens just fine, and has no quotes…so maybe you can see why I may be seeing that there is two different editor responses happening at the same time.
                          idequotingpathwithspaces2.PNG

                          The question is, are these the strings that are being passed to the editors and I suspect they are, and if they are properly formed with quotes, why are they not performing properly.

                          Update1: The modify command you see is the interpreters way of showing that a file was right clicked and Open in Source Editor selected from the IDE right click menu option.

                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Lycan Thrope
                            last edited by PeterJones

                            @Lycan-Thrope said in Problem launching NPP with file from IDE:

                            The question is, are these the strings that are being passed to the editors

                            No, they are not. Your Debug Info proved that. If you don’t believe Debug Info, use Task Manager’s Command Line column in the Details tab. (Right click on the header, Select Columns, and choose Command Line, if it’s not visible for you.)

                            Lycan ThropeL 3 Replies Last reply Reply Quote 0
                            • Lycan ThropeL
                              Lycan Thrope @PeterJones
                              last edited by

                              @PeterJones said in Problem launching NPP with file from IDE:

                              No, they are not. Your Debug Info proved that.

                              Hmmm…going to have to look into that, if I can. It’s not open source, so that may be difficult to find out. :(

                              1 Reply Last reply Reply Quote 0
                              • Lycan ThropeL
                                Lycan Thrope @PeterJones
                                last edited by Lycan Thrope

                                @PeterJones said in Problem launching NPP with file from IDE:

                                No, they are not. Your Debug Info proved that. If you don’t believe Debug Info, use Task Manager’s Command Line column in the Details tab. (Right click on the header, Select Columns, and choose Command Line, if it’s not visible for you.)

                                I don’t seem to be able to find this option. (learning everyday) I have the details tab, but don’t seem to be able to bring up Command Line or any column. Will still try, but at the moment, this doesn’t seem to be something I’m able to do at the moment. ::sigh:: more learning. ;)

                                Update: Perhaps because my McAfee’s was running it was blocking something, I managed to right click the header and get Columns to show, but I don’t see an option checkbox for Command Line.

                                Update2: found it. investigating now. :)

                                Update3: You’re right, it apparently isn’t passing it to NPP quoted, but the command to run NPP IS quoted. Hmmm…

                                1 Reply Last reply Reply Quote 0
                                • Lycan ThropeL
                                  Lycan Thrope @PeterJones
                                  last edited by Lycan Thrope

                                  @PeterJones ,
                                  Thanks for helping me find this out. This is strange, because when we put filepath/filename in the code, we do surround them with quotes for the reasons you point out.

                                  Why the IDE would not pass a filepath/filename parameter without quotes around it is strange, unless the way the IDE is designed, it does it internally, as witnessed by those two different ways it displays depending on if there is spaces in it. In other words, the IDE interpreter sees the spaces, and then puts quotes around it for itself. This makes sense, but making it more difficult for us to use external editors without passing it that way is definitely perplexing. Just as an FYI, the dBASE Plus editor is based on the SciTE editor that they changed to in the dBASE Plus 9 version, so it does share at least a little bit of familial genes with NPP, namely the Scintilla library. :-)

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