There have been a lot of checkins this week (at least, compared to the
two previous weeks). Allow me to explain those changes that I'm
responsible for. (I also explain what changes you'll need to make to
the glue scripts, if you build Frontier or Radio from source.)
My checkins addressed four areas:
* string.patternMatch()
* clock.milliseconds()
* the script profiler
* math verbs
string.patternMatch now takes an optional third parameter, ix, to tell
Frontier where to start searching. This makes it possible to use
string.patternMatch to "walk" all the way through a string. (Just keep
setting the starting point to one more than the last match.)
Update your glue script at string.patternMatch so that the first line
says, "on patternMatch (pattern, s, ix = 1)".
clock.milliseconds() returns a timer value in thousandths of a second.
clock.ticks() was plenty fast enough back in the day, but these days
Frontier can do a few hundre operations in a single tick, so any
timing based on a tick is quite inaccurate.
Frankly, milliseconds isn't good enough either. Even on my decrepit
old G4/450, many verbs and operators run in less than a millisecond.
Andre and I both want microseconds (millionths), and in fact the
native timers this is based on all use microseconds, but for now this
is what we have.
The script profiler now uses milliseconds internally, instead of
ticks. By default, it converts the results to ticks just before
returning the profile results table, but you can request milliseconds
when you call script.stopProfile by passing an optional second
argument, flUseMilliseconds, like this:
script.startProfile( true )
... run some script here, to be profiled ...
script.stopProfile( adrResults, true )
You'll need to update the glue script at script.stopProfile. The first
line should now say: "on stopProfile (adrTable, flUseMilliseconds =
false)"
Finally, there's the new math group. There are currently only three
verbs, but more are planned (I'd like to see a math group similar to
Math in other languages like JavaScript, Java, c, etc.).
math.min (a, b)
- returns the lesser of two values
- more than a math verb, can compare anything
that can be compared with a less than symbol,
including strings
- usage:
math.min( 5, 7 )
>> 5
- replacement for this:
if ( a < b )
return a
else
return b
math.max (a, b)
- returns the greater of two values
- more than a math verb, can compare anything
that can be compared with a greather than symbol,
including strings
- usage:
math.max( 5, 7 )
>> 7
- replacement for this:
if ( a > b )
return a
else
return b
math.sqrt (n)
- returns the square root of n
- result is always a double
The glue scripts for the math verbs are attached to this email. I'll
also upload them to the files section on Yahoo.
Seth