absolute vs relative file paths

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jthurs51
Posts: 4
Joined: Fri Jan 26, 2007 8:14 am

absolute vs relative file paths

Post by jthurs51 » Fri Feb 02, 2007 1:30 am

On page 25 of the userguide it refers to a section on "File Name Specifications and File Paths" and something called relative file paths. I can't find the section though :(

Can someone please explain how to and when to use the different file path types? I seem to be having a very difficult time getting relative filepaths to work. For example, I think relative refers to where the Revolution media is located, so if I have a folder named "myStuff" containing "myMov.mov" in the "Revolution Media" folder, how do I refer to it? the movie file?

Thanks for reading,

-JT

oliverk
Site Admin
Site Admin
Posts: 53
Joined: Mon Feb 27, 2006 2:16 pm
Location: Edinburgh

Post by oliverk » Fri Feb 02, 2007 11:46 am

Hi JT,

An absolute file path is something that points from the root of the system to the file / folder in question. Examples are:

Windows:
C:/Documents and Settings/myUserName/My Documents/program.rev

Mac:
/Users/myUserName/Documents/program.rev

Linux:
/home/myUserName/program.rev

An absolute path always points to that file, regardless of the the current directory or where your program is saved.

A relative path is simply a partial path to a file or folder, it is said to be "relative" because in order to get the actual (absolute) path, to the file / folder, you need to know the rest of the path (what it is "relative" to).

Examples are:

Windows, Mac or Linux:
Documents/program.rev

Relative paths are useful becuase the thing that the path is relative to can change. For example if you have a file in the same folder as your program, the relative path to that file is simply the name of the file eg

myFile.rev

Or if the file is in a folder called "Documents" which is in the same folder as your program:

Documents/myFile.rev

This is a good use of relative paths because it means you can move your program, and as long as the file is moved to the same place, ie relative to your program its still in the same place, you don't need to change any code.

With regards to your file myMov.mov, could you explain exactly where it is located? If you give me the absolute path of the file, and the absolute path of your stack / program I can explain how to use a relative path to access the file.

Hope this is some help.

Regards

Oliver
Oliver Kenyon
Software Developer
Runtime Revolution

jthurs51
Posts: 4
Joined: Fri Jan 26, 2007 8:14 am

Post by jthurs51 » Fri Feb 02, 2007 5:51 pm

oliverk wrote: With regards to your file myMov.mov, could you explain exactly where it is located?
I sure can. On Mac OS X 10.3

/Applications/Revolution Media/mystuff/myMov.mov

Thanks!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”