DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

FR function error

Solved!
Go to solution

Hi,

 

A piece of code that uses a .lst file has stopped working in DIAdem 2019. The code uses FileNameGet to obtain multiple filenames and saves the list to a .lst ASCII file. It then uses the FR function to read each line.

 

However, in DIAdem 2019, the first line comes back as the string ÿþm

 

Does anyone know why this is or how to correct it?

 

I see that there is the alternative function TextFileReadLn, but before I go ahead and change my code I wanted to ask if there is something else that I'm missing.

 

Thanks, Simon.

0 Kudos
Message 1 of 5
(2,460 Views)

Hi Simon,

 

When I get characters that are odd in a text file, it usually means that I have a mismatch between ASCII or unicode formating.

 

Best way to check is to run notepad++ or ultraedit (you can not see this in regular notepad)  and see what encoding the file is.  Most likely Notepad++ will say it is unicode.

 

You can read unicode(utf-8 in DIAdem, just just have to change one argument..

 

Paul

0 Kudos
Message 2 of 5
(2,403 Views)

Thanks Paul.

 

Notepad++ says the encoding is UCS-2 LE BOM. Naturally, this means nothing to me. I should also re-stress that the .lst file was written by DIAdem using its FileNameGet function so it seems odd that its FR function can't read its own files.

 

I'm afraid I don't know how to act on your last statement. The FR function only has two arguments and neither seem to relate to file format.

 

If you could clarify then I'd be grateful.

 

Thanks.

0 Kudos
Message 3 of 5
(2,385 Views)
Solution
Accepted by Simon_Aldworth

FileNameGet creates a Unicode file and FR supports only ANSI ASCII.

I think you have a few options.

 

  • Instead of FR you can use TextFileRead (with TextFileOpen, etc.) to import the Unicode file.
  • You can use the variable FileDlgFileName to get direct the list of selected files (if possible).
  • Alternatively, you can use FileDlgShow for selecting the files. This command is easier, has less parameters and returns direct the list of selected files.

Greetings

Walter

0 Kudos
Message 4 of 5
(2,380 Views)

Thanks Walter.

 

The help files clearly state that FileNameGet specifies an ASCII file. Nonetheless, thanks for the options. I have chosen to go with TextFileRead as I can do so with the least modification of my script.

 

Regards.

0 Kudos
Message 5 of 5
(2,370 Views)