Page 9 of 12
Re: [Script] WhiteSpaceCtxMenu
Posted: 15 Jul 2015 07:27
by bdeshi

- the middledots are spaces
the horizontal lines are tabs - 2015-07-15_112549.png (2.29 KiB) Viewed 4552 times
Re: [Script] WhiteSpaceCtxMenu
Posted: 15 Jul 2015 07:40
by highend
Whitespaces:

- Unbenannt.png (938 Bytes) Viewed 4551 times
Highlighted trailing whitespaces:

- Unbenannt1.png (647 Bytes) Viewed 4551 times
A plugin to highlight trailing spaces:
https://github.com/SublimeText/TrailingSpaces
Re: [Script] WhiteSpaceCtxMenu
Posted: 15 Jul 2015 22:48
by CookieMonster
klownboy wrote:
highend wrote:You have a trailing space at the end of this line...
2 days ago here
http://www.xyplorer.com/xyfc/viewtopic. ... 75#p126058 I said,
When copying/pasting make sure you don't have extra spaces in there as you did after the initial heredoc statement.
Why, because I spotted one.
At the end of line 8, if so I removed that and it further broke the script ?
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 01:28
by klownboy
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.
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 04:10
by CookieMonster
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.
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.
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
Posted: 16 Jul 2015 08:30
by bdeshi
Please post the script in it's current state.
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 13:29
by klownboy
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,

Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 15:56
by CookieMonster
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
}
The script, once again

Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 16:07
by klownboy
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?
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 16:08
by highend
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!
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 16:21
by CookieMonster
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
Posted: 16 Jul 2015 16:26
by klownboy
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?
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 16:40
by highend
Hi Ken,
I then went to the help file and noticed Don did not indent his first example
Because it doesn't need to be indented as long as no other code is involved.
The second example in help is indented
Because it needs to be
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?
I don't find it misleading. The second "real" line (echo $str;) is indented.
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.
Re: [Script] WhiteSpaceCtxMenu
Posted: 16 Jul 2015 17:02
by klownboy
highend wrote:Because it doesn't need to be indented as long as no other code is involved.
Yeah, I realize that now. It's the general rule for XY scripting -
highend wrote:In a multi-line script all lines apart from the first line have to be indented by at least one space.
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...
Re: [Script] WhiteSpaceCtxMenu
Posted: 17 Jul 2015 01:06
by CookieMonster
It is working beautifully, it was the indent, I had it known this morning but no time to post
