Re: Eu improvements (part 4)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Karl Bochert wrote:
> 
> I might use structures to organize the fields of a customer list, but
> I would want type() to validate that a zipcode is ok.

Or you could create a structure for the zip variable...

type Zip(sequence z) -- the type way
   if all_numbers(z) then
      return length(z) = 5 or length(z) = 9
   else
      return -1
   end if
end type

sequence Zip is
    integer a, b, c, d, e
    where
       a in {0,1,2,3,4,5,6,7,8,9} -- pseudo code
       b in {0,1,2,3,4,5,6,7,8,9}
       c in {0,1,2,3,4,5,6,7,8,9}
       d in {0,1,2,3,4,5,6,7,8,9}
       e in {0,1,2,3,4,5,6,7,8,9}
    end where
end sequence

sequence ZipPlus is
    integer a, b, c, d
    where
       a in {0,1,2,3,4,5,6,7,8,9}
       b in {0,1,2,3,4,5,6,7,8,9}
       c in {0,1,2,3,4,5,6,7,8,9}
       d in {0,1,2,3,4,5,6,7,8,9}
    end where
end sequence

sequence ZipCode is
    Zip zip_code
    ZipPlus zip_plus
end sequence

ZipCode z
z.Zip = "12345"
z.ZipPlus = "9876"

:)

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu