dbTalk Databases Forums  

Check for File

comp.databases.filemaker comp.databases.filemaker


Discuss Check for File in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jc@agncs.com
 
Posts: n/a

Default Check for File - 02-23-2007 , 12:53 PM






Using FM 7.0, I have a script that checks for a file on the "c"
drive. if the file is there it deletes the current set of records and
imports the new records in the file.

How can I make the script "stop" or "exit" if the file is not on the
"c" drive where it won't continue on and delete the current set of
records

thanks


Reply With Quote
  #2  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Check for File - 02-23-2007 , 04:44 PM






In article <1172256789.792773.290840 (AT) 8g2000cwh (DOT) googlegroups.com>,
jc (AT) agncs (DOT) com wrote:

Quote:
Using FM 7.0, I have a script that checks for a file on the "c"
drive. if the file is there it deletes the current set of records and
imports the new records in the file.

How can I make the script "stop" or "exit" if the file is not on the
"c" drive where it won't continue on and delete the current set of
records
I don't know how you're checking for the file, but the basic script
would be something like:

If [{file exists check returns "Yes"}]
Delete Records
Import
Else
{do whatever when file does not exist}
End If

Or, if there is nothing to do when the file doesn't exist you can leave
out the "Else" bit completely.
eg.
If [{file exists check returns "Yes"}]
Delete Records
Import
End If


Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #3  
Old   
jc@agncs.com
 
Posts: n/a

Default Re: Check for File - 02-24-2007 , 08:47 AM



On Feb 23, 5:44 pm, Helpful Harry <helpful_ha... (AT) nom (DOT) de.plume.com>
wrote:
Quote:
In article <1172256789.792773.290... (AT) 8g2000cwh (DOT) googlegroups.com>,

j... (AT) agncs (DOT) com wrote:
Using FM 7.0, I have a script that checks for a file on the "c"
drive. if the file is there it deletes the current set of records and
imports the new records in the file.

How can I make the script "stop" or "exit" if the file is not on the
"c" drive where it won't continue on and delete the current set of
records

I don't know how you're checking for the file, but the basic script
would be something like:

If [{file exists check returns "Yes"}]
Delete Records
Import
Else
{do whatever when file does not exist}
End If

Or, if there is nothing to do when the file doesn't exist you can leave
out the "Else" bit completely.
eg.
If [{file exists check returns "Yes"}]
Delete Records
Import
End If

Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)
Harry:

That is my problem. How do I "check" to see if the file is actually
on there. How would you write a script in FM7 to see if the file
exist?

Thanks



Reply With Quote
  #4  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Check for File - 02-24-2007 , 07:20 PM



In article <1172328422.394264.131760 (AT) 8g2000cwh (DOT) googlegroups.com>,
jc (AT) agncs (DOT) com wrote:

Quote:
On Feb 23, 5:44 pm, Helpful Harry <helpful_ha... (AT) nom (DOT) de.plume.com
wrote:
In article <1172256789.792773.290... (AT) 8g2000cwh (DOT) googlegroups.com>,

j... (AT) agncs (DOT) com wrote:
Using FM 7.0, I have a script that checks for a file on the "c"
drive. if the file is there it deletes the current set of records and
imports the new records in the file.

How can I make the script "stop" or "exit" if the file is not on the
"c" drive where it won't continue on and delete the current set of
records

I don't know how you're checking for the file, but the basic script
would be something like:

If [{file exists check returns "Yes"}]
Delete Records
Import
Else
{do whatever when file does not exist}
End If

Or, if there is nothing to do when the file doesn't exist you can leave
out the "Else" bit completely.
eg.
If [{file exists check returns "Yes"}]
Delete Records
Import
End If

Harry:

That is my problem. How do I "check" to see if the file is actually
on there. How would you write a script in FM7 to see if the file
exist?

Thanks
Ahh, OK. When you said you had a script I thought you meant that. )

You can't specifically check to see if a file exists in standard
FileMaker. You can possibly create a kludgey work-around using the
Error Capture commands, but really you would need a "file routines"
plug-in of some sort. There is a free one I know about for older
versions of FileMaker, but it hasn't been updated for newer versions.

Luckily you may not need it for what you're trying to do.

If you're replacing ALL the records in the current database with the
newly imported ones then you can use a script that tries to import the
records and if there is no error it deletes the old records. Since a
successful Import command leaves you with a Found Set of just the newly
imported records, you can swap that with the "unfound" / omitted
records and then delete the (now) Found Set.

A script something like:

