Home > Community > Forums > Custom IC SKILL > Get current script directory

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: *

 Get current script directory  

Last post Tue, Oct 21 2008 1:07 AM by useratcad. 2 replies.
Started by useratcad 20 Oct 2008 03:37 AM. Topic has 2 replies and 2343 views
Page 1 of 1 (3 items)
Sort Posts:
  • Mon, Oct 20 2008 3:37 AM

    • useratcad
    • Not Ranked
    • Joined on Thu, Oct 16 2008
    • Posts 15
    • Points 195
    Get current script directory Reply

    Hello,

    I need to find the current dir of the loaded skill file to automatically load the other files in the folder.

    I found that  "get_filename(piport)" will return the skript name, but not the dir.

    How could I do that? 

     

    Thanks Tim 

    • Post Points: 20
  • Mon, Oct 20 2008 10:46 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,587
    • Points 15,915
    Re: Get current script directory Reply

    Hi Tim,

    Using your idea of get_filename(piport), I have expanded it a little to obtain the root of the directory name.

    This seems a little clunky, and I have only tested it under a couple of conditions, but it seemed to work:

    when(file = get_filename(piport)
     ;; expand the file using the SKILL path
     matches = foreach(mapcar path getSkillPath()
      when(isFile(strcat(path "/" file ))
       simplifyFilename(strcat(path "/" file ))
      )
     )
     full = car(setof(item matches item))
     when(full
      ;; convert the path into a list of strings
      ;; and remove the filename from the list
      path = remd(file parseString(full "/"))
      ;; convert the list of strings back into a
      ;; single string, prepending with "/" for a
      ;; fully qualified path
      root = strcat("/" buildString(path "/"))
      ;; print and return the file directory root
      printf("root dirname: %s\n" root)
      root
     )
    )

    • Post Points: 20
  • Tue, Oct 21 2008 1:07 AM

    • useratcad
    • Not Ranked
    • Joined on Thu, Oct 16 2008
    • Posts 15
    • Points 195
    Re: Get current script directory Reply

    Awesome. I modified it a little and it works perfect. Thanks for your help! 

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by useratcad at 20 Oct 2008 03:37 AM. Topic has 2 replies.