[Tutor] sound implementation problems

Alan Gauld alan.gauld at btinternet.com
Fri Jun 14 02:19:25 CEST 2013


On 13/06/13 18:56, Jim Mooney wrote:

> tripped me up. If you're using an IDE or editor, mine has the
> unfortunate habit of loading in its own directory, and having no option
> to automatically access files from my  program directory. It saves a
> program into the last used directory,

This is a function of the IDE application itself

 > but looks for sounds in its own directory.

And this is a function of the interpreter that the IDE is using to 
execute your code. The IDE has no direct control over that. It's 
important when using an IDE to appreciate the bits of your workflow that 
are being done by the IDE code and the bits being done by the 
interpreter that the IDE uses to execute your code.

> So use the Full Path to your sound file, and avoid that possible
> problem.

This is good practice in any program you write. Either derive the full 
path or set the working directory prior to accessing the files. Full 
paths are ultimately the only sure way.

> I have a startup script that now stays in my program directory,
> though. Of course, if you have an IDE or editor that lets you set the
> default directory that's no problem.

That's a dodgy way to solve the problem since if you change IDE or run 
the program outside the IDE that startup script will likely get 
forgotten and not be used. Remember you are not expected to use
an IDE for anything other than developing the code, its not
intended to be a runtime environment. Relying on the IDE is
a bad habit to develop.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list