Wow, I had forgotten about that hack! Thanks for reminding me Chris. I
thought we had no more use for that hack once EP2.0.10 included its own
facility for custom data file names. But it becomes useful again for
the purpose here.
I tested the hack with EP3, running it as a InLine in SessionProc, and
it still works. I revised it a bit based on a reading of the Full
Script generated by EP3 (one can learn a lot from reading the code
generated by E-Studio!). Give this a try, and modify as desired:
Dim filenameBase As String
Dim filenameRecovery As String
Dim filenameEDAT As String
Dim fileNameExport As String
' Close data file already started in the Main() routine.
If (CLng(c.GetAttrib("Subject")) <> 0) Then c.DataFile.Close
' Construct new file or path name any way we like. May want to add code
to deal
' with potential problems such as existing (duplicate) or illegal file
names and
' non-existent directories.
' For this example, we add the date and a random number to the file name (I
' leave it as an exercise to add the time to the file name -- hint,
Windows does
' not allow colons in file names).
filenameBase = c.GetAttrib("Experiment") & "-" _
& c.GetAttrib("Subject") & "-" & c.GetAttrib("Session") _
& "-(" & c.GetAttrib("SessionDate") & "#" & PRNG.GetNext() & ")"
filenameRecovery = filenameBase & ".txt"
filenameEDAT = filenameBase & ".edat3"
fileNameExport = filenameBase & "-Export.txt"
c.DataFile.Filename = filenameRecovery
c.SetAttrib "DataFile.Basename", filenameBase
If CLng(c.GetAttrib("Subject")) <> 0 Then
' Remove any existing file; may want to add some overwrite
protection here.
If FileExists(filenameEDAT) Then Kill filenameEDAT
If FileExists(fileNameExport) Then Kill fileNameExport
If FileExists(c.DataFile.Filename) Then Kill c.DataFile.Filename
' Start new data file.
c.DataFile.Open
c.LogHeader
End If
-- David McFarlane
On 2020-06-27 Sat 10:15 AM, Chris Broz wrote:
> Is it possible to modify the startup sequence in your case to ask the user
> for date and time, and then include those in file names? Or even asking
> them to pull the number from a site before beginning (e.g., a timestamp
> <
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fwww.unixtimestamp.com%2F__%3B!!HXCxUKc!jtE8ei6dTfjWIni-EKHAJlyrRUzwFOjDZ359UUr4Okzna9x_bJgkWxKcStg5qBOz%24&data=01%7C01%7Cmcfarla9%40msu.edu%7Cd11cd7ead9664b82f03e08d81aa480eb%7C22177130642f41d9921174237ad5687d%7C0&sdata=oZ9OW7xM7ppl%2FiXM7kOk1htpgwNPw0jcBqjPdMt8MxQ%3D&reserved=0 >). That might minimize overwriting. You
> could then treat that string as a unique subject number. It's still
> possible for users to submit the same values, but it seems less likely than
> folks accepting the default.
>
> I just tried to insert a math function Random(Low, High) into a startup
> prompt as the default. It didn't work, which makes sense. Code injection
> into a file name seems risky. Here's
> <
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fgroups.google.com%2Fforum%2F*!topic%2Fe-prime%2FBWWATXRikOA__%3BIw!!HXCxUKc!jtE8ei6dTfjWIni-EKHAJlyrRUzwFOjDZ359UUr4Okzna9x_bJgkWxKcSuFI3Zec%24&data=01%7C01%7Cmcfarla9%40msu.edu%7Cd11cd7ead9664b82f03e08d81aa480eb%7C22177130642f41d9921174237ad5687d%7C0&sdata=Jm%2B0ILOGyISm8tNS5S9Lk5nIXgeThK75ko1hQODO02E%3D&reserved=0 > an old forum