![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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) |
#4
| |||
| |||
|
|
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 |
)
#5
| |||
| |||
|
|
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) |
#6
| |||
| |||
|
|
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 |

![]() |
| Thread Tools | |
| Display Modes | |
| |