Koonce Posted June 23, 2006 Posted June 23, 2006 I need to write a close script to find all the blank records and delete them upon closing, I wrote a script to find the blanks in a field but when the field is already blank it trys to delete the entire data base is there a way to do this. Thanks in advance. Randy
Fitch Posted June 23, 2006 Posted June 23, 2006 When you say "already blank" I presume you mean it's empty in all records. Doesn't the script give you an error dialog? You need to trap for errors. E.g. Set error capture[On] Find[...] If[Get ( FoundCount ) = 0] . Exit script // or whatever End If or... If [Get (LastError) <> 0] or... If [Get (LastError) = 401]
Koonce Posted June 23, 2006 Author Posted June 23, 2006 Ok so I did this script Set Error capture [on] Enter Find mode Restore perform find if Get(FoundCount)=0 Close File[Current File] end if if Get(FoundCount)>0 Delete All Records[no dialog] Close File[Current File] end if It cycle into a loop on exit and deletes records. What is going wrong??? Thanks
T-Square Posted June 23, 2006 Posted June 23, 2006 A couple of points: 1) The loop happens because you invoke Close File in the script, which is itself invoked by closing the file. I'm not certain, but you probably don't need to Close File in the script since it's already the action taking place. 2) You can simplify the script to: Set Error Capture[On] Perform Find[Restore] /* Note: I don't like using the Restore option in finds, since I can never get them to work; I always end up coding my finds using Set Fields... */ If[Get(FoundCount)] Delete All Record[No Dialog] End If You don't need to test for FoundCount=0 since all you're doing is closing the file, which as I noted above, is the action taking place anyway. HTH, David
Recommended Posts
This topic is 6730 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now