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

Klaus Major klaus at major-k.de
Mon Feb 27 07:08:54 CST 2006


Hello again :-)

> Hello Klaus!
> Am 25.02.2006 um 19:00 schrieb metacard-request at lists.runrev.com:
>
>> "relative" always means "relative to the current folder = the  
>> directory"
>> So if "the directory" is something like:
>>
>> Win
>> C:/Folder1/subfolder2/the current project
>> resp. Mac
>> /Volumes/harddisk 1/Folder1/subfolder2/the current project
>> and in this folder you have you folder with your images.
>> Absolute path:
>>
>> Win
>> C:/Folder1/ subfolder2 /the current project/the images
>> resp. Mac
>> /Volumes/harddisk 1/Folder1/subfolder2/the current project/the images
>>
>> You can simply script:
>> ...
>> import paint from file "the images/name of image.jpg"
>> ...
>>
>> Or do you mean to set the filename like the "importer" stack does?
>>
>> In that case:
>> ...
>> set the filename of img "whatsoever" to "the images/name of  
>> image.jpg"
>> ...
>>
>> That's it :-)
>>
>> Hope that helps.
>
>
> I tried vainly what you wrote.
> Here is my script. I hope you can find the mistake:
>
> on mouseUp
>   answer file "Please select an image:"
>   put it into ImportPicture
>
>   if ImportPicture is empty then
>     answer "You did not select an image."
>     exit mouseup
>   end if
>
>   set the itemDel to "/"
>   get the effective filename of stack "Testloader"
>
>   put it into MediaFolder
>   delete last item of MediaFolder
>   put "/Media" after MediaFolder
>
>   put item -1 of Importpicture into ImpPict
## ImpPict = the FILENAME of the selected image e.g. userimage.jpg
>   put url ("binfile:" & ImportPicture) into url ("binfile:" &  
> MediaFolder & "/" & ImpPict)
> ## Now the image is in the Media-Folder
>
> ## 1. advice with tree vain trails:
>
>   import paint from file "MediaFolder/ImpPict"
>   import paint from file "Media/ImpPict"
>   import paint from file (Media & "/" & ImpPict)
## No such files!!!

##Try this instead:

##impPct is a string, so you have to concatenate the correct string  
first!
   import paint from file ("Media/" & ImpPict)

>  ## 2. advice
>
>   import paint from file Importpicture
##Should work fine since this holds the absolute path now :-)

>   set the filename of img ImpPict to ("Media/" & ImpPict)
## This will only work if you really have an image named
## like the string in the variable -> ImpPict  e.g. userimage.jpg !!!

> end mouseUp
>
> In the stack-script I put this:
>
> on preopenstack
>   get the effective filename of this stack
>   set the itemdel to "/"
>   delete last item of it
>   set the directory to it
>   start using "libURL"
> end preopenstack
>
>
> perplexed
> Reinhold

Hope that helps and de-plexes you a bit :-)


Regards

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



More information about the metacard mailing list