Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hello

 

I've got a script which saves a PDF to the user's desktop. Or at least that's what i want it to do.

 

Does anyone know if there's a standard output file path which will save it to the desktop of whoever happens to be using the script? The users in this case happen to be using PCs. Not sure if that makes a difference, versus Macs.

 

Thanks.

 

Philip

 

 

 

 

Posted

I've been using this and so far it works everywhere:
 

Set Variable [ $filepath ;
Let (
[ $sysPlat = Abs ( Get ( SystemPlatform ) )
; $plat = case ( $sysPlat = 2 ; "filewin:"
; $sysPlat = 1 ; "filemac:"
; $sysPlat = 3 ; ""
; "file:"
) // 1 = mac, 2 = win, 3 = iOS
; $imgPlat = substitute ( $plat ; "file" ; "image" )
; $desktop = Get ( DesktopPath )
; $documents = if ( $sysPlat = 3 ; "" ; Get ( DocumentsPath ) )
; $temp = Get ( TemporaryPath )
; $fm = Get ( FileMakerPath )
; $file = "literal" & table::field & "literal" // changeable
; $ext = ".pdf" // can be .txt, .xls, .xml, .htm, etc.
/* iOS specific */
; $WriteGo = $plat & $documents & $file & $ext
; $ReadGo = "file:" & $documents & $file & $ext
/* results that seem to work most of the time */
]; $plat & $documents & $file & $ext
// or $plat & $temp & $file & $ext
// or $imgPlat & $desktop & $file & $ext
)
]
/* WRITE path */
// windows = "filewin:" & Get ( DocumentsPath ) & nameOfFile
// mac = "filemac:" & Get ( DocumentsPath ) & nameOfFile
// ios = "nameOfFile"
/* READ path */
// windows = same
// mac = same
// ios = "file:" & Get ( DocumentsPath ) & nameOfFile

* It's xplat, so you don't need to change the calc!
* Remember that reading/writing with FMGo is slightly different.
* The path for images is "image" not "file" (look at the dialogs when choosing the path for examples).
* You don't need to use variables ($), but I like to follow in the Data Viewer for debugging and if in the same script, I can change the $filepath to any of the variables in the final step before calling in the dialog.
* You don't need to separate the extension - include as part of the file name ($file), but sometimes I need it to be that way.

Posted

Hi Bev,

 

I must be doing something wrong, If I paste your calc into the calculation box, I get an error

 

)
]  Here, it wants an operator.
/* WRITE path */
// windows = "filewin:" & Get ( DocumentsPath ) & nameOfFile
// mac = "filemac:" & Get ( DocumentsPath ) & nameOfFile
// ios = "nameOfFile"
/* READ path */
// windows = same
// mac = same
// ios = "file:" & Get ( DocumentsPath ) & nameOfFile

 

Lee

Posted

Hi Beverley and Doughemi

 

Thanks for your replies. Beverley, your suggestion fills me with awe but is beyond my capabilities, I'm afraid!

 

Doughemi, your suggestion looks to be within my grasp, but can you advise on how I'd actually use the Get(DesktopPath) function. All I'm trying to do is drop a file in a Container field onto the user's desktop. So my script is simply:

 

Export field Contents [Filename::Containerfieldname;'Container1']

 

and I wan to specify the Output File Option attached to that line. Is it as simple as me specifying Get(DesktopPath) as the output file or a bit more complicated than that?

 

Thank you.

 

Philip

Posted
Set Variable [$path; Value:Get ( DesktopPath ) & "DesiredFileName"]
Export Field Contents [ Filename::Containerfieldname; "$path"]
Posted

Lee, that's the comments I added to the post. sorry, not really in the calc.... :)

 

the final "]"is what gets output when you print the script step. i.e. is the end of the step, not the calc.

Posted

I thought that would be the case, I just wanted to be sure I was getting it right and that it would be clear to the novice. Thanks for sharing.

 

Lee

Posted

Doughemi, Beverley and Lee

 

Thank you so much. Worked a treat!

 

It's a fantastically generous thing you do on this forum. It can be quite stressful trying to work out solutions and then you post an enquiry on here and - Bingo! - people who know what they're doing take their time to help out.

 

Thanks again.

This topic is 3864 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
×
×
  • Create New...

Important Information

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