Newbies blue Posted August 20, 2002 Newbies Posted August 20, 2002 Is there a way to keep a script button from performing the script on all records? I have a script to insert text in one field based on the number contained in another field. There are often exceptions that I change manually. When I add new records and run the script, it overrides changes I've made to previous records. Is there a way to stop this, or do I need to always run the script in found sets? hope this makes sense! thanks
CobaltSky Posted August 20, 2002 Posted August 20, 2002 Hello blue, Most script steps, by default, only apply to the current record, and a Loop / End Loop sequence must be included in order to have them work through all found records. There are a few exceptions to this, such as the Replace script step, which is designed specifically to apply to the whole found set. In all probability, the script you are using has a looping procedure which makes it apply to the whole found set. If this is the case, you may wish to consider making a copy of the script and deleting the Loop and loop-related steps, so that you will have a 'Current record only' version of the script (I'm assuming that you will want to keep the original for those occasions when updating all found records might be appropriate). Similarly, if the problem is a 'Replace' command within the script, you may simply delete that step from the copy of the script (leaving the Paste or Set Field or other associated steps.
Newbies blue Posted August 20, 2002 Author Newbies Posted August 20, 2002 wow that was fast! There is a loop integrating a sub-script into the end of the existing script. Sounds like I'm going to have to re-edit the two scripts into one. thanks
CobaltSky Posted August 20, 2002 Posted August 20, 2002 Hi Blue, From what you say, it is likely that the sub-script is doing the update to the curent record, and the loop is then managing the application of the update to all the found records. If you simply call the sub-script directly, rather than the 'loop' script, it sounds as though it might do what you want without any editing. Give it a try and see?! Cheers,
Newbies blue Posted August 20, 2002 Author Newbies Posted August 20, 2002 I'm not sure I understand what you mean by "call the sub-script directly". Although I wanted to avoid boring you all with a long and convoluted description, it may help get a final answer to what is or is not possible. The database is basically a form for creating labels for motion picture film cans. The layout designed is for a single can label and the script duplicates the proper number of records depending on the number of cans per title (anywhere from 1 to 15) There may be a more sophisticated way to accomplish this but I have just set up a series of if/duplicate record/paste literal steps (if the last can = 6, it duplicates 5 more records and numbers them consecutively 1 through 6) The sub-script then has to run over that span of 6 records inputting the proper reel number on each can. The reel numbers do not match the can numbers because they are not consecutive but in A/B configurations (can 1 = reel ONE-A, can 2 = reel ONE-B, can 3 = reel TWO-A, can 4 = reel TWO-B
CobaltSky Posted August 21, 2002 Posted August 21, 2002 Hi Blue, What I meant by 'call the sub-script directly' was to attach the sub script to your button (in place of the looping script), or to set it to show on the Scripts menu and select it from there. However, in light of your more detailed explanation, it seems that the loop may still be required - in order to make incremented changes to multiple iterations of a record for a single motion picture, so calling the sub-script may therefore not be appropriate. If I understand correctly, you are needing to apply a change not to the current record, but to it and all its fellow 'reel/can label iterations' present in the database. If this is the case, then the most straightforward solution may be to include some additional steps (prior to the loop in your script) which perform a 'find' to locate the group of records for the current motion picture. Then the looping procedure will only apply to the records for one movie. A Show all Records step at the end of the script (if appropriate) will then reinstate the full data set. If you will need the script to return the user to a batch of records that was being worked with (rather than using Show all Records), you may need to introduce a tag field which can be set from within the script (using the Replace command) prior to the Find steps at the start of the script. The tag field can then be used at the end of the script (as the target of another Find step) to re-group the starting found set (and the tag field should then be cleared using another Replace command) before the script ends and returns the user to the labels list.
BobWeaver Posted August 23, 2002 Posted August 23, 2002 To avoid running the script on old records, you can have a field called OldRecord. When you create a new record, this field will be blank. So your script can check this field to make sure it's empty before doing anything to the record. Or, you can do a Find for all records where the OldRecord field is empty, and only process those records. As you process each record, set OldField to some value (such as the current date) so that it won't be processed again the next time you run the script.
Newbies blue Posted August 26, 2002 Author Newbies Posted August 26, 2002 thanks bob and ray I'm still working out a few other complications but you've given me some great options!
Recommended Posts
This topic is 8202 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