Jump to content

Folder Path Problem


 Share

This topic is 3995 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I am trying to save a PDF to a user selected folder using the ScriptMaster Choose Folder but seem to run an issue if the volume name is not included.

ScriptMaster Choose Folder returns:

/Users/myUser/Desktop

Trying to save a PDF using the ScriptMaster supplied path to generate a $pathVariable = filemac:/Users/myUser/Desktop/myfile.pdf generates an error 800 "Can't write file".

To test my pdf path process I tried using FileMaker Get(DesktopPath) which returns:

/Volume/Users/myUser/Desktop/

Save a PDF using the this path to generate a $pathVariable = filemac:/Volume/Users/myUser/Desktop/myfile.pdf works fine.

Is it just the missing volume from the path that is causing the error and how do I get the volume using ScriptMaster?

So far I am working on a Mac but will need to run on Windows as well so I don't know if drive letters will be an issue.

Link to comment
Share on other sites

THe "Specify Output File" dialog box specifies what format each output needs to be on each platform that you're working on. The mac formatat requites "filemac:/volumeName" before the directory (which might be /Volumes/myExernalDrive if you're not working on your main drive or /MainHDD or /Volumes/MainHDD if it's your main drive as examples) and the windows path requires filewin:/driveletter:/. Scriptmaster returns the driveletter on windows, but not the filewin:/ and only the path on mac, not the volume or filemac:/.

Link to comment
Share on other sites

Just discovered this one myself. Basically the Mac path is root relative and begins /Users/.....

You could generate a $$var using GetDesktopPath, and keep the text upto the second "/" - thus your "volume" prefix

In fairness it's not 360Works fault - what I read suggests it is a Java/Groovy limitation that is rooted in a "root" directory structure.

Link to comment
Share on other sites

The user could select a local or remote volume so I don't think I can rely on the getdesktoppath to extrapolate the required volume.

Looking at external volumes I think I have a general workaround by starting the Mac user at the top level Volumes folder they can select an external volume and drill down to their home folder and I think it will pick up the full path.

Link to comment
Share on other sites

  • 11 months later...

The user could select a local or remote volume so I don't think I can rely on the getdesktoppath to extrapolate the required volume.

Looking at external volumes I think I have a general workaround by starting the Mac user at the top level Volumes folder they can select an external volume and drill down to their home folder and I think it will pick up the full path.

Why can't you use $$Volume=get(SystemDrive) ?

Worked for me.

Link to comment
Share on other sites

THe "Specify Output File" dialog box specifies what format each output needs to be on each platform that you're working on. The mac formatat requites "filemac:/volumeName" before the directory (which might be /Volumes/myExernalDrive if you're not working on your main drive or /MainHDD or /Volumes/MainHDD if it's your main drive as examples) and the windows path requires filewin:/driveletter:/. Scriptmaster returns the driveletter on windows, but not the filewin:/ and only the path on mac, not the volume or filemac:/.

I got the Mac version to work (by using get(systemDrive)).

But, the Win version produces this 'found file path':

post-72145-0-95321100-1329973844_thumb.j

Of course this doesn't work. So, I have to ask "normal Windows path separator is "\" The above mentioned Specify File Type shows a path example with "filewin:/driveletter:/directoryName/filename --- or "/".

What am I supposed to believe; Win or FM? Can you comment on what is wrong with the above path?

Thank you

Link to comment
Share on other sites

Ron

Either use a java/groovy function to get the path or a custom function to clean the path you get from FM - you can't really expect to mix both as they are not the saem

In my script, I use 360Works File Select() function to get the file and it's path. (see above screen capture). File Select() is a Groovy function.

The 'weird' thing is that concatenating get(systemDrive) in front of the path puts /C:/ in front of the path.

Link to comment
Share on other sites

Its not wierd at all

You are mixing two things

Java returns paths in one way, and Filemaker in another.

Then you are adding the front of a penguin to the back of a horse and wondering why it is not an eagle.

http://www.briandunning.com/cf/517

This custom function will convert your path FROM FM to Java, THEN you can add them together

Only I think you want to do it the other way round.

Link to comment
Share on other sites

Its not wierd at all

You are mixing two things

Java returns paths in one way, and Filemaker in another.

Then you are adding the front of a penguin to the back of a horse and wondering why it is not an eagle.

http://www.briandunning.com/cf/517

This custom function will convert your path FROM FM to Java, THEN you can add them together

Only I think you want to do it the other way round.

Thanks for the link. I am going to try and reverse the function.

But, what I am finding is that FM in it's substitute and replace functions DOES NOT like the "\" text string and produces a modal error dialog.

I suspect that the briandunning function will also reject "\"....

Latest efforts on my part have been:

Use 360works select file() to grab the path and file.

post-72145-0-82215600-1330038018_thumb.j

Copy that path to the clipboard.

Paste it into the 'Specify File' dialog... and it still didn't work..... grrrr r(^#@$&^@*

workpost-72145-0-98825400-1330037990_thumb.j

I surely can't be the first Windows user to encounter this problem? But, there is a real shortage of information

on this or any other board to solve it or shed much 'light'.

Ron

Link to comment
Share on other sites

I just downloaded the BDunning function mentioned above.

It will *not* accept a reverse substitution of "/" for "" . And there is no other function even close to doing the Windows to Mac path address that FM requires.

Plus I can't use FM substitute command -- it errors out. The 360Works people, only help on beginning level and need to be paid for 'custom work' (I am doing this for non-profit and we don't have the $$$ ; which is why "I" am doing it instead of one of you. :laugh2: Plus hard coding doesn't work. I am wondering "Is this possible?" What do all the Windows folks do when they want to input a selected file path to Import?????

Link to comment
Share on other sites

There should be no major difficulty involved in making paths work cross platform.

FileMaker paths always use forward slash as a directory separator, whether on Mac or Windows.

In an OS-level script, and in a ScriptMaster Java path, the directory separator is forward slash on Mac and backward slash on Windows.

Since the backward slash is also an escape character in FileMaker calculations, I often find it easier to work with Char ( 92 ) or a custom function using that formula, rather then typing an actual backward slash in the formula.

Maybe it would be easier to assist you if you could make a sample file including your script available.

Link to comment
Share on other sites

Custom function

Its not difficult.

Its not a ScriptMaster issue

The idea is almost certainly from someone else but I haven't attributed it. Sorry

/**

* osfmPath( path )

* 11_11_18 JR

* v1.0

*

* input: path = (string) O/S name of the file/folder location

* return: (string) an FM cleaned version of an O/S path

*

*/



Let ( [

_platform = Case (

Abs ( Get ( SystemPlatform ) ) = 1 /*SysIsMAC*/ ; "mac" ;

Abs ( Get ( SystemPlatform ) ) = 2 /*SysIsWIN*/ ; "win" )

;

_start = Case (

_platform = "mac" ; "filemac:/" ;

_platform = "win" ; "filewin:/" )

;

_path = Case (

_platform = "mac" ; Substitute ( path ; "/Volumes/" ; "" ) ;

_platform = "win" ; Substitute ( path ; "" ; "/") )

] ;

_start & _path

)

Link to comment
Share on other sites

Thanks for the code. It looks interesting (admittedly I don't, on first glance see where the path conversion takes place.)

This is what I came up with:

post-72145-0-88177900-1330153869_thumb.j

I can't seem to get it to understand any volume/Drive other than the startup drive (C:). I don't know what that is about.

If someone has any ideas, I would surely like to hear them.

Thanks

Ron

Link to comment
Share on other sites

Nope, just not getting your issue.

I downloaded a virgin copy of Scriptmaster and ran the Script

It returns <W:pixcols3.jpg> for a file on one of my mapped network drives (I work in FM more than 50% of the time on PC)

On the dialog box for file import or export it says Examples - fullpath filewin:/driveletter:/directoryName/fileName

So on WIndows

$filePath = "filewin:/" & Substitute ( $resultFromSMfunction ; "" ; "/" )




You seem to be using network paths though, so this will return <A9a6 projectslog4.CSV>



Examples - fullpath filewin://computerName/shareName/directoryName/fileName



in which case 
$filePath = "filewin:/" & Substitute ( "$resultFromSMfunction ; ["" ; "/"] ;["" ; "/"] )

The answer from this is filewin://A9/a6 projects/log4.CSV

There's not much information because its not that difficult.

Link to comment
Share on other sites

Custom function

Its not difficult.

Its not a ScriptMaster issue

The idea is almost certainly from someone else but I haven't attributed it. Sorry

/**

* osfmPath( path )

* 11_11_18 JR

* v1.0

*

* input: path = (string) O/S name of the file/folder location

* return: (string) an FM cleaned version of an O/S path

*

*/



Let ( [

_platform = Case (

Abs ( Get ( SystemPlatform ) ) = 1 /*SysIsMAC*/ ; "mac" ;

Abs ( Get ( SystemPlatform ) ) = 2 /*SysIsWIN*/ ; "win" )

;

_start = Case (

_platform = "mac" ; "filemac:/" ;

_platform = "win" ; "filewin:/" )

;

_path = Case (

_platform = "mac" ; Substitute ( path ; "/Volumes/" ; "" ) ;

_platform = "win" ; Substitute ( path ; "" ; "/") )

] ;

_start & _path

)

I created this script which is quite beautiful in it's simplicity.

However, it seems to 'pre suppose' that the file path is known.

Because I want the user to be able to select a file and then have FM create the file path and name, it seems like this would be a great solution AFTER the selection.

Or, am I missing something?

Ron

Link to comment
Share on other sites

Tool 'A' will give you the temperature in Farenheit

Tool 'B' will convert Farenheit to Centigrade

Someone asks you for the temperature, but needs it in Centigrade

What do you do?

1: Say that you can't do it with the tool you have for reading temperature

or

2: Use tool 'A', then take what that tells you and THEN use tool 'B' with the answer from tool 'A' as an input

I think all the parts are in the previous posts.

Link to comment
Share on other sites

This topic is 3995 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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