From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-05-2022 09:36 PM
Hi,
I'm writing this to report an issue rather than look for a solution.
The help files state that TextFileReadLn will return Null when it reaches the end of the file. However, that doesn't seem to be the case, at least not with my installation of DIAdem 2022, as it returns NoValue instead.
A minor change to my code got it working.
Regards.
Solved! Go to Solution.
11-07-2022 04:45 AM
Hi Simon_Aldworth,
Thank you for your information.
DIAdem uses NaN for NoValues and indicates that the variable contains no valid data.
VBS uses Null for the same behavior. In both cases you check for NoValues or for Null with the VBS function IsNull. In the end both NoValue and Null have the same meaning.
The following script (which describes your case) works fine.
dim iHdl, sFullFileName, text
sFullFileName = "MyFullFileName.txt"
iHdl = TextFileOpen(sFullFileName, eTextFileAttributeRead)
if iHdl <> 0 then
do
text = TextFileReadln(iHdl)
if not isNull(text) then
msgbox text
else
TextFileClose(iHdl)
end if
loop until isNull(text)
end if
Greetings
Walter
11-08-2022 02:23 AM
Hi Walter,
I'm afraid this doesn't work for me. My code is:
T1 = TextFileReadLn(FileNum)
If Not IsNull(T1) Then
Call DataFileLoad(DataReadPath & T1)
Etc, etc....
End If
This fails because it enters the If...Then code and tries to load a file called "NOVALUE".
However, the following is fine:
T1 = TextFileReadLn(FileNum)
If T1 <> "NOVALUE" Then
Call DataFileLoad(DataReadPath & T1)
Etc, etc...
End If
Regards.
11-08-2022 03:05 AM
Hi Simon_Aldworth,
Yes, the reason is T1. T1 is a DIAdem variable with the specific datatype String. A string can only contain text data and has no “marker” for NaN or Null. Therefor we implemented in case of assigning NaN (or Null) to DIAdem string variables the text “NoValue”.
In my example I used a VBS variable which is always a variant and can have different sub datatypes and works fine with NaN or Null.
Greetings
Walter