How to put into var contents of txt file?

I need to place into 2d-variable “myDocs” names and pathes of documents.
Text file:
Doc1
1_ABB\Doc1
Doc2
1_ABB\Doc2
Doc3
1_ABB\Doc3\

Then i would like to constract dialog with choosing one of these documents (by name) and open folder by finder (every 2nd line in file).

So first stage: how to read this txt-file into variable?

Thanks

Hi,

this solution reads the whole text file and creates two lists (name- and pathList).
An numeric index prefix is added to the name list for a fast lookup to get the appropriate path


set textFile to (choose file)
set textFileContents to paragraphs of (read textFile)
set nameList to {}
set pathList to {}
repeat with i from 1 to (count textFileContents) by 2
	set end of nameList to ((i div 2 + 1) as text) & " - " & item i of textFileContents
	set end of pathList to item (i + 1) of textFileContents
end repeat
set chosenName to choose from list nameList
if chosenName is false then return
set folderPath to item (word 1 of item 1 of chosenName) of pathList
tell application "Finder" to open folder folderPath


Note: The Finder expects HFS paths (colon separated)

Great. Does work. But now i can’t get in dialog Cyrillic characters.
Instead of
1_АББ\Создание
i got
1_“ê“ë“ë\\“°“æ“∑“¥“∞“Ω“∏“µ ”ɔÅ“ø“µ”à “Ω“æ“≥“æ
In text file coding is UTF wihout BOM.

How to work with Cyrillic fonts?

Thanks.

UTF-8 or UTF-16?

UTF-8


.
set textFileContents to paragraphs of (read textFile as «class utf8»)
.

UTF16


.
set textFileContents to paragraphs of (read textFile as Unicode text)
.

StefanK, many thanks!
«class utf8» - works properly))