Within method and timer code in Flex operators, you can examine records in any of the input streams.
[ Symbol='T'; | Shares=10; Price=22.88; ]You might have another input stream called Earnings that contains recent earnings data, storing records:
[ Symbol='T'; Quarter="2008Q1"; | Value=10000000.00; ]In processing events from Earnings, you can look up the most recent Trades data using:
Trades := Trades_stream[Earnings];The record in the Trades stream that has the same key field Symbol. If there is no matching record in the Trades stream, the result is null.
Earnings := Earnings_stream{ [ Symbol = Trades.Symbol; | ] };The syntax here uses curly braces rather than square brackets because the meaning is different. The Trades event does not have enough fields to look up a value by key in the Earnings stream. In particular, it's missing the field called Quarter. The curly braces indicate "find any record in the Earnings stream whose Symbol field is the same as Trades.Symbol". If there is no matching record, the result is null.
for (earningsRec in Earnings_stream) { if ( (Trades.Symbol = Earnings.Symbol) and (Earnings.Value < 0) ) { negativeEarnings := 1; break; } }As with other for loops in SPLASH, the variable earningsRec is a new variable whose scope is the body of the loop. You can write this slightly more compactly:
for (earningsRec in Earnings_stream where Symbol=Trades.Symbol) { if (Earnings.Value < 0) { negativeEarnings := 1; break; } }This loops only over the records in the Earnings stream that have a Symbol field equal to Trades.Symbol. If you happen to list the key fields in the where section, the loop runs very efficiently. Otherwise, the where form is only nominally faster than the first form.
for (rec in Flex1) { ... }