Book a Demo

Author Topic: OpenTextFile is not a function  (Read 2887 times)

fy1997

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
OpenTextFile is not a function
« on: June 02, 2020, 01:06:01 pm »
When I use EA simulation, I want to use JavaScript to read the data of the local file. I used COMObject("Scripting.FileSystemObject"), but when I use the OpenTextFile function, I get an error: [-1196949623] TypeError: fso .OpenTextFile is not a function, the version I use is v15.0.1508, why is this happening?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: OpenTextFile is not a function
« Reply #1 on: June 02, 2020, 02:17:53 pm »
Posting your code might help someone spot the error.

Geert

fy1997

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: OpenTextFile is not a function
« Reply #2 on: June 02, 2020, 08:19:04 pm »
Thanks!And this is my code:
var fso, ts, s ;
var ForReading = 1;

fso = new COMObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile("exam.json", ForReading);
s = ts.ReadAll();

And I got a error:OpenTextFile is not a function.