Help with Siemens Macro no data when reading in file.

I have a macro that has me stumped. On a Siemens 810D, I can write to a fi le but I cannot read the data back in. I don't get an error from the read c
ommand. Error Boolean = 0 , I just get no data. VALSTR[1] = VALSTR[2] = blank (no data).
Here is a program snippet:
N7 DEF INT FILE_ERROR ; READ WRITE ERROR RETURN
N8 DEF STRING[255] VALSTR[2] ;NUMBER AS A STRING N10 DEF REAL SLNUM ; NUMBER
N12 DEF BOOL VALIS ;TEST RETURN OF ISNUMBER N14
N20 READ(FILE_ERROR, "/_N_SPF_DIR/_N_TESTFILE_SPF", 0, 1, VALSTR) N22 IF FILE_ERROR <>0 N24 MSG(<<FILE_ERROR<<" TESTFILE FILE NOT FOUND, CORRECT AND PRESS CYCLE ST ART") N26 M00
N30 ENDIF
N32 N34 VALIS = ISNUMBER (VALSTR[1]) N36 IF VALIS == FALSE N38 MSG("FILE DATA IS NOT A NUMBER," <<VALSTR[1]<< ", CORRECT AND PRESS CYC LE START") N40 M00
N44 ENDIF
N92 SLNUM = SLNUM + 1 N94 N96 VALSTR[1] = <<SLNUM
N104 WRITE(FILE_ERROR, "/_N_SPF_DIR/_N_TESTFILE_SPF", VALSTR[1]) N106 IF FILE_ERROR <>0 N108 MSG(<<FILE_ERROR<< " TESTFILE FILE NOT WRITTEN, CORRECT AND PRESS CYCL E START") N110 M00
N114 ENDIF
If I change "VALSTR" to VALSTR[1] in the read command I get a variable erro r. WHY? Also my write file appends but does not OVER WRITE the existing data. WHY? The Programming Guide 11/2002 Edition, 1.17 WRITE Write file (SW 4.3 and hi gher) says: "If a file with the same name exists on the hard disk, it is ov erwritten after the file is closed (in the NC)."
Any guidance would be treasured.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.