How to implement isClassdef(filespec), isFunction(filespec) and isScript(filespec)?
이전 댓글 표시
I'm trying to implement
isClassdef(filespec)
isFunction(filespec)
isScript(filespec)
which take full filespecs as input and return true/false. I think that the code exists in Matlab because it's used to sort the files in "Current Folder", but I failed to find it.
The function, exist fails me for classes, which are defined in @-folders. It returns 2, whereas I expected 8.
>> which tree
h:\m\FEX\InUse\TreeDataStructure\@tree\tree.m % tree constructor
>> exist( 'tree' )
ans =
2
>> meta.class.fromName('tree')
ans =
class with properties:
Name: 'tree'
...
I try to avoid to read the files and search for key-words.
What's the best way?
댓글 수: 5
Jan
2016년 11월 20일
How could you distinguish functions from scripts without reading the files and checking, if the first keyword is not "function"?
Steven Lord
2016년 11월 20일
How would you use such functions if they existed? Why do you need to differentiate between script, function, and class files?
per isakson
2016년 11월 21일
편집: per isakson
2016년 11월 21일
Walter Roberson
2016년 11월 21일
Can .p files be classdef files? Hmmm, I guess they could be, but it does sound odd.
per isakson
2016년 11월 21일
편집: per isakson
2016년 11월 21일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!