Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 4th, 2010, 08:32 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Relative File Paths

Hi there,

I'm wondering if FusionPro allows the use of relative file paths so that I don't have to hard-code them.

At the moment all my resources have to be placed inside the same folder as my template file which I'd like to avoid. What I'd like to do is have a folder within my template's parent folder titled 'Resources'. In my code I would reference it something like '~/Resources/' where the ~ will be the path to the parent folder of my template file.

Ideally my folder structure would be something like...

TEMPLATE FOLDER (Parent Folder)
INPUT (Child of TEMPLATE FOLDER)
OUTPUT (Child of TEMPLATE FOLDER)
RESOURCES (Child of TEMPLATE FOLDER)

All my resources would be places in the RESOURCES folder and all output files would appear in the OUTPUT folder.

It seems though that I have to either set the Search Path (through Compose > Advanced) or hard code the FULL file path. Both of these options mean I have to determine a static path rather than a dynamic one.

Essentially I'd like to replace "C:\\Folder 1\\Folder 2\\Template Folder\\" with something like PathToMe which would return the path to the FusionPro template file.

I hope it's clear what I'm trying to achieve.

Many thanks,

Juergen
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #2  
Old April 5th, 2010, 06:28 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

I typically keep my FP template in the parent folder and have a child folder for my resources. I create a relative path in that scenario as a JavaScript Global variable that I can reference in my various rules.

Regardless of where you choose to put your template file, relative paths should work for you as well (i.e. "..\\RESOURCES\\").
Reply With Quote
  #3  
Old April 5th, 2010, 07:20 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Hi Eric,

Thanks for the reply.

I've just tried adding a relative folder path to JavaScript Globals
Code:
gOutputFolder = "..\\OUTPUT\\";
and in the OnNewOutputFile Callback rule I have the following code...

Code:
if (!FusionPro.Composition.isPreview)
    {
        fileName = (FormatDate(Today(), "ddMM ") + productNames[ProductID]);
        FusionPro.Composition.outputFileFullPathName = gOutputFolder + fileName;
    }
(Ignore the 'productNames[ProductID]' part - it's simply referencing an array to construct the filename)

If I compose, the file is saved at the root level of the hard drive?! I've checked to make sure that a folder titled OUTPUT exists in the template's parent folder so don't understand why the file is being saved where it is.

This is the sort of behaviour that prompted me to post on the forum as I'd exhausted all the possibilities I could think of!

Any clues?

Thanks,

Juerg
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #4  
Old April 5th, 2010, 07:28 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Just a thought - do you think it matters that I'm testing this on a Mac? The template will ultimately be used on a PC but I often do the programming at home on a Mac...
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #5  
Old April 5th, 2010, 08:06 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Very weird! Just noticed that the file is being saved in the FusionPro application folder!!! I've attached a screenshot...

Juerg
Attached Images
File Type: jpg Pic001.jpg (140.9 KB, 21 views)
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #6  
Old April 5th, 2010, 09:18 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

The mac does use a different separator for path names. I didn't realize you were on a Mac based on your signature. In my globals, the rule I use is:
Code:
var gOutputFolder = (FusionPro.isMac) ? "..::OUTPUT:" : "..\\OUTPUT\\";
Reply With Quote
  #7  
Old April 5th, 2010, 09:31 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

I assumed that FP used standard delimiters in file paths. Curious why it doesn't?!

Anyway, I'm now getting the attached error!

Seems I'm destined to be chasing my tail on this one!
Attached Images
File Type: jpg Pic003.jpg (17.9 KB, 8 views)
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #8  
Old April 5th, 2010, 10:04 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

Your latest JPEG only shows one colon preceding the OUTPUT folder although I don't know if that alone is the issue. What happens if you place the template in the parent folder and change the output path to "::OUTPUT:"?
Reply With Quote
  #9  
Old April 5th, 2010, 10:37 AM
jurgmay jurgmay is offline
Regular Contributor
 
Join Date: Aug 2009
Location: Bristol, UK
Posts: 53
Default Re: Relative File Paths

Hi Eric,

I get the same error message, it just shows to colons instead of one. I changed it because I assumed it was incorrect when it first threw the error.

At the moment I have a folder called FIC. Within this folder is my template file along with all associated files .cfg, .def, .dif etc. as well as all the graphic resources. Finally I have a folder titled OUTPUT which I'm trying to put my output file in.

Does this sound like the correct structure?

Thanks for your help so far - much appreciated!

Juerg
__________________
FusionPro Desktop 6.2P1a Windows XP & Mac OS X 10.6 (Snow Leopard)
Reply With Quote
  #10  
Old April 5th, 2010, 10:53 AM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Relative File Paths

I see nothing wrong with your file structure. Will the structure (or the relative location) change once the template is being used on the PC?

Here is where I posted my own solution for a similar problem which is why I'm somewhat baffled that your scenario is proving harder to solve.

Of course, I have never used this information in conjunction with an output file name; only for pulling in resources. I wonder of an absolute path is required by the outputFileFullPathName object?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:32 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.