|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/29/2008 11:17:35 AM
Posts: 6,
Visits: 10
|
|
Hi, I'm having trouble using a parameterized filename for an ImageDisplay object. I have a list with a column "Image" with values like "test-chair1.jpg". In the object, I use the string "CE5-stimuli\[Image]", which should properly select the file. However, when I compile the script, I get a compile-time error and the following in the Script window:
DisplayStim.Filename = "CE5-stimuli\[Image")
Yes, that's right, with the extra right parenthesis and no interpolation. If I move the files into the working directory, so that the filename is just "[Image]", it seems to work fine. If I hard-code that filename into the object, complete with subdirectory, it also displays with no problem.
How do I get EP2 to use parameterized image names in subdirectories without choking? Thank you,
-Harlan
|
|
|
|
|
Forum MVP
      
Group: Forum Members
Last Login: Today @ 3:46:25 PM
Posts: 336,
Visits: 894
|
|
HarlanHarris (10/24/2008) In the object, I use the string "CE5-stimuli\[Image]", which should properly select the file.
We have run into that problem many times, and it has a simple solution. In your object, use either
CE5-stimuli/[Image]
or
CE5-stimuli\\[Image]
Explanation: E-Primes sets Option CStrings to On. In C (and Unix), the \ character serves as an "escape" character to override the usual meaning of the following character. Since the [ character usually has the special meaning of introducing an attribute reference, the "\[" sequence instead means to treat the [ as just a literal [ character and nothing more, hence the error. The sequence "\\[" instead says to ignore the special meaning of the second \ character and treat it as a literal character, so that translates into a "\[" sequence and you get the usual special meaning of "\[". Follow? Finally, C uses forward slashes as a path separator, so that also works.
I have learned to always use the forward slash in E-Prime paths, since that always works with less thought about when to use a singe vs. double backslash, but that may be a matter of taste.
-- David McFarlane, Professional Faultfinder
|
|
|
|
|
Forum MVP
      
Group: Forum Members
Last Login: Today @ 3:46:25 PM
Posts: 336,
Visits: 894
|
|
Some further thought on file path separators in E-Prime...
The E-Studio GUI contributes to this confusion because, when you use the file browser to add a sample file name, it uses a single backslash for the file path separator. So when you edit this to include an attribute reference you naturally leave in the single backslash, and then get an error. It would help if the E-Studio GUI instead inserted either a single forward slash or a double backslash for us. Or if PST would document this in some obvious place. (OTOH, almost nobody but me bothers to read the documentation anyway, and even I have missed many parts of the documentation.)
-- David McFarlane, Professional Faultfinder
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/29/2008 11:17:35 AM
Posts: 6,
Visits: 10
|
|
David McFarlane (10/24/2008)
HarlanHarris (10/24/2008) In the object, I use the string "CE5-stimuli\[Image]", which should properly select the file.
We have run into that problem many times, and it has a simple solution. In your object, use either
CE5-stimuli/[Image]
or
CE5-stimuli\\[Image]
David, works perfectly, thank you very much! Yes, a very unfortunate issue with escape characters and DOS paths...
|
|
|
|