SC Include: script error when no ref

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

SC Include: script error when no ref

Post by Filehero »

Hi Don,

with 17.20.0101 I get (better: first observed) a script error "<script> does not contain any valid lines." with the following code.

Code: Select all

include "libs\fh_lib.inc"; // put your lib reference here
  
  $FILE_NAME = "cmd.exe";  
  $filePath = quicksearch($FILE_NAME, "C:\", <crlf>, "s");
  msg($filePath, 1);
  if (exists($filePath) == 1) {
    msg($filePath, 1);
  }
  //$temp = getXYTemp();
Once I uncomment the last (and only) line actually referencing a function from the included library, the error goes away.

My expected behavior: I can put in as much "unused" includes as I like as long as I respect all defined SC limits (100 nested includes etc.).


FH

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC Include: script error when no ref

Post by admin »

Tough bug and tougher to fix. But it would never have surfaced if you had your syntax right. Having the line $FILE_NAME = "cmd.exe"; indented was (wrongly) tolerated under certain conditions, but it was never alright. Code should look like this:

Code: Select all

include "math.inc"; // put your lib reference here
 
$FILE_NAME = "cmd.exe"; 
  $filePath = quicksearch($FILE_NAME, "E:\Test\moveup\parent", <crlf>, "s");
  msg($filePath, 1);
  if (exists($filePath) == 1) {
    msg($filePath, 1);
  }
  //$temp = sum(1, 2);

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC Include: script error when no ref

Post by Filehero »

admin wrote:Tough bug and tougher to fix. But it would never have surfaced if you had your syntax right. Having the line $FILE_NAME = "cmd.exe"; indented was (wrongly) tolerated under certain conditions, but it was never alright. Code should look like this:

Code: Select all

include "math.inc"; // put your lib reference here
 
$FILE_NAME = "cmd.exe"; 
  $filePath = quicksearch($FILE_NAME, "E:\Test\moveup\parent", <crlf>, "s");
Bugs can make programmers even more sloppy. :oops:

Really, I did it that often that I really forgot about the right way. Thanks for fixing. :)

Btw, it is still (wrongly) tolerating the missing indents, even with Syntax Checking on.


Cheers,
Filehero

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC Include: script error when no ref

Post by admin »

Yes, it's still tolerating because there is ambiguity. Tricky stuff. I cannot be too cold-blooded here.

But that "<script> does not contain any valid lines." message is gone, right?

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC Include: script error when no ref

Post by Filehero »

admin wrote: But that "<script> does not contain any valid lines." message is gone, right?
Yes, it's gone - fix confirmed. Thanks. :)

Post Reply