Is it possible to read an htm or html file as a string?

I need to figure out if this is possible before I commit time to it. I have htm files that are used in a .net application for CNC machines. Somehow they use them to render up things in their thing. When I open in a text editor I get something like the following:

<HTML>
<HEAD>
<TITLE>Fault Tags</TITLE>
</HEAD>
<BODY>

<H1 ALIGN = CENTER>Fault Tags</H1>

<BR><HR><H3 ALIGN = CENTER>INTRODUCTION</H3>

<H4 align="center">FAULTS</H4>

<p>&nbsp;</p>

<p>
<HR><A NAME = "D"></A>
Delay Faults<br>
<HR><A NAME = "D1"></A>
D1	 HYDRAULIC PRESSURE ALARM<br>
FLT.D_FLT[0].0<br>
Fault:	 The system has excessive backpressure in one of the hydraulic filters.&nbsp;<br>
Action:	 Check power pack return and supply filters and replace as necessary.
<br>
<p><img border="0" src="FLT.D_FLT[0].0.jpg" width="600" height="600">
<br>
</p>
<HR><A NAME = "D2"></A>
D2	 TABLE DID NOT LIFT UP<br>
FLT.D_FLT[0].1<br>
Fault:	 The Table Down prox did not turn off, or the Table Up prox did not turn<br>
 on when the Table Up solenoid was energized during the last table index<br>
 sequence.&nbsp;<br>
Action:	 Check prox switch and solenoid operation and adjust, repair or replace as needed.<br>
<br>
<p><img border="0" src="FLT.D_FLT[0].1.jpg" width="600" height="600">
<p><img border="0" src="FLT.D_FLT[0].11.jpg" width="600" height="500">

When I try to read it through a console it throws:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
IOError: File 'P:\will\Gage\FaultTagsD.htm' doesn't exist or isn't a file.

I also saved it as HTML and the same results. As a sanity check. After researching seems like there isn’t much diff.

Eventually, the goal would be to read it and output:

D1	 HYDRAULIC PRESSURE ALARM
FLT.D_FLT[0].0
Fault: The system has excessive backpressure in one of the hydraulic filters.&nbsp
Action: Check power pack return and supply filters and replace as necessary.

In some way. To store. I can figure out that bit if it is possible to read?
Or maybe place them in the web apps folder and scrape?
Or give up and have interns make it manually next summer?

Sure you can.

1 Like

Tested and working for HTM extension too

Right on, thanks man!

I figured it could.

So it’s gotta be an access problem. I’m confused on what scope the script console is ran in. It is using the mapped drive of server or my machine. But, we’ll get er figured out. I have same drive mapped to different letters lol on the machines. Although I cant get either to work rn

Scripts from the console run on the same machine as the Designer you’re running it in. Make sure the path/file you access is readable from your machine in that case.

You may need to add the mapped drive into the Ignition conf file.

There is a section in the user manual that details this, and also search this forum if stuck there are several posts on the topic.

Don’t forget in your path to double up all your backslashes as seen in my attachment.

This is necessary if accessing the file in a script running in gateway scope.

Yeah, I have did this and seems to be working fine. Its something else. I have similar things working already…

I added hashes in front of the edits. And didn’t find anything in the logs. Don’t know how to prove it other than that and testing from console.

Are you using sufficient backslashes in the path, as per @Matrix_Engineering’s example?

It is running on my local machine accessing my mapped drives on my local machine:

I did a bunch of work earlier thinking I was using the mapped drive of the server not paying a ton of attention to file paths. It was just working. I was confused as P: is Z: and vice versa… :roll_eyes:

To avoid this problem when hard coding the path, you could always use the \domain\folder\path style.

So instead of using P: or Z: you would have ‘//Domain_or_server/Folder/’ an example would be “\\EPIC-FILESVR\Shared\will\Gage\FaultTagsD.htm”

This is what I use as it guarantees you point to the correct location regardless of what machine it’s used on. You only have to make sure that the user running the script has rights to access the shared drive.

1 Like

Nice.

So that works from console nicely:

Can’t tell if it’ll work from gateway yet. Trying to figure out how to get my global scripting project to work. For that. Then I can confirm if the drive is mapped in ignition. One step at a time. Thanks man!