Since there's no Get ( ActiveRecordNumber ), you probably have to use an OnRecordEnter trigger to set a $$, and use an expression like $$activeRecordNumber ≠ Get ( RecordNumber ).
It would be a little bit better to use the primary key from the record instead of record number, which can change for a particular record without triggering the OnRecordLoad trigger (with a Sort for example).
If you want this to work across different layouts and still use a single script, you can code the layout name (or ID) into the variable name.
[…] which can change for a particular record without triggering the OnRecordLoad trigger
Correct, I didn't have that scenario on my radar.