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.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

FileNameGet writes as Unicode and FR cannot read list

Solved!
Go to solution

Hello all,

 

I am trying to use DIAdem Script to automate my measurement conversion from .tdms to .csv.

 

To load as a list, I use the function FileNameGet which generates and saves a list of measurements.

Using a loop, I then iterate and convert each file after reading using FR.

The problem is FileNameGet always writes as Unicode even after changing my DIAdem environment encoding to ASCII.

On the other hand, FR does not support Unicode.

Currently, I always pause the execution, open the list of experiments and convert them to ASCII manually using a text editor, before proceeding.

Do you know of any better solution? (See my full code below)

 

I am a novice and will be glad to count on your assistance.

Thanks in advance and regards.

 

 


Call FileNameGet("ANY","FileRead",strText1, strText2, strText3, strText4, strText5)
strText5 = FR(LoadPath & "text.txt",1)

If MsgBox("Save as ASCII complete?",vbQuestion + vbYesNo) = vbYes Then
' Just to pause execution
End If

I = 1
While strText5 <> "EOF"

strText5 = FR(LoadPath & "text.txt" ,I)
if strText5 <> "EOF" then
Call DataFileLoad(strText5,"TDMS","Load")
Call DataFileSave(strText5&".csv","CSV_EXPORT")
DataDelAll()

Call LogfileWrite(strText5 & " is done")
End If

I = I + 1
Wend

0 Kudos
Message 1 of 2
(626 Views)
Solution
Accepted by tch007

Hi tch007

DIAdem supports a simpler command for requesting file selections. You find an example below.

dim iCount
if FileDlgShow(DataReadPath, "My CSV Files,*.CSV", "Data selection", true) = "IDOk" then
  For iCount = 0 To Ubound(FileDlgNameList)
    Call msgbox(FileDlgNameList(iCount))
  Next
Else
  Call MsgBox ("The loading of the data was aborted.")
End If

 

In addition, the FR is an old command with several restrictions. The better choice for text file handling would be TextFileOpen, TextFileReadLn, etc. You find details and examples in the DIAdem help.

 

Greetings

Walter

0 Kudos
Message 2 of 2
(574 Views)