pH-Controlled molecular switches and the substrate-directed self-assembly of molecular capsules with a calix[4]pyrrole derivative.