Page 1 of 1

Error Reporting

Posted: 23 Jan 2024 18:51
by rjbill
The level and type of error reporting in the Scripting system is ridiculous and stupid.

Fixed it: The problem was "++nCount", which is not allowed, it has to be "nCount++".
It's actually SAD and unfortunate that the error reporting works like this.


For the JS code below, it only says " '}' Expected".

It should and needs to report the LINE at the very least, and PREFERABLY a column at or near the error.

Code: Select all

var nTabColumn = StrToInt (InputBox ("Tab To Column", "Tab To Column?", "0"));

if ((nTabColumn > 0)  &&  (nTabColumn < 200)) {
   Document.BeginUpdate();
   Document.BeginUndo();

   var nCursorX = Document.CursorX;
var nCount = 0;

   while ((Document.CursorX < nCursorX)  &&  (nCount < 200)) {

      Document.InsertText(" ");
++nCount;

   }

   Document.EndUndo();
   Document.EndUpdate();
}
THEN, to TRY to Debug it, I did the following, and the error message is "Not enough actual parameters".
So I changed InputBox (BACK) to: InputBox ("Tab To Column", "Tab To Column?", "0")
which is what I had initially, but I removed the default value "0" because I looked at the help
and InputBox says there is no Default Value parameter: (so WTF is up with that??)
InputBox

Syntax

InputBox(const wsCaptions, wsPrompt: String): String

Description

Display a dialog box to obtain user input.

Example

var
s: string;

begin
s := InputBox('Name', 'Enter a user name:');
...
end.

Code: Select all

var sTabColumn = InputBox ("Tab To Column", "Tab To Column?");
var nTabColumn = StrToInt (sTabColumn);

//if ((nTabColumn > 0)  &&  (nTabColumn < 200)) {
   //Document.BeginUpdate();
   //Document.BeginUndo();

   var nCursorX = Document.CursorX;
var nCount = 0;

//   while ((Document.CursorX < nCursorX)  &&  (nCount < 200)) {

      Document.InsertText(" ");
++nCount;

//   }

   //Document.EndUndo();
   //Document.EndUpdate();
//}
With the above, it does the prompt.

Re: Error Reporting

Posted: 23 Jan 2024 21:24
by Rickard Johansson
InputBox() is a method inside the MainApp object, so it should be MainApp.InputBox("Hello", "world!");

The text cursor is positioned at the error. So the line and column will be the same as the current cursor position...

Code: Select all

// JScript

var nTabColumn = StrToInt (MainApp.InputBox("Tab To Column", "Tab To Column?"));

if ((nTabColumn > 0)  &&  (nTabColumn < 200)) {
   Document.BeginUpdate();
   Document.BeginUndo();

   var nCursorX = Document.CursorX;
   var nCount = 0;

   while ((Document.CursorX < nCursorX)  &&  (nCount < 200)) {

      Document.InsertText(" ");
      nCount++;

   }

   Document.EndUndo();
   Document.EndUpdate();
}
This seems to compile...

Re: Error Reporting

Posted: 23 Jan 2024 22:18
by rjbill
It works without the MainApp.

Mine has never changed the cursor location anywhere. (that I can remember historically, even)
Even when I do Dual Document View like is suggested in the Help.