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

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post 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?
Windows 8.1, 64-bit

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post by highend »

Select your script file and use this in the address bar:

Code: Select all

::text filetype();
Output?
One of my scripts helped you out? Please donate via Paypal

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post by aliteralmind »

UTF-16LE
Windows 8.1, 64-bit

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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.
One of my scripts helped you out? Please donate via Paypal

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post 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?

:(
Windows 8.1, 64-bit

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post by highend »

I'm using:

"default_encoding": "UTF-8",

and that works perfectly fine when I create new .xys files from within ST.
One of my scripts helped you out? Please donate via Paypal

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post by aliteralmind »

I attached the script as saved in both Sublime and in TextPad.
To see the attached files, you need to log into the forum.
Windows 8.1, 64-bit

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post by highend »

You did notice that TextPad didn't use UTF-16LE (but Windows 1252)?
One of my scripts helped you out? Please donate via Paypal

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post 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:
Windows 8.1, 64-bit

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post 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").
Windows 8.1, 64-bit

highend
Posts: 14950
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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.
One of my scripts helped you out? Please donate via Paypal

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post by aliteralmind »

Already is. :(
Windows 8.1, 64-bit

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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

Post by PeterH »

Try to preview (raw view!) files in hexadecimal, and compare?

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

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

Post 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?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

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

Post 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? :(
Windows 8.1, 64-bit

Post Reply