The first example selects all $C^{\alpha}$ carbon atoms between residue number 40 and 100:
( name ca and resid 40:100 )
The next example selects all heavy side-chain atoms:
( not ( name ca or name n or name c or name o or hydrogen ) )
The next example selects all atoms in Phe residues that are within 20 Å around residue 1:
( resname phe and ( residue 1 around 20.0 ) )
The next example is similar to the previous one, except that all atoms of a particular Phe residue are selected once any atom of this residue is within 20 Å from residue 1:
( byresidue ( resname phe and ( residue 1 around 20.0 ) ) )
Suppose that we want to get the stereochemistry as a function of residue number. The following example tags each residue by using its $C^{\alpha}$ carbon atom and then computes the rms deviation of bond lengths from ideality for all atoms of the selected residue.
for $1 in id ( name ca ) loop main
   constraints interaction=( byresidue ( id $1 ) )=(previous) end
   print threshold=0.1 bonds
   display   $RESULT
end loop main

Xplor-NIH 2023-11-10