When i try to read a line from a file using
Readln>C:\Documents and Settings\Owner\My Documents\file_20070924_175218.txt,%variable%,line
I get either:
Line=
(returns nothing)
OR
Line=##ERR## - Code : 32
It seems like the file was created using wordpad and not notepad. When opening in notepad, there are some characters that notepad cannot read. Is there any other way to read the file?
Thanks
Error when reading .txt (unicode)
Moderators: JRL, Dorian (MJT support)
Error when reading .txt (unicode)
Last edited by mafiamoe on Thu Sep 27, 2007 10:00 pm, edited 1 time in total.
Wordpad can write to several different file formats including plain text, Rich Text and Unicode Text. Wordpad will assign Rich text documents a .RTF extension. Wordpad will assign a .TXT extension to both plain text and to Unicode Text documents so there's no way to tell them apart by looking at the file name. There will probably be significant differences between a plain text and a unicode text file.
I created a unicode text file in WordPad by typing
Line 1
Line 2
Line 3
then saved the file as c:\test_document.txt
When I look at the file in a hex editor I see that the first four characters in the file are ascii characters 255, 254, 108 and 000. The ReadLn> function in Macro Scheduler will not report any part of the file after ascii character 000. ReadFile> with Separate> will not report anything after the first Ascii 000. ReadFile> with PutClipboard> will not report anything after the first Ascii 000. However ReadFile> then WriteFile> will recreate the file in its entirety.
I suspect that your file was saved to the unicode text format and will require a resave to plain text to be usable. Unless perhaps there is a VBScript trick that could be employed...? Or another thought would be to open the file in WordPad, Then Press ctrl + A then ctrl + C to capture all of the text to the clipboard. Then use GetClipboard> and Separate> to acquire each line of text.
Hope this was helpful,
Dick
I created a unicode text file in WordPad by typing
Line 1
Line 2
Line 3
then saved the file as c:\test_document.txt
When I look at the file in a hex editor I see that the first four characters in the file are ascii characters 255, 254, 108 and 000. The ReadLn> function in Macro Scheduler will not report any part of the file after ascii character 000. ReadFile> with Separate> will not report anything after the first Ascii 000. ReadFile> with PutClipboard> will not report anything after the first Ascii 000. However ReadFile> then WriteFile> will recreate the file in its entirety.
I suspect that your file was saved to the unicode text format and will require a resave to plain text to be usable. Unless perhaps there is a VBScript trick that could be employed...? Or another thought would be to open the file in WordPad, Then Press ctrl + A then ctrl + C to capture all of the text to the clipboard. Then use GetClipboard> and Separate> to acquire each line of text.
Hope this was helpful,
Dick
After reading your reply and doing some more research on my end, I can confirm that it is in fact in unicode. I tried searching the vbscript resources and thought I found a way to change the entire file from unicode to text format, but turned out to not work at all. I also tried the readfile/writeln technique and was able to copy over the folder, but inside the new .txt there are still characters that are not recognized so it cannot readln successfully. I am not sure opening wordpad is an option in the long run. I can use that for now to test the other areas of the code, but I will still be searching for a way to copy the file without running wordpad or a way to 'readln' directly from the unicode file.
Thanks for the help so far
Thanks for the help so far

It works!!!
The DOS command is unable to read the file that is in a folder with a space in it (eg. C:\program files\) but that was remedied with a simple copyfile to a new directory. The section of code used is below, with a couple variable changes so it makes a little more sense
CopyFile>C:\Program Files\program\unicode.txt,C:\test\newunicode.txt
Run Program>cmd /c type C:\test\newunicode.txt>C:\test\text.txt
What I actually use has some variables for the file locations, like:
Let>location=C:\Program Files\program
and then:
CopyFile>%location%\unicode.txt,C:\test\newunicode.txt
Thank you!!!
The DOS command is unable to read the file that is in a folder with a space in it (eg. C:\program files\) but that was remedied with a simple copyfile to a new directory. The section of code used is below, with a couple variable changes so it makes a little more sense

CopyFile>C:\Program Files\program\unicode.txt,C:\test\newunicode.txt
Run Program>cmd /c type C:\test\newunicode.txt>C:\test\text.txt
What I actually use has some variables for the file locations, like:
Let>location=C:\Program Files\program
and then:
CopyFile>%location%\unicode.txt,C:\test\newunicode.txt
Thank you!!!

- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: