SaveTemp ( )

Function stats

Average user rating
57
212
9999
Support
FileMaker 9.0 +
Date posted
10 March 2009
Last updated
12 March 2009
Version
Recursive function
No

Author Info
 Andries Heylen

11 functions

Average Rating 4.9

author_avatar



 

Function overview

Prototype

SaveTemp  ( _filename )


Parameters

_filename  the filename with extension included


Description

Tags:  temp   fmtempfm   file  

FileMaker 9 added the possibility to save in a temporary folder, however this temporary folder is never emptied. In order to delete a file from the temporary folder, the filename should start with the following string: "FMTEMPFM".

That is exactly what this customfunction does, so you don't need to bother anymore. By using this customfunction for saving temporary files, you can be sure that it will be deleted the next time you startup FileMaker.

Examples

Sample input

SaveTemp ( test.pdf )


Sample output

filemac:/Macintosh HD/Users/.../FMTEMPFM_test.pdf

 

Function code

/* SaveTemp ( _fileName )
by Andries Heylen, BH&A

v.ß1 - Mar 2009

FileMaker 9 added the possibility to save in a temporary folder, however this temporary folder is never emptied. In order to delete a file from the temporary folder, the filename should start with the following string: "FMTEMPFM".

That is exactly what this customfunction does, so you don't need to bother anymore. By using this customfunction for saving temporary files, you can be sure that it will be deleted the next time you startup your computer.

*/

Case ( Abs ( Get ( SystemPlatform ) ) = 1 ; "filemac:" ; "filewin:") & Get ( TemporaryPath ) & "FMTEMPFM_" & _filename

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/212

    Prototype: SaveTemp( _filename )
    Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)
    Last updated: 12 March 2009
    Version: 2.0

*/
// ===================================

 

Comments

Fabrice
11 March 2009



Hi Andries,
didn't you forget to use the parameter in the function code?

maybe try to append "& _filename" ;-)
  General comment
Andries Heylen
12 March 2009



ok... you are right, this might be a better solution ;-)
  General comment
BruceR
13 March 2009



Are you sure about the need to do this? I just tested and none of this seems to be necessary. Scripted creation of a PDF in temp folder. Opened PDF file, viewed its parent folder. Quit FileMaker. Opened same file again, same export script, but modified file name. Again look at parent folder. The file from the first export did not exist. The temp folder can take care of itself I think.
  General comment
Andries Heylen
13 March 2009



Is this on a Mac or on Win?

I use Mac OSX and none of my files are deleted unless I prefix them with FMTEMPFM. I found this solution here:
http://sixfriedrice.com/wp/filemaker-9-tip4-temporary-files/

This issue should be solved with FM10
(Edited by Andries Heylen on 13/03/09 )
  General comment
BruceR
13 March 2009



OK, that was in 10. In 9, same script, check parent folder, oops lotsa junk there. So your routine is only needed for FM9.
  General comment
Genx
27 March 2009



Anyone know the difference between using platform specific filemac: and filewin: vs just file: ?
  General comment
Andries Heylen
20 March 2010



actually I always use just "file:" now... I don't know really where the difference is...
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)