;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfStrLeft (strString, intLength, strPadString) If strPadString == "" Then strPadString = " " Return StrFix (StrSub (strString, 1, intLength), strPadString, intLength) ;.......................................................................................................................................... ; This UDF "udfStrLeft" returns the leftmost length characters of string. ; If string has less than length characters, the result will be padded on the right side ; with the pad string, which defaults to a blank. ;.......................................................................................................................................... ; Detlev Dalitz.20030312 ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. strResult1 = udfStrLeft ("abcd" , 10, "-#") ; "abcd-#-#-#" strResult2 = udfStrLeft ("abcd" , 6, "*" ) ; "abcd**" strResult3 = udfStrLeft ("testabcdefgh", 4, "*" ) ; "test" strResult4 = udfStrLeft ("testabcdefgh", 4, "" ) ; "test" strResult5 = udfStrLeft ("testabcdefgh", 15, "" ) ; "testabcdefgh " Exit ;------------------------------------------------------------------------------------------------------------------------------------------