Error Reporting

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
rjbill
Posts: 879
Joined: 13 Jun 2011 06:36

Error Reporting

Post 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.
RJTE version 16.16 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
User avatar
Rickard Johansson
Site Admin
Posts: 6628
Joined: 19 Jul 2006 14:29

Re: Error Reporting

Post 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...
User avatar
rjbill
Posts: 879
Joined: 13 Jun 2011 06:36

Re: Error Reporting

Post 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.
RJTE version 16.16 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
Post Reply