Page 1 of 1

SC Include: script error when no ref

Posted: 03 Oct 2016 15:43
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

Re: SC Include: script error when no ref

Posted: 03 Oct 2016 20:41
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);

Re: SC Include: script error when no ref

Posted: 03 Oct 2016 21:53
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

Re: SC Include: script error when no ref

Posted: 03 Oct 2016 22:22
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?

Re: SC Include: script error when no ref

Posted: 03 Oct 2016 23:51
by Filehero
admin wrote: But that "<script> does not contain any valid lines." message is gone, right?
Yes, it's gone - fix confirmed. Thanks. :)