Home > Community > Forums > PCB SKILL > Check if File exists in SKILL

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Check if File exists in SKILL 

Last post Mon, Jul 7 2014 5:58 AM by fxffxf. 6 replies.
Started by BinduSripad 02 Jul 2014 03:52 AM. Topic has 6 replies and 868 views
Page 1 of 1 (7 items)
Sort Posts:
  • Wed, Jul 2 2014 3:52 AM

    Check if File exists in SKILL Reply

    Hi,

     

    I am trying to check if a given file exists in one of the directories listed in the parent of parent of current directory (2 levels up)

    Code:

     isFileName(ruleFile list("..." ) )

    This doesnt seem to be correct.

     

    Could you please suggest a solution for the same. Is there an alternate to varying the SKILL Path?

     

    Thanks,

    Bindu 

     

    • Post Points: 20
  • Wed, Jul 2 2014 8:59 AM

    • Randy R
    • Top 50 Contributor
    • Joined on Wed, Jul 16 2008
    • Dupont, WA
    • Posts 192
    • Points 3,025
    Re: Check if File exists in SKILL Reply

    See if this works for you.  Just replace filename.txt with your filename.

    isFileName("filename.txt" "..\\..\\") 

    Good Day, R².
    • Post Points: 20
  • Wed, Jul 2 2014 10:44 AM

    Re: Check if File exists in SKILL Reply

    Hi Randy,

     

    Thanks for the suggestion!

    But it is not working as expected.

    In general, how is a file searched in multiple/hierarchy of directories in SKILL?

     

    Thanks,

    Bindu 

    • Post Points: 20
  • Wed, Jul 2 2014 6:34 PM

    • Aldrin
    • Not Ranked
    • Joined on Tue, Dec 4 2012
    • Posts 10
    • Points 210
    Re: Check if File exists in SKILL Reply

    The suggestion by Randy R actually works. Alternatively,if you have defined path to search.. you can use the isFile(filepath) command.

     

    For file multiple file searching, you may use getDirFiles then loop.

     

    • Post Points: 5
  • Wed, Jul 2 2014 6:36 PM

    • Aldrin
    • Not Ranked
    • Joined on Tue, Dec 4 2012
    • Posts 10
    • Points 210
    Re: Check if File exists in SKILL Reply

     *For multiple directory/hierarchy searching, you may use getDirFIles then loop on the result.

    • Post Points: 20
  • Thu, Jul 3 2014 11:32 PM

    Re: Check if File exists in SKILL Reply

    Hi All,

     

    This works :

    ;;  you can change the directory depth based on requirement

    _fileList = getDirFiles("../../../")

    if( exists(_file _fileList (stringp _file)) 

    then       

         _checkFile = "True"

    else

    printf("\nFile %s not found!" _file)

    );if 

     

    Thanks for the helpful pointers!!

    Bindu 

    • Post Points: 20
  • Mon, Jul 7 2014 5:58 AM

    • fxffxf
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • ., AK
    • Posts 296
    • Points 4,710
    Re: Check if File exists in SKILL Reply

    You may want to try axlDMFindFile which ignores the skillPath variable. For examle to find a file up 2 levels do

    sprintf(buf "../../%s"   ruleFile)

    result = axlDMFindFile("MISC" buf "r")

    if result is nil then file does not exist.

    It is also best to use UNIX style directory delimiters  ( "/") instead of Windows style ("\") since you don't need escape the UNIX version.

    In general, getDirFiles should be avoided if performance will be an issue.

    • Post Points: 5
Page 1 of 1 (7 items)
Sort Posts:
Started by BinduSripad at 02 Jul 2014 03:52 AM. Topic has 6 replies.