Page 1 of 2

2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 11:48
by aliteralmind
I have this trivial script file:

Code: Select all

msg "Hello1";
   msg "Hello 2";
When executing it via "Scripting > Load selected file", the second line causes an error, seemingly because of the indentation. The documentation says "all lines but the first must be indented by at least one space", and this is indented by three spaces. What am I missing, please?

Image

And is it true that empty lines at the bottom of a script file cause this same error?

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 12:12
by highend
Select your script file and use this in the address bar:

Code: Select all

::text filetype();
Output?

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 12:16
by aliteralmind
UTF-16LE

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:10
by highend
You must have something weird in your file.

Creating an UTF-16LE file named test.xys
with

Code: Select all

msg "a";
    msg "b";
Works fine here.

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:27
by aliteralmind
Yup!

Sublime Text does something funny. It fails when the file is created in Sublime, but works when created in TextPad.

Now what?

:(

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:35
by highend
I'm using:

"default_encoding": "UTF-8",

and that works perfectly fine when I create new .xys files from within ST.

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:41
by aliteralmind
I attached the script as saved in both Sublime and in TextPad.

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:46
by highend
You did notice that TextPad didn't use UTF-16LE (but Windows 1252)?

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:47
by aliteralmind
Huh!

My Sublime *is* setup that way:

Code: Select all

    // Encoding used when saving new files, and files opened with an undefined
    // encoding (e.g., plain ascii files). If a file is opened with a specific
    // encoding (either detected or given explicitly), this setting will be
    // ignored, and the file will be saved with the encoding it was opened
    // with.
    "default_encoding": "UTF-8",

    // Determines what character(s) are used to terminate each line in new files.
    // Valid values are 'system' (whatever the OS uses), 'windows' (CRLF) and
    // 'unix' (LF only).
    "default_line_ending": "system",
I also tried "windows" and "unix" line endings, but same result. :evil:

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 13:51
by aliteralmind
For me, "::text filetype();" results in "Ascii" on the TextPad file, and "UTF16-LE" on the Sublime one (even though it's configured as "UTF-8").

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 14:12
by highend
I've used EditPadPro to check the encoding of the file instead of filetype().

Try to use
"fallback_encoding": "Western (Windows 1252)",

in ST.

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 14:18
by aliteralmind
Already is. :(

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 14:42
by PeterH
Try to preview (raw view!) files in hexadecimal, and compare?

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 14:47
by bdeshi
The line break/newline format is Unix. Set it to Windows.

open the file in ST, change the newline format, then save the file?

Re: 2nd line in multi-line script (1st indented) "not valid"

Posted: 26 Dec 2014 15:00
by aliteralmind
The file:

Code: Select all

$rootdir = "C:\Users\aliteralmind\AppData\Roaming\Sublime Text 3";
   $srcdir = $rootdir."\Packages\User\notes_and_backup\SideBarEnhancements_my_tweaks";
   $destdir = $rootdir."\Packages\SideBarEnhancements";
   if (confirm("About to delete ".$destdir.*.". Continue?", , 2) == 0) { end true;
   } delete 1, 0, $destdir."*";
   zip_extract($rootdir."\Installed Packages\SideBarEnhancements.zip", $destdir);
   wait 500;
   if (confirm("About to implement tweaks. Continue?", , 2) == 0) { end true;
   } $destfile = $destdir."\Side Bar.sublime-menu";
   $srctxt = readfile($srcdir."\Side Bar.sublime-menu");
   writefile($destfile, $srctxt);
   $destfile = $destdir."\SideBarAPI.py";
   $srctxt = readfile($srcdir."\SideBarAPI.py");
   writefile($destfile, $srctxt);
   $destfile = $destdir."\_jeff_epstein_notes.txt";
   $srctxt = readfile($srcdir."\_jeff_epstein_notes.txt");
   writefile($destdir."\_jeff_epstein_notes.txt", $srctxt);
//; delete 1, 0, $destfile
//; delete 1, 0, $destfile
//; delete 1, 0, $destfile
I changed the line-ending to "windows".

Raw view of the Sublime version:

Image
And TextPad:

Image

---

Can't XY just ignore line-ending differences? :(