On 7/4/05 9:05 PM, "Sarah Reichelt" <[EMAIL PROTECTED]> wrote:
> Secondly, has anyone any suggestions of the best way to do this? I > can do it in a long-winded manner, but I feel sure that some RegEx > wizard (Ken, are you listening), would be able to come up with a > really neat way to solve this. Yes, Sarah, I'm listening... :-) > Here is pseudo-code is what I want to do: > > on sendSerialCommand p1, p2, p3 > -- p1 must be A-P or a-p > if paramError(p1,"A-P|a-p") then exit to top > -- p1 must be a number from 1 to 8 > if paramError(p2,"1-8") then exit to top > -- p1 must be either S or D > if paramError(p3,"S|D") then exit to top > > sendSerialString p1 & p2 & p3 > end sendSerialCommand You can use RegEx to see if an incoming param matches a set of strings or numbers. The basic rules are: 1) Put what you're looking for in brackets 2) If you actually have a range to check, you can use the hyphen between (even for letters). 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 the (?i) means to be case insensitive. Here's a few more from your example: if not matchText(p2,"[1-8]") then exit to top if not matchText(p3,"[SD]") then exit to top -- note s,d won't match if not matchText(p3,"(?i)[SD]") then exit to top -- matches SDsd if not matchText(p3,"[SDsd]") then exit to top -- matches SDsd HTH, Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] _______________________________________________ use-revolution mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
