- the middledots are spaces
the horizontal lines are tabs - 2015-07-15_112549.png (2.29 KiB) Viewed 3897 times
[Script] WhiteSpaceCtxMenu
Re: [Script] WhiteSpaceCtxMenu
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: [Script] WhiteSpaceCtxMenu
Whitespaces:
https://github.com/SublimeText/TrailingSpaces
Highlighted trailing whitespaces:
A plugin to highlight trailing spaces:https://github.com/SublimeText/TrailingSpaces
One of my scripts helped you out? Please donate via Paypal
Re: [Script] WhiteSpaceCtxMenu
At the end of line 8, if so I removed that and it further broke the script ?klownboy wrote:2 days ago here http://www.xyplorer.com/xyfc/viewtopic. ... 75#p126058 I said,highend wrote:You have a trailing space at the end of this line...Why, because I spotted one.When copying/pasting make sure you don't have extra spaces in there as you did after the initial heredoc statement.
Re: [Script] WhiteSpaceCtxMenu
Hi CookieMonster, it was exactly the same space that highend referred to $psd = <<<PSD . Certainly removing it wouldn't have further broken the script. Something else did I would imagine.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
I'm sorry but the lightbulb is not going off in my head; as to this white space issue, if you could explain a little more as to the problem related to the white space problem in the script that you guys have been telling me numerous times, I would appreciate it.klownboy wrote:Hi CookieMonster, it was exactly the same space that highend referred to $psd = <<<PSD . Certainly removing it wouldn't have further broken the script. Something else did I would imagine.
To me the script looks fine, I'm looking at the script though Javascript eyes HighEnd and you KlownBoy are telling me, no, no, no you have white spaces
Re: [Script] WhiteSpaceCtxMenu
Please post the script in it's current state.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: [Script] WhiteSpaceCtxMenu
Hey CookieMonster, I initially mentioned be careful on spaces after the heredoc was on July 11 (5 days ago). I would think between all the comments and posts since then this would not be an issue any longer. I only re-mentioned it since highend said the same thing a few days ago...hopefully, it's all fixed now and working properly. Only worry about what you have for a script at this point. Is it working alright for you? If not, as Sammay suggested, post it. And by the way,
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Code: Select all
/*** text file menu ***/
$txt = <<<DOC
"NotePad++|C:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe";
"PSPad|C:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe";
"Notepad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe";
DOC;
$psd =<<<PSD
"Photoshop|C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe" openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe";
PSD;
if(exists("<selitem>") == 1) {
$selext = getpathcomponent("<selitem>", "ext");
if(gettokenindex($selext, "ini|txt|nfo|inf|reg|ps1|vbs", '|', 'i')) {load "$txt", , s; end(1);} //load textfile menu
elseif($selext LikeI "xys") {load("<selitem>"); end(1);} //no menu - example showing how you can automatically run an XY script on a right click on white
elseif($selext LikeI "ahk") {openwith "C:\Windows\notepad.exe"; end(1);} //no menu - example to open an AHK file for editing
elseif($selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}
else {#550; end(1);}
}
else {
#550
}
Re: [Script] WhiteSpaceCtxMenu
Hey again CookieMonster, if you click Select all above the code box that you just posted or simply highlight the text, you'll see there's an extra space after "$psd =<<<PSD ". Compare it to the heredoc for txt files, you'll see no space after "$txt = <<<DOC". Is what you posted working for you or not?
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
NO TWO NORMAL CODE LINES ARE ALLOWED TO BE NON INDENTED...
There are exceptions,
BUT YOUR SCRIPT DOESN'T CONTAIN ANY OF THEM (apart from what's inside the two heredocs).
I'm shouting? For a reason (it was correct beforehand...)
Now go and figure out what's wrong in your script!
There are exceptions,
BUT YOUR SCRIPT DOESN'T CONTAIN ANY OF THEM (apart from what's inside the two heredocs).
I'm shouting? For a reason (it was correct beforehand...)
Now go and figure out what's wrong in your script!
One of my scripts helped you out? Please donate via Paypal
Re: [Script] WhiteSpaceCtxMenu
I really do believe this time I got it, let me tinker with this for a bit, yes, I will post my results soon ! I'm heading out the door so soon will be a little while
Re: [Script] WhiteSpaceCtxMenu
Hey highend I noticed what you mentioned also. I then went to the help file and noticed Don did not indent his first example. The second example in help is indented. I always indent my heredocs unless it's using the alternate heredoc syntax #<<< . His first example in the help file does work with or without the indent. Regardless of my confusion with the help file, I should have went ahead and mentioned that in my post as well. OK, it's because it's only one heredoc - one line of code not indented that it works if there two it will not work. I think Don should have indented that first example even if just for consistently - it can be misleading?
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Hi Ken,
The general rule is in the help file as well:
Because it doesn't need to be indented as long as no other code is involved.I then went to the help file and noticed Don did not indent his first example
Because it needs to beThe second example in help is indented
I don't find it misleading. The second "real" line (echo $str;) is indented.OK, it's because it's only one heredoc - one line of code not indented that it works if there two it will not work. I think Don should have indented that first example even if just for consistently - it can be misleading?
The general rule is in the help file as well:
Multi-line Scripts and Multi-Scripts
A script can have more than one line (multi-line script), and a script resource can have more than one script (multi-script). There is one important formatting rule for multi-line scripts:
In a multi-line script all lines apart from the first line have to be indented by at least one space.
One of my scripts helped you out? Please donate via Paypal
Re: [Script] WhiteSpaceCtxMenu
Yeah, I realize that now. It's the general rule for XY scripting -highend wrote:Because it doesn't need to be indented as long as no other code is involved.
that applies and not a specific one for heredocs. Duh. Thanks highend for clarifying. In any case both before and after spaces were mentioned previously...highend wrote:In a multi-line script all lines apart from the first line have to be indented by at least one space.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
It is working beautifully, it was the indent, I had it known this morning but no time to post