determining a plain text file

Alex Tweedly alex at tweedly.net
Mon Jul 10 05:29:43 EDT 2006


Mark Smith wrote:

> ps. the function I used was:
>
> function isText tData
>  --  put replacetext (tData,"[^\x20-\x7E\n\r\t]","") into nData
>  --  return tData = nData
>
>  repeat for each char c in tData
>    add 1 to tc
>    get charToNum(c)
>    if it <> 9 OR it <> 10 Or it <> 13 AND it < 32 then exit repeat
>  end repeat
>  return tc = length(tData)
> end isText
>
Ummmm - that's not right.
Instead of

>    if it <> 9 OR it <> 10 Or it <> 13 AND it < 32 then exit repeat

it should be

>    if it <> 9 AND it <> 10 AND it <> 13 AND it < 32 then exit repeat


As it is, every character will pass that test - usually on the first and 
certainly no later than the second sub-clause of the test.

I'd still expect this method to be faster than the Regex - but your test 
will run somewhat faster than the correct equivalent would.


-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/383 - Release Date: 07/07/2006




More information about the use-livecode mailing list