Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6730 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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]

Posted

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

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.