Jump to content
Sign in to follow this  
innodat

Windows vs. Mac File Path

Recommended Posts

Hi Guys,

this is probably an easy one for someone who knows windows... I can't figure it out and would appreciate a tip.

My database has a scripted Excel export function. I've chosen to name the files Excel_11807.xls, and collect them in a designated directory "Lasting Record Data/Excel Export". I'm using the Get(FileMakerPath) function to locate the directory, as it is located in the same folder as my runtime solution (or FileMaker application for the time being).

On the Mac, the following calculation works flawlessly:

Substitute (

Get(FileMakerPath) & "Excel" & (Substitute (Get(CurrentDate); "/"; "")) & ".xls" ;

"Excel" & Substitute (Get(CurrentDate); "/"; "") & ".xls" ;

"Lasting Record Data/Excel Expor/t" & "Excel" & Substitute (Get(CurrentDate); "/"; "") & ".xls"

)

However, in my windows test-environment (WIN XP, SR3) it returns: "Excel_11807.xls could not be created. Use a different name..."

How do I need to change the path for it to work in a windows environment??

Thank you so much for your input!

Share this post


Link to post
Share on other sites

I am surprised this works at all as your target filename does not have a prefix that FM needs to determine the platform and protocol.

file: is relative

filemac: is mac absolute

filewin: is windows absolute

Should work if you just prefix with "file:"

If not then maybe the file already exists and is locked, or the directory does not exist.

Incidentally, where did the underscore come from in the Windows message as it's not in your calculation.

Share this post


Link to post
Share on other sites

It seems you've got a lot of extra Substituting in the calculation. Also, my preference is to create a sortable date stamp for file names in folders, yearmonthday, padding the month and day. I think an absolute path prefix is best, as those FileMaker path functions return absolute paths (they would have to on client machines).

I would also prefer to use the Documents folder, Get ( DocumentsPath ). Exported documents don't belong in the application folder, IMHO.

Let ( [

prfx = Case ( Abs ( Get ( SystemPlatform)) = 1; "filemac:"; "filewin:" );

yr = Year ( Get ( CurrentDate ));

m = Right ( "0" & Month ( Get ( CurrentDate )); 2);

d = Right ( "0" & Day ( Get ( CurrentDate )); 2)

];

prfx & Get(DocumentsPath) & "Lasting Record Data/Excel Export/Excel_" & yr & m & d & ".xls"

)

Share this post


Link to post
Share on other sites

Hey Fenton and IdealData!

Thank you so much for your input - it works like a charm. I've been reading in another post, "It's always the obvious in the end..." - I guess that goes for this one too.

Funny that my mac file paths always worked without the filemac: prefix...

Fenton, the reason I've placed the document folder in the runtime application folder is because A) I don't have an installer app to place things automatically in different spots, :) the users are really computer illiterate - I thought it would make their lives easier.

Cheers,

Michael

Share this post


Link to post
Share on other sites

Ah yes, Runtime returns its own app path. That is fine. A local FileMaker file can also return its own path.

Share this post


Link to post
Share on other sites

Sorry to reopen this thread, but i can't get it to work:

i've made this script:

Set Variable [ $percorsoDesktop; Value:Get ( PercorsoDesktop ) ] 

Save record as PDF [ filename: “filewin:$percorsoDesktop”; Create e-mail; current record ] 



but every time i launch it, i have the error message n.800 "unable to write to disk...."

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.