|
|
|
Junior Member
      
Group: Forum Members
Last Login: 9/22/2008 9:54:26 AM
Posts: 16,
Visits: 69
|
|
| Hi, I'm trying to create a list of files that are held in a sub-folder. The two examples below should (in my opinion!) give the same result. ie; list the first two files held in "SubFolder01". But... only Example 1 works. Example 2 just adds the word "files", then two blank lines, in the debug window. I'd rather not have to change directory just to read what's there, so can someone please tell me what's wrong with my code? Thanks, J. EPrime v2.0 '=========================== Example 1 ChDir ("SubFolder01") dim i% Dim a$(10) a(1) = Dir$("*.*") i = 1 While (a(i) <> "") And (i < 10) i = i + 1 a(i) = Dir$() Wend debug.print "files: " & crlf & a(1) & crlf & a(2) '=========================== Example 2
dim i% Dim a$(10)
a(1) = Dir$("SubFolder01\*.*") i = 1 While (a(i) <> "") And (i < 10) i = i + 1 a(i) = Dir$() Wend debug.print "files: " & crlf & a(1) & crlf & a(2) '===========================
...I'm an immortal...so far...
|
|
|
|
|
Junior Member
      
Group: Forum Members
Last Login: 9/22/2008 9:54:26 AM
Posts: 16,
Visits: 69
|
|
Sorry! I meant to say I'm using E-Prime version 1.0, NOT version 2! ... I can't work out how to edit my original post... J
...I'm an immortal...so far...
|
|
|
|
|
Forum Guru
      
Group: Forum Members
Last Login: Today @ 6:03:05 PM
Posts: 229,
Visits: 607
|
|
JackOByte,
Just a guess, since I did not bother to test this myself...
Since E-Prime has the CStrings option on, the backslash '\' character acts as an "escape" character. Thus, the line
a(1) = Dir$("SubFolder01\*.*")
Gets interpreted as
a(1) = Dir$("SubFolder01.*")
To avoid this, you need to escape the escape, e.g.,
a(1) = Dir$("SubFolder01\\*.*")
Alternatively, in E-Prime (and in fact in most places in modern Windows) you can use a forward slash in place of a backslash for a path separator, e.g.,
a(1) = Dir$("SubFolder01/*.*")
And that is my preferred practice.
Hope this helps,
-- David McFarlane, Professional Faultfinder
|
|
|
|
|
Junior Member
      
Group: Forum Members
Last Login: 9/22/2008 9:54:26 AM
Posts: 16,
Visits: 69
|
|
| Morning Dave, Mmm, that never even crossed my mind! I gave it a go and... a(1) = Dir$("SubFolder01\\*.*") works, but a(1) = Dir$("SubFolder01/*.*") doesn't. Much thanks, J
...I'm an immortal...so far...
|
|
|
|