Todd Posted September 30, 2003 Posted September 30, 2003 I'm perplexed by the action of one of my scripts and I can't figure out the problem. Here's what I've got: Set Error Capture (on) If [isEmpty(field2)] Copy [donor id FM] Perform external script End If If [not IsEmpty(field2)] show message (with choices for each of the 3 buttons) End If If [status(CurrentMessageChoice)=3] copy [donor id FM] Perform external script End If If [status(CurrentMessageChoice)=2] Copy [donor id FM2] perform external script End If ****Note that everything works just fine up until this point when I run this part only. Now the trouble starts when the script continues: If [status(CurrentMessageChoice)=1 Copy [donor id FM3] perform external script End If When I add in this last message choice, for some reason the script goes haywire and jumps back to the starting page where the script begins, instead of going to the page which is instructed in the external acript. What am I missing here? It's weird that it only happens when the 3rd choice is added on.
Ugo DI LUCA Posted September 30, 2003 Posted September 30, 2003 If you want your external script to stay in the related file, you should add a Refresh [ bring to front ] at the end of the external script. BTW, what exactly are you "Copying"
kenneth2k1 Posted September 30, 2003 Posted September 30, 2003 I'm not 100% sure of this (which means that I probably shouldn't speak ), but I think you will have to give the last control to the related db. For example the end if is the last step in the script, so it will go back to the main db. But Ugo is right - a refresh window or go to layout script in the related db can be called at the absolute end of your main script. Could someone verify? Ken
Fitch Posted September 30, 2003 Posted September 30, 2003 Your script needs to be structured this way to work properly: If [status(CurrentMessageChoice)=3] .. copy [donor id FM] .. Perform external script Else .. If [status(CurrentMessageChoice)=2] .. .. Copy [donor id FM2] .. .. perform external script .. Else .. .. Copy [donor id FM3] .. .. perform external script .. End If End If Also, if it happens to be the same external script, you can just put that step after the last If(), instead of putting it in there three times. Redundancy is bad bad bad. BTW, experienced developers tend to shun copy/paste wherever possible, because e.g. it requires you to go to a particular field-layout-file, and it blows away the clipboard which may annoy your users. Instead, consider using Set Field (related::global field, donor id) to move your data around.
kenneth2k1 Posted September 30, 2003 Posted September 30, 2003 Good points Fitch. I was going to mention the script structure, but I got lazy. Plus, I think that it should be more like this: If [this is true] do this else If [this is true] Show Message If [status(CurrentMessageChoice) = 1] do this and so on... end if end if ... as many end ifs as you need Perform script [external] - this would be the refresh window or go to layout script in the related db. But my scripts aren't the cleanest. But he said that it works (but does it really?? )
Todd Posted September 30, 2003 Author Posted September 30, 2003 As usual, Fitch nails it again. I just removed the redundant script commands (going to the external script in every If step) and now all is well. Thanks ever so much for your help. (By the way, I already had the Refresh Window built into the tail end of the external script and that didn't make a difference.) Now I have learned my redundancy lesson redundancy lesson.
Recommended Posts
This topic is 7728 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