Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List of Files 1

Status
Not open for further replies.

dddenney

Programmer
Nov 29, 2000
41
US
Does anyone know of a function or api call that will not return the list of files in all Upper Case? We have tried Sys(2000), ADIR(), DIR, and LIST FILES, and all of them return the file names in uppercase. It is imperative that we are able to return the filenames in their proper case.

Thanks,

Dan
 
You can do something like:

!DIR > FileList.txt

Then create a cursor or table to import the files.

Dave S.
 
Tried that already. For some reason, the list becomes capitalized if run through FoxPro. Also long filenames end up getting truncated with the ~1. It doesn't do this however if DIR is run from the command line. Any ideas?
 
I guess you could deal with it this way:
Code:
CLOSE DATABASES
SET DEFAULT TO (HOME(2) + 'Data')

nlineNumber = ADIR(myArray)  && Create array

FOR nCount = 1 TO nLineNumber 
   STORE myArray(nCount,1) TO myVar
   myVar = PROPER(myVar)
   STORE myVar TO myArray(nCount,1)
ENDFOR
 
What OS are you using? I don't have a test bed of different OS'a but Win 2000 preserves the original case when using the !DIR (note the '!') command.

mgagnon - That would work if the user actually entered the filename PROPER. But if they used something like aBcDe.txt, it wouldn't.

Dave S.
 
Actually, I had to change the FoxRun.PIF to use CMD.EXE instead of COMMAND.COM. Now I can use the ! DIR to get the list of files in a given directory, that will be case sensitive and give the full filename for long filenames. For some reason if your FoxRun.pif is set to COMMAND.COM it will truncate and give everything in upper case.

Dan
 
Well, slap my forehead. I had forgotten I had canged mine about six months ago. I guess that makes a difference. [dazed]

Dave S.
 
Now when I distribute the executable, do I just include the FoxRun.PIF in the Project or do I need to include it in the Setup program?

Dan
 
Well, it depends on your OS. CMD.EXE is for Win 2000. I'm not sure what Win ME uses, but '95 & '98 use COMMAND.COM. Keep in mind that this whole scenario doesn't work with those. You will probably have to get into API calls for earlier versions of OS.

Go to for some real good examples.

Dave S.
 
DSummZZZ


mgagnon - That would work if the user actually entered the filename PROPER. But if they used something like aBcDe.txt, it wouldn't.


????
Local myVar
myVar = "aBcDe.txt"
myVar = PROPER(myVar)
? myVar

Sorry I beg to differ...

 
Ummm..., potayto/potahto.
The key word being proper, as opposed to PROPER().
PROPER() does return the string in 'proper' case as defined by VFP or common grammar, but if you want the string returned with the letters in the proper case that they were created as opposed to improper, i.e. upper when it should be lower, or lower when it should be upper, then PROPER() doesn't apply:

Local myVar
myVar = "aBcDe.txt"
? myVar &&... displays aBcDe.txt
myVar = PROPER(myVar)
? myVar &&... displays Abdce.txt

Dave S.
 
If you use WSH (Windows Script Host), you can use this Tip I got from Anders Altberg on the UT:

*:* Show Filenames with case preserved [vs. ADIR()]
As filenames are case-insensitive in Windows and NT, all file formats, upper case is as correct as lower or whatever. You can use the FileSystemObject to get the names as Explorer shows them.

path = "C:/mydata/"
ofs = create('scripting.filesystemobject')
nn = ADIR(arr,path+"*.*")
FOR ii = 1 TO nn
? ofs.getfile(path+arr[ii,1]).name
NEXT

Rick
 
Thanks Rick. That does just fine. It's nice not having the DOS window open up everytime we need to run it.

Thanks to everyone for their help.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top