UDL: Overloaded folding close keywords
-
I’ve got a bit of a curly one here for specifying a UDL that I could do with some help with.
Here’s what I’ve got so far:
The problem is the keyword “END” is used to finish an IF … THEN block, but is also used in “END SELECT” for a “SELECT CASE” block.
As you can see, lines 12, 13 & 14 get treated as “END SELECT” instead of it being “END” finishing the IF above it and “SELECT CASE” starting a new block.
Is there a subtle way around this? Or have reached the limit of what can be done with UDL?
Thanks!
-
I believe you need a Close for every Open. I think the END SELECT is ending the FUNCTION block.
Try
END END END END "END SELECT"
in your Close box. -
Hi, @rossjparker, @jim-dailey and All,
Jim, did you really verify your assumption, re-creating the code of the picture, in a new tab ?
It was my first guess too, but, unfortunately, it does not work :-((
Trying with
END SELECT
, only, in theClose
part is also useless ! In that case, of course, the end of theFUNCTION
area occurs on theEND SELECT
of the SELECT CASE blockThe best I’ve found out, is to, simply, type in
END
in theClose
zone. The drawback is that the word SELECT in END SELECT, is not highlighted anymore ;-))However, I’m not a pro about UDL languages and I haven’t fully study the
UDL
documentation, yet ( See below ) :https://ivan-radic.github.io/udl-documentation/
I do hope that I did miss something obvious ;-))
Best Regards,
guy038
-
Including the example source file and the export file of the UDL (or at least links to them) saves any (potential) helper from having to type the code and UDL entries.
-
remember the good old times, without any internet, public domain disks, nor bbs modems, when many of us bought computer magazines and started typing the published program listings into our home computers, for nights and nights.
(it used to be an extra challenging fun in the pre-checksum aera 😉)
maybe this just kicks in that same retro style motivation, to actually type all that stuff down … and maybe … just maybe, the op knew all that in advance, and just wanted to surprise us with a gift from our childhood 😂😂😂
btw: just kidding, welcome to the notepad++ community, @rossjparker 👍
-
Thanks for the welcome @Meta-Chuh !
I had no idea this was such an active community! Good on you all. Thanks for taking the time to look at my problem.
As suggested by @MAPJe71 (and sorry I did not think of it up front - but at least I figured out how to embed an externally hosted image! :-), here is the source snippet I’m playing with for those wishing to play along:
INT FUNCTION _KRN_Alarm_ClearSelection(INT iDspType = -1, INT iMonitor = -1) INT iError = -1; INT iFormID = -1; IF iMonitor = -1 THEN iMonitor = KRN_MM_GetMonitor(); END IF iDspType = -1 THEN iDspType = miAlarmDsp[iMonitor]; END SELECT CASE iDspType CASE ALM_CURRENT iFormID = mhCurrentForm[iMonitor]; CASE ALM_HISTORY iFormID = mhHistoryForm[iMonitor]; CASE ALM_SHELVED iFormID = mhShelvedForm[iMonitor]; END SELECT IF iFormID <> -1 THEN iError = KRN_DG_FormClearSelection(mobjAlarmDataGrid, iFormID); END RETURN iError; END
And here is the corresponding UDL v2.1 XML export:
<NotepadPlus> <UserLang name="CiCode" ext="ci" udlVersion="2.1"> <Settings> <Global caseIgnored="no" allowFoldOfComments="yes" foldCompact="yes" forcePureLC="0" decimalSeparator="0" /> <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments">03/* 04*/ 00! 00// 01 02</Keywords> <Keywords name="Numbers, prefix1"></Keywords> <Keywords name="Numbers, prefix2"></Keywords> <Keywords name="Numbers, extras1"></Keywords> <Keywords name="Numbers, extras2"></Keywords> <Keywords name="Numbers, suffix1"></Keywords> <Keywords name="Numbers, suffix2"></Keywords> <Keywords name="Numbers, range"></Keywords> <Keywords name="Operators1">( ) [ ] , = ;</Keywords> <Keywords name="Operators2">AND OR NOT</Keywords> <Keywords name="Folders in code1, open"></Keywords> <Keywords name="Folders in code1, middle"></Keywords> <Keywords name="Folders in code1, close"></Keywords> <Keywords name="Folders in code2, open">IF FUNCTION WHILE FOR "SELECT CASE"</Keywords> <Keywords name="Folders in code2, middle"></Keywords> <Keywords name="Folders in code2, close">END "END SELECT"</Keywords> <Keywords name="Folders in comment, open"></Keywords> <Keywords name="Folders in comment, middle"></Keywords> <Keywords name="Folders in comment, close"></Keywords> <Keywords name="Keywords1"></Keywords> <Keywords name="Keywords2">THEN DO TO RETURN CASE</Keywords> <Keywords name="Keywords3">INT REAL STRING OBJECT GLOBAL</Keywords> <Keywords name="Keywords4"></Keywords> <Keywords name="Keywords5"></Keywords> <Keywords name="Keywords6"></Keywords> <Keywords name="Keywords7"></Keywords> <Keywords name="Keywords8"></Keywords> <Keywords name="Delimiters">00" 01^ 02" 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords> </KeywordLists> <Styles> <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="Consolas" fontStyle="0" nesting="0" /> <WordsStyle name="COMMENTS" fgColor="2E369C" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="LINE COMMENTS" fgColor="2E369C" bgColor="FFFFFF" fontName="" fontStyle="2" nesting="0" /> <WordsStyle name="NUMBERS" fgColor="FF00FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="KEYWORDS1" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="3" nesting="0" /> <WordsStyle name="KEYWORDS2" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="KEYWORDS3" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="KEYWORDS4" fgColor="0000A0" bgColor="FFFFFF" fontName="" fontStyle="3" nesting="0" /> <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="OPERATORS" fgColor="EA0000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="FOLDER IN CODE1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="FOLDER IN CODE2" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS1" fgColor="008040" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> </Styles> </UserLang> </NotepadPlus>
In this language (CiCode), you can comment out an entire line by starting it with a ‘!’. If I comment out the blank line between the END and the SELECT, it immediately fixes the problem. And in fact this is the temporary work-around I am using currently.
Thanks once again for your interest!
-
The best I’ve found out, is to, simply, type in END in the Close zone. The drawback is that the word SELECT in END SELECT, is not highlighted anymore ;-))
yes, your solution is also the best thing i could find so far.
the highlighting of
SELECT
would not be a problem, as we can set that as a keyword with the same colour (screenshot below).
the bigger issue is, that the “SELECT” after the “END” of “END SELECT” opens another fold, but never gets a belonging closing end.
it works, but it looks a little awkward, as the function fold will overshoot the document.what do you say, @rossjparker ?
folding seems to work using this workaround and the given sample, but not perfect. -
A hack would be to tweak the end folding statement and using an unique comment at the end.
Of course this means that you have to type this in addition but … well … it’s a dirty hack. -
@Meta-Chuh - not a bad compromise until I tried it with a real source file with lots of functions. Everything after the END SELECT starts to get misinterpreted as the parser is out of sync. Functions that follow start to get messed up too.
But I did find what appears to be the perfect solution by trial and error. Use single quote characters (') to specify multi word open/closing folding in markers instead of double quotes ("). Using single quotes appears to still allow any amount of white space between the words except new lines - i.e. the two words must be on the same line.
I know the language definition is terrible. But this language is very old - it dates back to the pre-internet times you were reminiscing about earlier @Meta-Chuh! :-)
-
But I did find what appears to be the perfect solution by trial and error. Use single quote characters (’) to specify multi word open/closing folding in markers instead of double quotes (").
nice find (i’ve just tried out your solution) and very embarrasing that i did not try that (
'
) out beforehand 🤭thank you for your own, working solution and for sharing. 👍
if you like, stick around here in the future, either for casual reading, or to participate on anything of interest to you. you are always welcome.greetings, meta chuh