udfIsVowel
bln udfIsVowel (str, int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfIsVowel (strString, intPos)
If intPos < 1 Then Return @FALSE
If intPos > StrLen (strString) Then Return @FALSE
Return !!StrIndexNC ("AEIOUY", StrSub (strString, intPos, 1), 1, @FWDSCAN)
;..........................................................................................................................................
; This UDF "udfIsVowel" returns a boolean value, which indicates if
; the character in the given strString at position intPos is a vowel or not.
; The character Y will also be considered as a vowel.
; (c)Detlev Dalitz.20100109.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

blnIsVowel11 = udfIsVowel ("Why not?", 3) ; 1 = @TRUE.
blnIsVowel12 = udfIsVowel ("Why not?", 4) ; 0 = @FALSE.
blnIsVowel13 = udfIsVowel ("Why not?", 5) ; 0 = @FALSE.
blnIsVowel14 = udfIsVowel ("Why not?", 6) ; 1 = @TRUE.



; Method 2.
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfIsVowel_ (strString, intPos)
If intPos < 1 Then Return @FALSE
If intPos > StrLen (strString) Then Return @FALSE
intNum = Char2Num (StrLower (StrSub (strString, intPos, 1))) - 97
Return (17842449 >> intNum) & !(intNum & 4294967264)
;..........................................................................................................................................
; This UDF "udfIsVowel" returns a boolean value, which indicates if
; the character in the given strString at position intPos is a vowel or not.
; The character Y will also be considered as a vowel.
; (c)Detlev Dalitz.20100109.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

blnIsVowel21 = udfIsVowel ("Why not?", 3) ; 1 = @TRUE.
blnIsVowel22 = udfIsVowel ("Why not?", 4) ; 0 = @FALSE.
blnIsVowel23 = udfIsVowel ("Why not?", 5) ; 0 = @FALSE.
blnIsVowel24 = udfIsVowel ("Why not?", 6) ; 1 = @TRUE.



; Method 3.
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfIsVowel__ (strString, intPos, blnVowelY)
If intPos < 1 Then Return @FALSE
If intPos > StrLen (strString) Then Return @FALSE
If blnVowelY Then Return !!StrIndexNC ("AEIOUY", StrSub (strString, intPos, 1), 1, @FWDSCAN)
Return !!StrIndexNC ("AEIOU", StrSub (strString, intPos, 1), 1, @FWDSCAN)
;..........................................................................................................................................
; This UDF "udfIsVowel" returns a boolean value, which indicates if
; the character in the given strString at position intPos is a vowel or not.
; The character Y will also be considered as a vowel by setting parameter blnVowelY to @TRUE.
; (c)Detlev Dalitz.20100109.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

blnIsVowel31 = udfIsVowel__ ("Why not?", 3, 1) ; 1 = @TRUE.
blnIsVowel32 = udfIsVowel__ ("Why not?", 3, 0) ; 0 = @FALSE.
blnIsVowel33 = udfIsVowel__ ("Why not?", 5, 0) ; 0 = @FALSE.
blnIsVowel34 = udfIsVowel__ ("Why not?", 6, 0) ; 1 = @TRUE.

Exit