Re: Stupid Newbie-sounding question.

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

>Juergen Luethje wrote:
<snip> 
>> At the first glance, it might look as if an additional data type would
>> make Euphoria more complicated,
Adding a string type takes the number of cases for the "&" operator
from 8 to 19, without considering unicode strings. Just so you know. I
agree that string types might be nice, but they are far from trivial.

>Nicholas Koceja wrote:
<snip>
>        if (x >= 'a' and x <= 'z') or        -- all lowercase characters
>           (x >= 'A' and x <= 'Z') or        -- all uppercase characters
>           (x >= '0' and x <= '9') or        -- all numericial characters
>           find(x, "?<>,./\\|[]{}`" &            --\ all of the other symbols
>                   "~!@#$%^&*()-=_" &            --- that you can type, even
>                   "+:\'\"\t\r\n" & {32}) then   --/ with "Shift" held down.
<snip>
Yuk. The above will not cope with multinational character sets either.
The following is much simpler, faster and better:

type string(object s)
object c
	if not sequence(s) then return 0 end if
	for i=1 to length(s) do
		c=s[i]
		if not integer(c) or c<0 or c>255 then return 0 end if
	end for
	return 1
end type

Regards,
Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu