Is there a way to seach for a file from within E3D / Pml ?
I know there is the syscom 'start dir abc.txt' command, but it doesn't return a value as to whether it was found or not. It's all external.
Is there a way to seach for a file from within E3D / Pml ?
I know there is the syscom 'start dir abc.txt' command, but it doesn't return a value as to whether it was found or not. It's all external.
There is some functionality by using the file object and it's various methods, however it is quite limited
It only looks for the file in the directory provided and doesn't appear to search in sub-directories :
!v1 = object file('c:\temp\abc.txt')
!v2 = !v1.exists()
unlike below which would search all sub-directories and find all copies of files named as such :
syscom 'start dir c:\temp.abc.txt /s'
You can do something like this. 1000000 is picked to be larger than the possible count of all subdirs
!f = object file('c:\temp\NetGridAddinControl.cs')
if not !f.exists() then
!dir = !f.directory()
!subdirs = object array()
!subdirs.appendarray(!dir.subdirs())
do !i to 1000000
if !i gt !subdirs.size() then
$p not found
break
endif
!dir = !subdirs[!i]
!ff = object file(!dir.fullname() + '\' + !f.entry())
if !ff.exists() then
$p found:
q var !ff.fullname()
break
endif
!subdirs.appendarray(!dir.subdirs())
enddo
endif
found:
<STRING> 'c:\temp\Samples\NetGridExample\NetGridAddinControl.cs'
Thanks for that.
I did something very similar, using the file object and methods like subdirs() and files() and managed to get my desired result.