Display a text file

155 views
Skip to first unread message

mfc.l...@gmail.com

unread,
Feb 19, 2021, 12:19:55 PM2/19/21
to E-Prime
Hi everyone!
I was wondering if there is any way to display a .txt file in a TextDisplay object? When I use square brackets with the attribute, it only shows the name of the file. What is the alternative, saving my text as pictures and presenting ImageDisplay objects?
Thank you very much for your help!
Best,
Marie

David McFarlane

unread,
Feb 22, 2021, 3:06:07 PM2/22/21
to e-p...@googlegroups.com
Marie,

I took a few minutes to make this work for myself using EP2.0.10.356,
here is how I did it:

1) Put the text file names in a List like usual (in my case I leave off
the ".txt" at the end and then add that later with inline code, just
because I think that looks neater).

2) Use an attribute reference such as [StimText] in your stimulus object
like usual.

3) Add an InLine object before your stimulus object (TextDisplay, Slide,
etc.). Use this inline code to read the file named at step 1 into the
attribute named in step 2. E.g., with a List column named "TextFile"
holding file names, and using the attribute "StimText" for the text to
display,

Dim fNum As Integer
Dim fName As String
fName = c.GetAttrib("TextFile") & ".txt"
fNum = FreeFile
Open fName For Input As fNum
c.SetAttrib "StimText", Input$(FileLen(fName), fNum)
Close fNum

4) Back on your stimulus object, open its property pages, go to the
Common tab, and set Generate PreRun to "BeforeObjectRun", otherwise
E-Prime will try to fill in the attribute reference before the InLine
runs and the task will crash.

That should take care of it. No big deal once you know how. See topics
"Freefile", "Open", "Input$ (functions)", and "Close" in the E-Basic
help for more info.

-- David McFarlane

mfc.l...@gmail.com

unread,
Feb 23, 2021, 8:43:01 AM2/23/21
to E-Prime
Hi David,
Thank you so much, that did the trick! It is indeed quite simple (once you know how). Thank you so very much for your help!
Best,
Marie

Reply all
Reply to author
Forward
0 new messages