Parameter checking

Ken Ray kray at sonsothunder.com
Tue Jul 5 12:05:16 EDT 2005


On 7/5/05 5:07 AM, "Dave Cragg" <dcragg at lacscentre.co.uk> wrote:

> 
> On 5 Jul 2005, at 03:21, Ken Ray wrote:
> 
> 
>> 
>> So, for example, if you are checking to see if p1 is between A and
>> P (case
>> insensitive), you can do this:
>> 
>>   if not matchText(p1,"(?i)[A-P]") then exit to top
>> 
>> OR this:
>> 
>>   if not matchText(p1,"[A-Pa-p]") then exit to top
> 
> Ken, I think you need to make it like this:
> 
>    if not matchText(p1,"^[A-Pa-p]$") then exit to top
> 
> 
> Otherwise it will match strings that contain the target character,
> which I don't think is what Sarah wants.

Well, she said the only one letter would be passed as a parameter, so I
didn't feel I needed ^ or $, but you're right... if the needs change and it
becomes more than one character, it will be necessary to add those, and in
fact it would have been better to have them on in the first place so no code
changes need to be made if the params change.

Good catch, Dave!

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the use-livecode mailing list