udfStrSubCase (sString, iStart, iLength, iMode)
;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udfstrsubcase",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udfstrsubcase

#DefineFunction udfStrSubCase (sString, iStart, iLength, iMode)
iStrLen=StrLen(sString)
If !iStrLen Then Return sString
If iStart<=0 Then iStart=iStrLen+iStart+1
If iLength>0
   iL=iStart
   iR=iStart+iLength-1
Else
   iL=iStart+iLength+1
   iR=iStart
EndIf
If iL<1 Then iL=1
If iR>iStrLen Then iR=iStrLen
If iL>iR Then Return sString
hBB=BinaryAlloc(iStrLen)
BinaryPokeStr(hBB,0,sString)
If !!iMode Then BinaryPokeStr(hBB,iL-1,StrUpper(StrSub(sString,iL,iR-iL+1)))
   Else BinaryPokeStr(hBB,iL-1,StrLower(StrSub(sString,iL,iR-iL+1)))
sString=BinaryPeekStr(hBB,0,iStrLen)
BinaryFree(hBB)
Return sString
;..........................................................................................................................................
; This Function "udfStrSubCase" returns a string with partial uppercased resp. lowercased characters.
; If parameter iStart is a negative number then the start position is relative to the end of the given string.
; If parameter iLength is a negative number then the characters are counted backwards.
; iMode = 0 ... SubString conversion to lower case.
; iMode = 1 ... SubString conversion to upper case.
;..........................................................................................................................................
; Detlev Dalitz.20030909
;..........................................................................................................................................
#EndFunction

:skip_udfstrsubcase
;------------------------------------------------------------------------------------------------------------------------------------------


; --- test ---

sResult11 = udfStrSubCase("a"    , 1, 1,1)  ; ==> "A"
sResult12 = udfStrSubCase("a"    , 1,-1,1)  ; ==> "A"
sResult13 = udfStrSubCase("a"    ,-1, 1,1)  ; ==> "A"
sResult14 = udfStrSubCase("a"    ,-1,-1,1)  ; ==> "A"

sResult21 = udfStrSubCase("abc"  , 1, 1,1)  ; ==> "Abc"
sResult22 = udfStrSubCase("abc"  , 1,-1,1)  ; ==> "Abc"
sResult23 = udfStrSubCase("abc"  ,-1, 1,1)  ; ==> "abC"
sResult24 = udfStrSubCase("abc"  ,-1,-1,1)  ; ==> "abC"

sResult31 = udfStrSubCase("abc"  , 2, 1,1)  ; ==> "aBc"
sResult32 = udfStrSubCase("abc"  , 2,-1,1)  ; ==> "aBc"
sResult33 = udfStrSubCase("abc"  ,-2, 1,1)  ; ==> "aBc"
sResult34 = udfStrSubCase("abc"  ,-2,-1,1)  ; ==> "aBc

sResult41 = udfStrSubCase("abc"  , 2, 2,1)  ; ==> "aBC"
sResult42 = udfStrSubCase("abc"  , 2,-2,1)  ; ==> "ABc"
sResult43 = udfStrSubCase("abc"  ,-2, 2,1)  ; ==> "aBC"
sResult44 = udfStrSubCase("abc"  ,-2,-2,1)  ; ==> "ABc"

sResult51 = udfStrSubCase("abcd" , 3, 2,1)  ; ==> "abCD"
sResult52 = udfStrSubCase("abcd" , 3,-2,1)  ; ==> "aBCd"
sResult53 = udfStrSubCase("abcd" ,-3, 2,1)  ; ==> "aBCd"
sResult54 = udfStrSubCase("abcd" ,-3,-2,1)  ; ==> "ABcd"

sResult61 = udfStrSubCase("abcde", 3, 2,1)  ; ==> "abCDe"
sResult62 = udfStrSubCase("abcde", 3,-2,1)  ; ==> "aBCde"
sResult63 = udfStrSubCase("abcde",-3, 2,1)  ; ==> "abCDe"
sResult64 = udfStrSubCase("abcde",-3,-2,1)  ; ==> "aBCde"

sResult90 = udfStrSubCase("this is a test string",-100, 6,1)  ; ==> "this is a test string"
sResult91 = udfStrSubCase("this is a test string",   0, 6,1)  ; ==> "this is a test string"
sResult92 = udfStrSubCase("this is a test string",   1,-6,1)  ; ==> "This is a test string"
sResult93 = udfStrSubCase("this is a test string",  11, 4,1)  ; ==> "this is a TEST string"
sResult94 = udfStrSubCase("this is a test string", -11, 4,1)  ; ==> "this is a TEST string"
sResult95 = udfStrSubCase("this is a test string",  -1, 6,1)  ; ==> "this is a test strinG"
sResult96 = udfStrSubCase("this is a test string", -18,-4,1)  ; ==> "THIS is a test string"
sResult97 = udfStrSubCase("this is a test string", -18,-5,1)  ; ==> "THIS is a test string"
sResult98 = udfStrSubCase("this is a test string", -21,-4,1)  ; ==> "This is a test string"
sResult99 = udfStrSubCase("this is a test string", -22,-4,1)  ; ==> "this is a test string"

Exit
;------------------------------------------------------------------------------------------------------------------------------------------
;*EOF*