Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Output file paths - is there a standard one for PCs

Featured Replies

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

 

 

 

 

Use the Get(DesktopPath) function

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.

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

  • Author

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

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

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.

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

  • Author

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.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.