⎕nparts : file or directory ?
4 posts
• Page 1 of 1
⎕nparts : file or directory ?
Dear All,
with ⎕nparts, i am in trouble.
i use dropfile event to catch path.
with a text file with extension :
with the same text file without extension :
no soucy.
the path to my work directory is C:\Users\user\Desktop\hazel\
and ⎕nexists said only if file exist or not.
am i wrong ?
how can i test if it is a file or directory ?
Regards,
Yves
with ⎕nparts, i am in trouble.
i use dropfile event to catch path.
with a text file with extension :
⎕nparts chn
┌→────────────────────────────────────────────┐
│ ┌→───────────────────────────┐ ┌→──┐ ┌→───┐ │
│ │C:\Users\user\Desktop\hazel\│ │nut│ │.txt│ │
│ └────────────────────────────┘ └───┘ └────┘ │
└∊────────────────────────────────────────────┘
with the same text file without extension :
⎕nparts chn
┌→─────────────────────────────────────────┐
│ ┌→───────────────────────────┐ ┌→──┐ ┌⊖┐ │
│ │C:\Users\user\Desktop\hazel\│ │nut│ │ │ │
│ └────────────────────────────┘ └───┘ └─┘ │
└∊─────────────────────────────────────────┘
no soucy.
the path to my work directory is C:\Users\user\Desktop\hazel\
⎕nparts chnthe cut is not really in the good place.
┌→─────────────────────────────────────┐
│ ┌→─────────────────────┐ ┌→────┐ ┌⊖┐ │
│ │C:\Users\user\Desktop\│ │hazel│ │ │ │
│ └──────────────────────┘ └─────┘ └─┘ │
└∊─────────────────────────────────────┘
and ⎕nexists said only if file exist or not.
am i wrong ?
how can i test if it is a file or directory ?
Regards,
Yves
- Yves
- Posts: 39
- Joined: Mon Nov 30, 2015 11:33 am
Re: ⎕nparts : file or directory ?
Interesting, my []nparts (version 17) works nicely:
..but instead of it I'd recommend using []ninfo (1=directory, 2=file):
-Veli-Matti
⎕nparts 'd:\users\user\desktop\hazel\nut.txt'
┌────────────────────────────┬───┬────┐
│d:\users\user\desktop\hazel\│nut│.txt│
└────────────────────────────┴───┴────┘
⎕nparts 'd:\users\user\desktop\hazel\nut'
┌────────────────────────────┬───┬┐
│d:\users\user\desktop\hazel\│nut││
└────────────────────────────┴───┴┘
⎕nparts 'd:\users\user\desktop\hazel\'
┌────────────────────────────┬┬┐
│d:\users\user\desktop\hazel\│││
└────────────────────────────┴┴┘
..but instead of it I'd recommend using []ninfo (1=directory, 2=file):
1 ⎕ninfo'd:\users\user\desktop\hazel\nut.txt'
2
1 ⎕ninfo'd:\users\user\desktop\hazel\nut'
2
1 ⎕ninfo'd:\users\user\desktop\hazel\'
1
1 ⎕ninfo'd:\users\user\desktop\hazel'
1
-Veli-Matti
- Veli-Matti
- Posts: 94
- Joined: Sat Nov 28, 2009 3:12 pm
Re: ⎕nparts : file or directory ?
Thanks Veli-Matti :)
i am under Dyalog APL/W-64 Version 17.0.33947 and ⎕nparts is unchanged :(
of course, and thank you, i use ⎕info to complete my function.
i am under Dyalog APL/W-64 Version 17.0.33947 and ⎕nparts is unchanged :(
of course, and thank you, i use ⎕info to complete my function.
- Yves
- Posts: 39
- Joined: Mon Nov 30, 2015 11:33 am
Re: ⎕nparts : file or directory ?
⎕NPARTS is working as intended.
For any name ⎕NPARTS returns
So:
Even with a left argument of 1, ⎕NPARTS does not check for the existence of the object or not:
Note that on Windows the ".." can be resolved so you would see '/home/i/do/' in the first element.
I agree that the documentation needs some changes .. the word "file" is misleading in some places; I have raised an issue requesting that the documentation is made more precise.
For any name ⎕NPARTS returns
- the directory in which the name resides
the name stripped of any path and any extension
the extension (if any)
So:
⎕nparts '../i/do/not.exist'
┌────────┬───┬──────┐
│../i/do/│not│.exist│
└────────┴───┴──────┘
Even with a left argument of 1, ⎕NPARTS does not check for the existence of the object or not:
1 ⎕nparts'../i/do/not.exist'
┌────────────────────┬───┬──────┐
│/home/andys/../i/do/│not│.exist│
└────────────────────┴───┴──────┘
Note that on Windows the ".." can be resolved so you would see '/home/i/do/' in the first element.
I agree that the documentation needs some changes .. the word "file" is misleading in some places; I have raised an issue requesting that the documentation is made more precise.
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group