×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

ADIR in VFP7

ADIR in VFP7

ADIR in VFP7

(OP)
Fox Pro 7 help states that I can get the volume label if I include V.  I've tried this and it doesn't seem to work.

Has anyone out there been able to make it work?  
If so how?


Thanks!
CJ

RE: ADIR in VFP7

Hi
=ADIR(myarray,"c:","V")
? myArray(1,1)
This gives the volume label for C:
It works correctly.
If the Volume Label is absent, a blank will appear.
Hope this helps you

ramani
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK

RE: ADIR in VFP7

(OP)
HI!

VFP help shows this (which doesn't work):
CLOSE DATABASES
SET DEFAULT TO (HOME(2) + 'Data')
gnDbcnumber = ADIR(gaDatabase, '*.DBC', "V")  && Create array
CLEAR
FOR nCount = 1 TO gnDbcnumber  && Loop for number of databases
   ? gaDatabase(nCount,1)  && Display database names
ENDFOR
SET PATH TO HOME( )  && Set path to Visual FoxPro directory

So all I have to do is:

=ADIR(myarray,"c:","V")
? myArray(1,1)

I wonder why Help can't be helpful.

THANKS very much!  I'll try what you have suggested.

:)


RE: ADIR in VFP7

The help file for once is very clear about this. It says that if you include the "V" attribute, the volume name is stored in the first array element, and the rest of the array is truncated. In other words, when you changed the help file's example code by adding the "V" attribute, you changed the entire functioning of the ADIR() function. In the example, it is designed to generate a list of available DBCs; your modification changed that to simply return a single element array. I don't understand why you would need a volume label when iterating through a list of database files, anyway.

-- Ed

RE: ADIR in VFP7

(OP)
Ed,

Sorry to come off rude, BUT:

Did you try it?
You must not be a new user.  I am.  The help file isn't helpful - they assume to much.  

D S H all work.  BUT the V didn't.   

What make you so sure I'm collecting a list of Databases?  There is more then one use for the ADIR function.

When I tried it here VFP7 didn't like the command.

I need the Volume ID, directory name and filenames.  Most of which I was able to make work.   

I'm trying to get around using the DOS dir save to a text file then import function.

Ramani has given me a good pointer, which I will try.

:)

RE: ADIR in VFP7

(OP)
Ramani,

I hope you get this.

THANK YOU FOR YOUR HELP!!!

CJ
:)

RE: ADIR in VFP7

> Sorry to come off rude, BUT:
> Did you try it?

        No, you're not coming off rude. And yes, I did try it.

> You must not be a new user.  I am.  The help
> file isn't helpful - they assume to much.
> D S H all work.  BUT the V didn't.

        I tried it many times, and I always got the same result: a single-element array. If the drive had a volume label, its value was in the array. If it didn't, the array element was an empty string.

> What make you so sure I'm collecting a list of Databases?
> There is more then one use for the ADIR function.

 Well, you gave the example from the Help file, which illustrated iterating through a list of databases. When you said that it didn't work, I assumed that you had tried to run that code.

> When I tried it here VFP7 didn't like the command.

 Can you explain in more detail what VFP 7 did when you issued that command? That would help determine where the problem is.

> I need the Volume ID, directory name and filenames.  
> Most of which I was able to make work.

 Getting the Volume Name (I'm not sure if that's the same as the Volume ID you need) is a separate task. You cannot get the Volume info and file/directory info in a single command.

> I'm trying to get around using the DOS dir save to
> a text file then import function.

 If you explain what you need to do in plain (i.e., not Fox) terms, perhaps we can come up with a solution. One thing you'll find with VFP is that there are usually at least 3 ways to do everything!

-- Ed

RE: ADIR in VFP7

(OP)
Hello Ed!

This is what I had originally when I was trying this:

SET DEFAULT TO (HOME(2) + 'Data')
gnDbcnumber = ADIR(gaDatabase, '*.DBC', "V")  && Create array
CLEAR
FOR nCount = 1 TO gnDbcnumber  && Loop for number of databases
   ? gaDatabase(nCount,1)  && Display database names
ENDFOR
SET PATH TO HOME( )  && Set path to Visual FoxPro directory

This of course didn't work, but this is what help was telling me to do.  I don't exactly remember the error, but it didn't like the syntax I think.  Which didn't make since because if I substituted a "D" it worked.

Then I tried what Ramani suggested:

SET DEFAULT TO (HOME(2) + 'Data')
gnDbcnumber = ADIR(myarray,"c:","V")

CLEAR
FOR nCount = 1 TO gnDbcnumber && Loop for number of files
? myArray(1,1)
ENDFOR

This works. (The was much rejoicing!)

Of course, I now have to make a few change.  Like I did to collect the list of files.

I wish that the ADIR function had all the features of the DOS DIR function.



:)

RE: ADIR in VFP7

ufffffffffffff.... sorry....

Hi CJ,

All you have to do... is issue the following command to get the volume name of drive c:
****************************************************
=ADIR(myarray,"c:","V")
? myArray(1,1)
****************************************************
You dont have to code .. all what you have done...
In fact, in your above myArray there is only one element and there is no need to issue FOR ... endfor loop

ramani
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK

RE: ADIR in VFP7

(OP)
Ramani,

Ever thought of thought of putting together a downloadable book of specific examples?  

You are very helpful.

Thanks, I'll remove the Loop.


:)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close