Mastering E-Prime: How to use a custom data file or path name

David McFarlane mcfarla9 at msu.edu
Tue Feb 2 02:27:37 UTC 2010


E-Prime automatically puts data files into the same directory as the 
.ebs (or .ebs2) file, and gives each one a name of the form 
<Experiment>-<Subject>-<Session>.edat (or .edat2).  But what if you want 
to customize the file name, or change the path to put data files in a 
chosen directory location?

You can do this by taking control of the Context.Datafile object, which 
you may learn about in the online E-Basic Help or from the code that 
E-Studio generates for the Main() routine.  You would then add the 
appropriate inline code as the first thing in your SessionProc.  Here is 
an example script that you may build on.  For the sake of this example 
we ask the experimenter for their initials (and then add that to the 
file name), though in practice we would more likely make this a 
StartupInfo parameter.

' Close data file already started in the Main() routine.
If CLng(c.GetAttrib("Subject")) <> 0 Then
	c.DataFile.Close
	Kill c.DataFile.FileName  ' might as well also delete it
End If
' Construct new file or path name any way you like.  You may want to
' add code to deal with potential problems such as existing (duplicate)
' or illegal file names and non-existent directories.
Dim  exptrID as String
exptrID = AskBox( "Enter experimenter initials:" )
c.DataFile.Filename = c.GetAttrib("Experiment") & "-" & exptrID & "-" _
	& c.GetAttrib("Subject") & "-" & c.GetAttrib("Session") & ".txt"
' Start new data file.
If CLng(c.GetAttrib("Subject")) <> 0 Then
	c.DataFile.Open
	c.LogHeader
End If

Note that this method uses ordinary features of E-Prime and should work 
with every version going back to 1.0.

A couple of warnings:  First, if you use this to change the data path, 
pay attention to the use of forward slashes ("/") vs. backslashes ("\") 
as path separators in E-Prime strings, as discussed at 
http://support.pstnet.com/forum/Topic2336-12-1.aspx and elsewhere. 
Second, without care you could easily lose data doing this, so do not do 
this unless you know what you are doing and can enforce the proper 
safeguards.

-- David McFarlane, E-Prime Master & Professional Faultfinder

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list