1. Templates and Masks
Hi all,
Is there anyone who can give me some advice or ideas for
building Euphoria routines/functions to interprete templates and masks
for data field rules in a databases. I know what it is but have know
idea how to build them.
eg.
Template: (___)|___-____
Mask: (999)|999-9999
Fielddata: (617) 555-5423
Thanks in advance,
Marcel Kollenaar
2. Re: Templates and Masks
> Template: (___)|___-____
> Mask: (999)|999-9999
> Fielddata: (617) 555-5423
>
> Thanks in advance,
>
> Marcel Kollenaar
I would imagine making a template would be a snap if you used sprintf() to
create formatted data, which is then stored and returned back to the
program that requested the data to be formatted in the first place. If
sprintf() isn't enough, you can make your own formatter function. For
example, assuming we treat # as the fill digit for a phone number:
--- example of primative formatter using mask
function formatter(sequence mask, sequence unformatted_data)
atom udp
udp = 0
for ix = 1 to length(mask) do
if mask[ix] = '#' then
if udp < length(unformatted_data) then
udp = udp + 1
mask[ix] = unformatted_data[udp]
else
udp = udp + 1
mask[ix] = ' '
end if
end if
end for
return mask
end function
puts(1, formatter("(###)###-####","4169671111"))
puts(1, "\n")
-- end of example
Hope this helps
David Gay
http://www.interlog.com/~moggie/Euphoria
"A Beginner's Guide To Euphoria", Serving The Euphoria Programming
Community Since April 21st, 1996.