Set domain length as a variable

Please supply a minimal working code example,following the guidelines of: Read before posting: How do I get my question answered?