
Re: Is it possible to process too fast for some scripts?
It's been my experience that a properly written script is not vulnerable to pacing (speed and latency) issues. But it's also been my experience that a lot of scripts aren't written perfectly. I would say that in almost every case where there's a problem (as in it worked before or works sometimes), it's because the script used setTextTrigger instead of setTextLineTrigger, or a text trigger was set without a waitOn before it to ensure other processing has occurred.
So let me elaborate. Let's say you want to grab the density manually from a density scan. You might do something like:
Code:
setTextTrigger densityTrigger :getDensity "Sector"
send "sd"
pause
:getDensity
getWord CURRENTLINE $density 4
Remember that a line from a density scan looks something like:
Sector 792 ==> 100 Warps : 2 NavHaz : 0% Anom : No
So no problem, it looks good right? FAIL - It turns out that this code actually suffers from both of the problems that I mentioned. Since this is a text trigger, the only thing that you can be sure of is that the triggering text "Sector" has been seen. So CURRENTLINE could be "Sector 792 ==>", or maybe just "Sector". How then can you grab the 4th word using getWord? Instead, you should have used setTextLineTrigger, which ensures the entire line after the triggering text is captured. A setTextLineTrigger is kinda like a 2-part trigger: it begins firing when the text is seen, and ends when the carriage return is seen, so CURRENTLINE returns the entire line. And a faster CPU or slower connection will really bring these triggering missteps to light.
But wait, there's a second problem with that code snippet. If you were to change the send text to "dsd", it will end up triggering on the Sector display rather than the density scan since the triggering text "Sector" will be seen at the wrong time. So here the key is to limit when the trigger can fire to a point just before the desired text is displayed. I like to use a waitOn for text that is consistently displayed just before the text I'm interested in, and never seen otherwise. So in this case, the optimal way to write it would be as follows:
Code:
send "sd"
waitOn "Relative Density Scan"
setTextLineTrigger densityTrigger :getDensity "Sector"
pause
:getDensity
getWord CURRENTLINE $density 4
So here the waitOn prevents the
TEXTLINE trigger from becoming active until the last possible moment, and you can be sure CURRENTLINE will be complete when it fires.
So let me give you script writers 2 cardinal rules for triggers:
1. Strive to waitOn unique text before your trigger, then set your trigger.
2. Use textline triggers unless you can't. (And if you don't know, you should ask why you sometimes can't.)
+EP+