Set Error Capture [On]
Import Records [Restore, No Dialog, "ImportFile"]
Set Field [g_ErrorCode, Get(CurrentError)]
If [g_ErrorCode = 0]
Show Omitted
Delete Records [No Dialog]
Else
If [g_ErrorCode = 100]
Beep
Show Message ["File does not exist.]
Else
Beep
Show Message ["A different error has occurred."]
End If
End If

where g_ErrorCode is a new Global field used to store the error code
returned by the Import command.

Error Codes: 0 = No error
100 = File Missing

NOTE: Since this is a script that deletes records, you MUST run it
on either an test file or a backup - do NOT run it on a file
that contains important records until you're sure it works
how you want it to.

Because ithe script uses the Restore option for the Import command, you
will first need to perform a manual import so that you can set the
order that the fields' data will be imported.

The error checking occurs only AFTER the Import command, so the Import
process itself cannot be aborted - that means some new records might
have been imported if, for example, the import file is corrupted and
ends unexpectedly.


Now, if you are not wanting to replace ALL the records, but want to
instead replace just the Found Set, then it gets a little trickier. You
would first need to set a "flag" field in all the Found Set records,
then try importing from the file. If no error is return you then reFind
the "flagged" records and delete them, if an error is returned then you
would need to "unflag" the records again ready for next time you try
the import (which may mean reFinding them first).




Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #5  
Old   
jc@agncs.com
 
Posts: n/a

Default Re: Check for File - 02-24-2007 , 08:40 PM



On Feb 24, 8:20 pm, Helpful Harry <helpful_ha... (AT) nom (DOT) de.plume.com>
wrote:
Quote:
In article <1172328422.394264.131... (AT) 8g2000cwh (DOT) googlegroups.com>,



j... (AT) agncs (DOT) com wrote:
On Feb 23, 5:44 pm, Helpful Harry <helpful_ha... (AT) nom (DOT) de.plume.com
wrote:
In article <1172256789.792773.290... (AT) 8g2000cwh (DOT) googlegroups.com>,

j... (AT) agncs (DOT) com wrote:
Using FM 7.0, I have a script that checks for a file on the "c"
drive. if the file is there it deletes the current set of records and
imports the new records in the file.

How can I make the script "stop" or "exit" if the file is not on the
"c" drive where it won't continue on and delete the current set of
records

I don't know how you're checking for the file, but the basic script
would be something like:

If [{file exists check returns "Yes"}]
Delete Records
Import
Else
{do whatever when file does not exist}
End If

Or, if there is nothing to do when the file doesn't exist you can leave
out the "Else" bit completely.
eg.
If [{file exists check returns "Yes"}]
Delete Records
Import
End If

Harry:

That is my problem. How do I "check" to see if the file is actually
on there. How would you write a script in FM7 to see if the file
exist?

Thanks

Ahh, OK. When you said you had a script I thought you meant that. )

You can't specifically check to see if a file exists in standard
FileMaker. You can possibly create a kludgey work-around using the
Error Capture commands, but really you would need a "file routines"
plug-in of some sort. There is a free one I know about for older
versions of FileMaker, but it hasn't been updated for newer versions.

Luckily you may not need it for what you're trying to do.

If you're replacing ALL the records in the current database with the
newly imported ones then you can use a script that tries to import the
records and if there is no error it deletes the old records. Since a
successful Import command leaves you with a Found Set of just the newly
imported records, you can swap that with the "unfound" / omitted
records and then delete the (now) Found Set.

A script something like:

Set Error Capture [On]
Import Records [Restore, No Dialog, "ImportFile"]
Set Field [g_ErrorCode, Get(CurrentError)]
If [g_ErrorCode = 0]
Show Omitted
Delete Records [No Dialog]
Else
If [g_ErrorCode = 100]
Beep
Show Message ["File does not exist.]
Else
Beep
Show Message ["A different error has occurred."]
End If
End If

where g_ErrorCode is a new Global field used to store the error code
returned by the Import command.

Error Codes: 0 = No error
100 = File Missing

NOTE: Since this is a script that deletes records, you MUST run it
on either an test file or a backup - do NOT run it on a file
that contains important records until you're sure it works
how you want it to.

Because ithe script uses the Restore option for the Import command, you
will first need to perform a manual import so that you can set the
order that the fields' data will be imported.

The error checking occurs only AFTER the Import command, so the Import
process itself cannot be aborted - that means some new records might
have been imported if, for example, the import file is corrupted and
ends unexpectedly.

Now, if you are not wanting to replace ALL the records, but want to
instead replace just the Found Set, then it gets a little trickier. You
would first need to set a "flag" field in all the Found Set records,
then try importing from the file. If no error is return you then reFind
the "flagged" records and delete them, if an error is returned then you
would need to "unflag" the records again ready for next time you try
the import (which may mean reFinding them first).

Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)
Thank you Harry for all you do for me and others!!



Reply With Quote
  #6  
Old   
ADempsey
 
Posts: n/a

Default Re: Check for File - 03-05-2007 , 11:09 AM



On 23 Feb, 18:53, j... (AT) agncs (DOT) com wrote:
Quote:
Using FM 7.0, I have a script that checks for a file on the "c"
drive. if the file is there it deletes the current set of records and
imports the new records in the file.

How can I make the script "stop" or "exit" if the file is not on the
"c" drive where it won't continue on and delete the current set of
records

thanks
Not sure if you still need it, but I have just released a free
FileMaker 7+ plugin which contains a function to check for the
existance of a file. It's called MooPlug and can be freely downloaded
from http://mooplug.com



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.