• User defined language and break/extra return statements

    4
    0 Votes
    4 Posts
    485 Views
    Lycan ThropeL

    @Charles-Chickering ,

    The problem here, is like Peter has mentioned. The UDL is a general parser, which makes it kind of dumb, but it does it’s job. The problem may be that you might need to rewrite your code if it’s able to be done.

    I found this problem in our UDL also, and rewrote the code instead, to reflect a better practice.

    For instance, if your language allows it, using a return in an if/endif conditional is essentially a “goto” escape clause reminiscent of early Basic. It was frowned on then as well, but did the job. If your condition in that code is accurate, then presumably you are accessing variables that you’re allowed to change in the function that is being passed to it, or it’s able to change the variable directly. If that is the case, perhaps you should just do the variable change which is the purpose of that conditional controlling.

    For instance, in that example code, Function foo is called, and the first thing it does is check if the A == 1. If it is, goes to the next if, if not, it goes to the end of A before the code before the return statement. If it does equal A, it then goes to the next conditional check if B==0, which if it is, it changes the variable x to 2. IF B is not equal to 0, it will automatically go to the else statement and change C to 3. No need for a return statement here. Your 2 if statements will end.

    Unfortunately, the way your code shows above, the return only keeps the code from continuing after x is changed to 2, where you’re trying to exit the function at that point. That’s not what you should be doing. You should be letting the function finish it’s run so it can return on it’s own.

    If the code at the end is not to be run, if the above conditions are met, then you need to add an else condition for if A<> 1, like this:

    function foo() //Simplified code if (A == 1) if (B == 0) x = 2 else C = 3 end //end b else //more code that doesn't execute if above condition is met end //end a return

    Follow the logic. those conditions have to be met. If they are met, they ignore the rest until they reach the end of the function, if you have structured them properly. At that point, you don’t need the return statement acting like a “goto” statement.

    The only other option, but the above code doesn’t seem to follow logically and it could just be junk code you provided, but a function usually returns a value, whether it is typically a 0 for success, 1 or -1 for fail (or vice versa if you have changed the return values), or a value that was computed. That’s how a return is supposed to work…so if I was writing code like that, it would return a value and that value is what you would return. For instance:

    function foo() //Simplified code if (A == 1) if (B == 0) x = 2 returnVal = x else C = 3 returnVal = C end //end else //more code that doesn't execute if above condition is met return returnVal end //end a return returnVal

    In this way, you’re returning a value, that can be interpreted at the point after the function returns. The above actually kind of looks like how a function might be overloaded to return different values depending on the code. I feel it should return one value type, not different ways depending on different variable values.

    Doing either of these two ways, would be programmitically consistent and proper, and void the issue of your folding not working properly.

  • How to add attributes in link in Notepad++

    2
    0 Votes
    2 Posts
    333 Views
    Alan KilbornA

    @ProfessorJuju

    You look for a pattern in the data, then you craft a search that will match the pattern, allowing you to replace a part of it with your additional data.

  • Need to find lines that are missing a comma at the end.

    11
    0 Votes
    11 Posts
    2k Views
    Mark OlsonM

    @Monarchia
    Looks like you got this fixed, but just wanted to chime in that JsonTools can indeed find the errors in your JSON file (as PeterJones mentioned), but you can also just turn on linting and then you can parse the JSON with any number of missing commas (as well as various other syntax errors) and pretty-print it as syntactically valid JSON.

    If your JSON file had a truly preposterous number of such syntax errors (say on the order of hundreds of thousands), the linter would probably use a lot of memory though.

  • Long line, into multiple in numerical order

    5
    0 Votes
    5 Posts
    269 Views
    Luis LucenaL

    @Alan-Kilborn @David-Brigden52

    I got it. thanks for the help.

    I am new at this and learning.

  • maarkdown udl editing

    2
    0 Votes
    2 Posts
    174 Views
    PeterJonesP

    @eglacias,

    If by “bright pink”, you mean “purple” (RGB=0x8000FF), that setting is the color for the “delimiter 1”, which is where the styling for brackets is defined.

    df22c4ee-80d6-4a10-97f1-ac77f8d4975f-image.png

  • Can I capture my saved macros so that I can move them to a new machine?

    4
    0 Votes
    4 Posts
    227 Views
    Kathi WK

    @Alan-Kilborn Thank you!!! Have a great weekend

  • 0 Votes
    8 Posts
    2k Views
    Alan KilbornA

    @Neil-Schipper

    I will have to consider your proposed functionality more deeply before offering an opinion. And that probably means: Mocking it up with a script – and quite possibly, slightly modifying the script I presented earlier in this thread.

    LATER FOLLOWUP:

    I did some thinking on the idea. Maybe it is OK…probably not a “game changer” though…

    As to quickly scripting it for experimentation, I think it can be a one-liner:

    notepad.menuCommand(MENUCOMMAND.SEARCH_SETANDFINDNEXT if not editor.getSelectionEmpty() else MENUCOMMAND.SEARCH_FINDNEXT)

  • 0 Votes
    6 Posts
    245 Views
    papahOOchP

    @PeterJones I was gonna give you the debuginfo but now the problem seems to have disappeared! I did have a windows update waiting that I installed last night before I went to bed, so maybe that was what was causing the issue. Strange, but then again, computers are just rocks tricked into doing math

  • Help! All my tabs and backups files disappeared

    4
    0 Votes
    4 Posts
    363 Views
    Neil SchipperN

    @CasualT-PlayStation

    Yesnomaybe?

    e1c7b93f-9281-4a2c-8b35-1404fc5f227f-image.png

  • NP++ and Windows Registry (Fix for FilePath Filename with blank space)

    10
    0 Votes
    10 Posts
    1k Views
    Jim VenceJ

    @Michael-Vincent That worked for me. Thank you!

  • Change colour of highlight in picklist

    8
    0 Votes
    8 Posts
    492 Views
    Michael VincentM

    @dinkumoil said in Change colour of highlight in picklist:

    @Michael-Vincent
    Do you know the version of Scintilla (or rather the version of Notepad++) that introduced this feature?

    Looking at https://www.scintilla.org/ScintillaHistory.html, it seems version 5.0.1:

    Add SCI_SETELEMENTCOLOUR and related APIs to change colours of visible elements. Implement SC_ELEMENT_LIST* to change colours of autocompletion lists.

    which methinks corresponds to Notepad++ 8.4:

    https://notepad-plus-plus.org/downloads/v8.4/

    Update Scintilla from v4.4.6 to v5.2.1 and add Lexilla v5.1.5. (Fix #10504)

    Cheers.

  • User Defined language more folding in code styles

    3
    0 Votes
    3 Posts
    2k Views
    denwithamD

    @PeterJones Thank you, just what I was looking for.

  • User Defined Language Escape Character

    2
    0 Votes
    2 Posts
    415 Views
    Anthony ShortA

    @Anthony-Short
    I think I figured it out. I simply used double quotation marks and coded it as follows in the 1st group.

    "Let's make a game!"

    No need for “&apos;” or “\',” just “Let’s.”

    Hopefully this topic helps somebody else out!

  • Invisible characters unwanted

    28
    0 Votes
    28 Posts
    31k Views
    Alan KilbornA

    Someone else found the solution for me:

    set the control character’s representation to the “zero-width space” character (so it has no visual component – but it will have a small “inverse video” artifact on-screen) set the representation appearance to plain text (to avoid the inverse video)

    Although, to script this (as I tend to do) is difficult as the set-representation-appearance Scintilla command is not yet available as an editor command in the PythonScript versions that are current as of this writing.

  • Selection highlight has disappeared from npp

    2
    0 Votes
    2 Posts
    701 Views
    PeterJonesP

    @Michel-Martin-Neuville ,

    Works just fine for me.

    Select Some:
    422a87eb-ebb7-4ec9-869f-74ef30a035b2-image.png

    Select All:
    eaf69895-bc4c-4d3c-83a6-0161dfdc97f8-image.png

    What theme do you have selected in Settings > Style Configurator? If you go to the Settings > Style Configurator > Global Styles > Selected Text Color, what colors are shown? Do you have something like trying Settings > Style Configurator > Global Styles > Global Override having any checkboxes? (Read the user manual on “Global Override” if you do… and then unchceck all the boxes, because they probably aren’t what you actually want.)

  • Toolbar doesn't remain 'fluent'

    3
    0 Votes
    3 Posts
    248 Views
    Terry RT

    @traderttt9 said in Toolbar doesn’t remain ‘fluent’:

    Anyone?

    It almost sounds like you have 2 problems.

    When opening a file that has the association, instead of opening Notepad++ first and then the file, you get 2 different results with the toolbar. This sounds like the association is opening a different (installed) version of Notepad++ on the PC. The way to identify that is to run Notepad++ each way, then check the “Debug Info” under the ? menu. It will tell you where the program is located. Alternatively one of the methods may be running Notepad++ with some commandline parameters which may be wrong. Again, see the “command line arguments” under the ? menu.

    You refer to making a change, then checking during a later session and the changes have reverted, or at least don’t appear to have changed and stuck. This could be because you are running Notepad++ in “multi instance” mode (see settings, preferences, multi instance & date). If so, then the last instance which closes will set the settings for the next time you run Notepad++. So make the changes in that instance before closing. It may also occur if you do NOT have the ability to alter the XML file holding this configuration change. So you would need to check on the XML files, stored either in the %appdata%\Notepad++ folder, or where the Notepad++ executable file is located, depending on how you run Notepad++. Check the file permissions, that you can write to the files.

    Terry

    PS, just noted @PeterJones thinks exactly the same!

  • How to replace characters over certain number?

    6
    0 Votes
    6 Posts
    2k Views
    L

    @guy038 said in How to replace characters over certain number?:

    (?-s).{55}\K.+

    Thank you very much, everything worked great. Tidy lists please the users :-)

  • Search help

    9
    0 Votes
    9 Posts
    4k Views
    PeterJonesP

    r 8 unknown y@y 4 unknown then .ro

    r********y@y****.ro

    How would i do this

    You would apply the knowledge you learned from my previous freebie solution and try to generalize it. Since . obviously matched a single character in my previous answer, using a . in your new expression anyplace you want it to match a single unknown character would work.

    (?i-s)\br........y@y....\.ro

    The (?i-s) says “be case insensitive; don’t let . match newline” The \b says “match a word boundary” (hence requiring the r at the - beginning of the email, rather than just in the middle) Every . means “one character” – and because of the earlier option, it actually means “one character (not including newlines)” the \. means “match a literal dot character” – I changed to this because that will require four unknowns followed by a literal dot; y.....ro would work for that portion of the regex as well, but it would also match y12345ro, which you don’t want, so I made it more specific.

    BTW: this is your last freebie from me. Until you start showing some effort and a willingness to learn, I cannot help you any further.

    ----

    Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.

  • How to remove text on a specific line across different files

    7
    0 Votes
    7 Posts
    440 Views
    guy038G

    Hello, @stealthy, @terry-R and All,

    @stealthy, a simple solution would be to use the following regex S/R :

    SEARCH (?-s)\A.*\R\K.*

    REPLACE 0

    Now, we can generalize, using the generic regex S/R below, in order to replace the line N, of EACH file, with the RR regex replacement expression :

    SEARCH (?-s)\A(?:.*\R){N-1}\K.*

    REPLACE RR

    Note that, if we want to replace the first line, in EACH file => N - 1 = 0. So, simply use the regex S/R : (?-s)\A.* !

    Best Regards

    guy038

  • functionList not ignoring comments

    26
    2 Votes
    26 Posts
    2k Views
    Lycan ThropeL

    @mpheath ,

    After going over a lot of stuff, including reexamining the FunctionList FAQ, I have to agree with you, that at present, I may need to work with the parser, as is. I must have missed that ‘embedded comments’ section, or glossed over it, or didn’t relate it to the kind of comments we do as the example seemed to be an example of excessive use of inline ‘block’ comment style for an inline comment. That may be what threw me as regards that example in the FAQ.

    Moving the opening class declaration line after any block comments immediately following it, fixes the problem completely, with my recent testing. It appears, however, that as I discovered before, line comments inside a class taking up a whole line, or after code, inside a class/endclass block does indeed work as it should.

    So I guess until I get up to speed with C++ and take a crack at a fix for the block comments giving problems inside a class/endclass code block, block comments will have to be avoided.

    I do, however, feel that the simple fix for this, should be just allowing a longer string other than \{ and \} symbol characters would be a proper fix, since being able to use class and endclass in the open/close symbole elements, it would be part of the actual parser demarcation ability to know where a class starts and ends, rather than having to use regex to find all the way to the end like this regex had to do to be able to outline the structure of the class. For now, the crisis is averted until I can revisit this issue, hopefully with some C++ skills at a later date. :)