Skip to main content
Participant
January 10, 2011
Answered

Dialog box works in script but unable to hard code path

  • January 10, 2011
  • 1 reply
  • 437 views

I am writing a script to read xml document and convert it to pdf.

When I try to get path by opening dialog box ..it is working...

  var xmlFile = File.openDialog("Select Document XML File");

    if (xmlFile == null || xmlFile.name.length < 4)

      {

      alert("Invalid File");

      return;

      }   

This above code is working

But when I try :

    var xmlFile = '/c/xyz/abc.xml';

    alert(xmlFile);

  if (xmlFile == null || xmlFile.name.length < 4)

      {

      alert("Invalid File");

      return;

      }   

It pops out error

There error says:

Error Number : 21

Error String : undefined is not an object

Line 105:

Source :if (xmlFile == null || xmlFile.name.length < 4)

Can anybody help me with this.?

This topic has been closed for replies.
Correct answer

Hi Mohit,

Put "File" before '/c/xyz/abc.xml';

var xmlFile = File('/c/xyz/abc.xml');

    alert(xmlFile);
  if (xmlFile == null || xmlFile.name.length < 4)
      {
      alert("Invalid File");
      exit();
      }  

1 reply

Correct answer
January 10, 2011

Hi Mohit,

Put "File" before '/c/xyz/abc.xml';

var xmlFile = File('/c/xyz/abc.xml');

    alert(xmlFile);
  if (xmlFile == null || xmlFile.name.length < 4)
      {
      alert("Invalid File");
      exit();
      }  

Participant
January 15, 2011

Thanks alot Anil. It did wonders for me