Coding a relative path

Hi all,

Aplogies for such a noddy question. I've used search and haven't really found a useful answer.

I'm reviewing scripts from another source that have had absolute values coded i.e D:/eggplant/blah/blah.

I know these should be relative values to where the scripts are imported to so that when imported the helper scripts are located relative to the structure.

After messing around with ~ and ./ I still haven't found a solution.

So, with a folder structure of Eggplant/Utilities/abc.abc, how do I code so that as long as tester B has the same structure Eggplant will drill through relative to where the suite was opened from?

I'm rambling....I'll stop now,

Thanks in advance,

G

Comments

  • This is from the windows sensetalk manual, dunno if it helps as you seem to have already tried it, but apparently your right.

    I would suggest putting "the long name of me" into a variable and then working on that variable. "the long name of me" is the full path of the current file running. Then you can just work with that by deleting items by the delimited "\".

    Good luck!
    Tech Talk
    
    Syntax: 
    
    file filePath
    folder filePath
    directory filePath
    
    The filePath may be the text of a path in either Mac/Linux or Windows format, or it may be a list in which each item is one component of the path.
    
    The name given may be either the full (absolute) path name of the file or folder, or the path relative to the current working folder (see the folder global property below). SenseTalk determines the full “absolute” path name of the file based on the name given, according to the following rules:
    
    • if the name begins with a slash (/) or the first item in the path list is "/" it is already an absolute file name
    
    • if the name begins with a drive letter and colon followed by a slash (like "C:/") or the first item in the path list is a drive letter and colon and the second item is a slash it is already an absolute file name
    
    • if the name begins with a tilde and a slash (~/) it represents a path relative to the user’s home folder
    
    • if the name begins with a tilde (~) followed by a user name it represents a path relative to that specific user’s home folder
    
    • if the name begins with a period and a slash (./) or two periods and a slash (../) it represents a relative path from either the current working folder or the current working folder's parent folder, respectively
    
    • otherwise, it represents a file or path within the current working folder
    
  • So basically it would be like this...

    For example with your example...C:\Eggplant\Utilities\abc.abc
    put the long name of me into var
    
    log var ---shows you what the long name of me does (c:\Eggplant\Utilities\abc.abc) may have <SELECTION> after it...ignore it...
    
    delete the last 2 items delimited by "\" of var
    
    log var ----shows you the first 2 items "c:\Eggplant"
    

    I think you get the basics of it now...
  • EggplantMattEggplantMatt ForumAdmin admin
    If you're just looking at the Helper suites, then if you always set the Default Suite Directory to the folder containing your suites, you can just use the name of the suite, e.g., "HelperSuite1.suite". The paths in the Helpers tab are editable. This will also work for things like setting the InitialSuites.

    You set the Default Suite Directory in the General pane of the eggPlant Preferences. When running in CLI mode, you can set it using the "-DefaultDocumentDirectory" flag.
Sign In or Register to comment.