BeforeIterate-macro
Sets the active layer in the active window to 1.
Def BeforeIterate {Layer -S 1};
This script counts the datasets in layer 1.
nlay1dats=0; BeforeIterate; doc -e D { nlay1dats+=1; };