Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.filemaker > #796

Re: Delete a file on hard drive

From Christoph Kaufmann <clkaufmann@gmx.ch>
Newsgroups comp.databases.filemaker
Subject Re: Delete a file on hard drive
Date 2012-04-18 15:10 +0200
Organization CLK
Message-ID <t8fto75eduka47nbtm52sid9p50nuj6d87@4ax.com> (permalink)
References <1ki6rya.19sapswrzcg5gN%clkaufmann@gmx.ch> <e293$4f853479$535375e6$686@cache1.tilbu1.nb.home.nl>

Show all headers | View raw


[Windows only]
Problem: Delete a file referenced in a container field.

The script step Export Field Contents deletes the indicated file on
the hard drive if no field is specified. This may not work because the
field has been removed, renamed, or has become read-only for some
reason.

Ursus wrote:

> With both Win and OSx you could use scripting. But you would have to know 
> the file name and location. WinCMD is more complex, apple script I'm not 
> proficient...
> 
> Win (basic outline)

Worked at last; thanks agagin.
 
> create textfield, Mypath
> Make it set to "cmd dir /b " & path & name of file & " >> test.txt
> create script with Send Event ("aevt";"odoc";Mypath) Which is FileType 
> Unknown,Open document/application/calculation(mypath)
> It will create test.txt

I couldn't get it to work with this syntax. Here's what worked on my
XP system [1]:

cmd /c echo $content  > "$dosPath"

where $content is the contents of the file and $dosPath is the
complete path, starting with "C:\" or something, ending with the file
name.

> Import this into a temp table
> If file didn't exist it will say so

This one gave me a headache: if the test file was successfully
written, the script told me so and deleted it - but only when I
debugged the script. When running normally, the script successfully
wrote the file, but it seems the import failed.

After checking maybe eleven times with and without debug, I decided
the delay must have been critical - inserting a script pause of 3 sec
between file write and import did it, and it still works with a pause
of 0.05 sec (same machine, same volume; network might be different).

So we have a way to find out whether or not we're allowed to write
files in a directory. Weak points:
a) we assume if we can write we can delete. Probably true in almost
every case
b) We don't know wheter the file we want to delete is still there, and
its name
c) we don't know whether the file is open or write-protected

So if you're up to efficiency and fool prof solutions rather than
experimenting, Troi file migth be the better choice. Or an upgrade to
Filemaker 12 which appears to have some more functionality.

After all the time I've spent exploring this, I intend to use the
solution outlined by Ursus in in our Filemaker 10 solution until we
upgrade to Filemaker 13.

[1] influenced by
http://www.filemakertoday.com/com/entry.php/18-Creating-a-Folder-from-FileMaker-(Windows)
-- 
Viele GrĂ¼sse
Christoph Kaufmann
http://clk.ch

Back to comp.databases.filemaker | Previous | NextPrevious in thread | Find similar


Thread

Delete a file on hard drive clkaufmann@gmx.ch (Christoph Kaufmann) - 2012-04-07 15:09 +0200
  Re: Delete a file on hard drive "Ursus" <Ursus.kirk@gmail.com> - 2012-04-11 09:36 +0200
    Re: Delete a file on hard drive clkaufmann@gmx.ch (Christoph Kaufmann) - 2012-04-11 18:44 +0200
    Re: Delete a file on hard drive Christoph Kaufmann <clkaufmann@gmx.ch> - 2012-04-18 15:10 +0200

csiph-web