• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

javascript runtime error - Object Expected

Greetings,

Trying to understand why the message in the picture would appear for the code below:

var sInputFile = GetScriptArgument( 0 );
var sOutputFile = sInputFile .replace(sInputFile .substring(sInputFile .lastIndexOf(".")), ".pdf");

StartTest(sInputFile , sOutputFile )       //  ********************** ERROR ON THIS LINE **********************
{
		var DestinationFile;		
		
		DestinationFile = sInputFile .substring(sInputFile .lastIndexOf("."));
...
...	
}

Open in new window


This code is at the very beginning of the js file.

Thanks!
js-object-required.jpg
0
John500
Asked:
John500
  • 5
  • 3
  • 2
  • +1
1 Solution
 
leakim971PluritechnicianCommented:
replace by the four first lines with :

var sInputFile = GetScriptArgument( 0 );
var sOutputFile = sInputFile.replace(sInputFile.substring(sInputFile.lastIndexOf(".")), ".pdf");

StartTest(sInputFile , sOutputFile )       //  ********************** ERROR ON THIS LINE **********************
{
		var DestinationFile;

Open in new window

0
 
Paul JacksonCommented:
change this :
StartTest(sInputFile , sOutputFile )
to
function StartTest(sInputFile , sOutputFile )
0
 
leakim971PluritechnicianCommented:
line 8 too :
DestinationFile = sInputFile.substring(sInputFile.lastIndexOf("."));

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
John500Author Commented:
Ok,  I changed things and it now looks like this:

function StartTest(sInputFile , sOutputFile )
{
		var DestinationFile;		
		
		try
		{
			 for (i = 0; i < 1001){   // ***********  (15, 25) Microsoft JScript compilation error: Expected ';'  **********
			      	     		
			      DestinationFile = "C:\Test\sub_directory\" + sOutputFile + "-" + i + ".pdf";
						MyConverterFunction(sInputFile , DestinationFile);
			  }
		}
		catch(err)
	  {
		  txt="Error printing PDF.\n\n";
		  txt+="Error description: " + err.description + "\n\n";
		  txt+="Click OK to continue.\n\n";
		  alert(txt);
	  }
}

Open in new window


The error is supposedly due now to a semicolon on line 15

I'm code blind on that one!
0
 
John500Author Commented:
... forgot to finish the FOR loop
0
 
John500Author Commented:
now it's:

        (17, 90) Microsoft JScript compilation error: Unterminated string constant



On this line:

       DestinationFile = "C:\Test\Feed_BPO_Print\" + sOutputPDFFile + "-" + i + ".pdf";

Which is right around the ".pdf" area
0
 
John500Author Commented:
I've corrected " i  "  by using

i.toString()

but I still get an error on char 101 of this line:

            DestinationFile = "C:\Test\Feed_BPO_Print\" + sOutputPDFFile + "-" + i.toString() + ".pdf";

Character 101 is right after the 'd' in ".pdf"

Thanks

0
 
Paul JacksonCommented:
what's the error?
0
 
leakim971PluritechnicianCommented:
Escape the backslash

DestinationFile = "C:\\Test\\Feed_BPO_Print\\" + sOutputPDFFile + "-" + i + ".pdf";

Open in new window

0
 
hieloCommented:

function StartTest(sInputFile , sOutputFile )
{
		var DestinationFile;		
		
		try
		{
			 for (var i = 0; i < 1001; ++i){ 
			      	     		
			      DestinationFile = "C:\\Test\\sub_directory\\" + sOutputFile + "-" + i + ".pdf";
						MyConverterFunction(sInputFile , DestinationFile);
			  }
		}
		catch(err)
	  {
		  txt="Error printing PDF.\n\n";
		  txt+="Error description: " + err.description + "\n\n";
		  txt+="Click OK to continue.\n\n";
		  alert(txt);
	  }
}

Open in new window

0
 
John500Author Commented:
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now