How to generate the relative path in an import-paint-script?

Klaus Major klaus at major-k.de
Sat Feb 25 03:31:01 CST 2006


Hi Richard and all,

> Reinhold Venzl-Schubert wrote:
>> Hi!
>> When I import an image I select "Link Only" and "Set Directory" to  
>> generate the relative path of it and to reduce memory usage.
>> Now I wrote a button-script to import a picture:
>>  > import paint from file ImportBild <
>> How can I generate the relative path in my script?
>
> This raises a good question for all of us. Absolute paths are  
> absolutely abysmal for real-world work.
>
> Should we consider an option in the IDE for relative paths?
>
> The issue here is that currently paths are relative to the current  
> directory, but the current directly is subject to change from any  
> script so it's not universally reliable.
>
> I have a request for true absolute paths in BZ:
> <http://support.runrev.com/bugdatabase/show_bug.cgi?id=2490>
>
> In the meantime, should we consider some form of assistance for  
> this in the IDE?  If so, how should we approach it?  Or are we just  
> asking for trouble to attempt this before having it done right in  
> the engine?

We should ask Mark before we do this, since in 2.7 the engine will check
several folders before it claims that a stack was not found!
Maybe this will work for media, too?
Or could be changed/enhaced to also work for media?

 From the "What's new" file:

#############################
Stack Loading Overhaul
~~~~~~~~~~~~~~~~~~~~~~

The order of and places where stacks are searched for on the filing  
system has
been updated. Upon attempting to load a stack with filename  
<filename>, the engine
attempts to open files in the following order:
   1) Attempts to open a file <filename>
   3) Attempts to open a file <current_dir>/<leaf>
   4) Attempts to open a file <startup_dir>/<leaf>
   5) Attempts to open a file <engine_dir>/<leaf>
   6) Attempts to open a file <mc_path_i>/<leaf>
   7) Attempts to open a file <path_i>/<leaf>
   8) Attempts to open a file <home_dir>/<leaf>
   9) Attempts to open a file <home_dir>/stacks/<leaf>
   10) Attempts to open a file <home_dir>/components/<leaf>
Where
   <current_dir> is the current working directory (i.e. the value of
'the folder')
   <startup_dir> is the directory that was current at the time the
engine was started up
   <engine_dir> is the directory containing the engine executable
   <mc_path_i> is the i'th path present in the MCPATH environment  
variable
   <path_i> is the i'th path present in the PATH environment variable
   <home_dir> is the value of the HOME directory
If any paths depend on an environment variable that doesn't exist, that
step is skipped.
###########################

A plugin could do that.

I have a nice substack called "Einstein" in my "2lz3" plugin that  
takes care of that
for example. Work with absolute paths when developing and then let  
"Albert" do
his work before you build a standalone :-)

Check the script, it is insanely easy :-D

> Richard Gaskin
>  Fourth World Media Corporation
>  ___________________________________________________________
>  Ambassador at FourthWorld.com       http://www.FourthWorld.com

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de



More information about the metacard mailing list