;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udfstracronym",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udfstracronym
#DefineFunction udfStrAcronym (sString, iLength, iCaseMode, iVowelDelMode)
If (sString=="") Then Return ("")
iCaseMode = Min(1,Max(0,iCaseMode))
iVowelDelMode = Min(1,Max(0,iVowelDelMode))
sString = StrClean(sString," abcdefghijklmnopqrstuvwxyz","",@FALSE,2) ; Use only alpha chars and blank.
If iVowelDelMode Then sString = StrClean(sString,"aeiouy","",@TRUE,1) ; Delete vowels and y char.
iLength = Max(-1,iLength)
If (iLength==0) Then iLength = 1 ; Use at least one chararcter.
sAcronym = ""
iCount = ItemCount(sString," ")
For i=1 To iCount
sWord = StrSub(ItemExtract(i,sString," "),1,iLength)
If iCaseMode
sChar = StrSub(sWord,1,1)
If (sChar==StrLower(sChar)) Then Continue
EndIf
sAcronym = StrCat(sAcronym,sWord)
Next
Return (sAcronym)
;..........................................................................................................................................
; This Function "udfStrAcronym" converts a string into its acronym, a sequence of abbreviations,
; by returning the leading substring of iLength alphanumeric characters from each word.
;
; iVowelDelMode=0 ... Vowels are left untouched.
; iVowelDelMode=1 ... All lowercase Vowels and the y character will be deleted from the given string.
; iCaseMode=0 ....... All first letter are returned.
; iCaseMode=1 ....... Only capital first letters are returned.
; iLength ........... The length of each acronym substring to be returned, one char minimum at least.
; iLength=-1 ........ The whole words will be used, no truncation.
;..........................................................................................................................................
; Detlev Dalitz.20020723
;..........................................................................................................................................
#EndFunction
:skip_udfstracronym
;------------------------------------------------------------------------------------------------------------------------------------------
; --- test ---
sAcronym1 = udfStrAcronym("Hey User, this is a Acronym test.",0,0,0) ; "HUtiaAt"
sAcronym2 = udfStrAcronym("Hey User, this is a Acronym test.",0,1,0) ; "HUA"
sAcronym3 = udfStrAcronym("Hey User, this is a Acronym test.",1,0,0) ; "HUtiaAT"
sAcronym4 = udfStrAcronym("Hey User, this is a Acronym test.",1,1,0) ; "HUA"
sAcronym5 = udfStrAcronym("Hey User, this is a Acronym test.",-1,0,0) ; "HeyUserthisisaAcronymtest"
sAcronym6 = udfStrAcronym("Hey User, this is a Acronym test.",-1,1,0) ; "HeyUserAcronym"
sAcronym7 = udfStrAcronym("Hey User, this is a Acronym test.",3,0,0) ; "HeyUsethiisaAcrtes"
sAcronym8 = udfStrAcronym("Hey User, this is a Acronym test.",3,1,0) ; "HeyUseAcr"
sAcronym9 = udfStrAcronym("Hey User, this is a Acronym test.",3,0,1) ; "HUsrthssAcrtst"
sAcronym10 = udfStrAcronym("Hey User, this is a Acronym test.",3,1,1) ; "HUsrAcr"
Exit
;------------------------------------------------------------------------------------------------------------------------------------------
;*EOF*