'MacroName:sentenstyle 'MacroDescription:sentenstyle 'This macro converts specific fields into "Sentence" style with the first letter getting capitalized 'while the rest gets converted to lowercase; or it capitalized the first letter of each word. 'September 30, 2010 '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '<<<<< Enter lazy programming mode. What variable declarations? <<<<< '>>>>> Feel free to modify. Code is unoptimized and minimally tested. >>>>> '<<<<< Tested only to see that it works. :-) <<<<< '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Global CS As Object '*** Converts field to sentence style. Capitalize first letter of first word of field (and specific subfields in array y) Private Function toSentence(a as String) as String Dim y(1 to 4) y(1) = "ßa " y(2) = "ßi " y(3) = "ßn " y(4) = "ßp " frstltr = UCase(mid(a, 6, 1)) mid(a, 6, 1) = frstltr for i = 1 to 4 x = InStr(1, a, y(i)) Max = Len(a) Do While x > 0 and x < Max frstltr = UCase(mid$(a, x+Len(y(i)), 1)) mid(a, x+Len(y(i)), 1) = frstltr x = InStr(x+Len(y(i)), a, y(i)) Loop next i toSentence = a End Function '*** Capitalizes each word in a field. Array y contains characters that often precede words. Private Function toCap(a as String) as String Dim y(1 to 4) y(1) = " " y(2) = "." y(3) = "[" y(4) = "(" a = LCase(a) for i = 1 to 4 x = InStr(1, a, y(i)) Max = Len(a) Do While x > 0 and x < Max frstltr = UCase(mid$(a, x+Len(y(i)), 1)) mid(a, x+Len(y(i)), 1) = frstltr x = InStr(x+Len(y(i)), a, y(i)) Loop next i toCap = a End Function Private Function modField(b as String, c as Integer) as Integer a = "" 'Stores value of each field n = 1 'Just a counter bool = CS.GetField(b, n, a) If c = 0 Then Do While a <> "" a = LCase(a) a = toSentence(a) bool = CS.SetField(n, a) n = n+1 bool = CS.GetField(b, n, a) Loop Else Do While a <> "" a = toCap(a) bool = CS.SetField(n, a) n = n+1 bool = CS.GetField(b, n, a) Loop End If End Function Sub Main Set CS = CreateObject("Connex.Client") '245 field gets special treatment. Everything before $c is lowercase except first letter. After $c the first 'letter of each word gets capitalized. bool = CS.GetField("245", 1, s245) s245 = LCase(s245) s245 = toSentence(s245) If InStr(s245, "ßc") <> 0 Then subC = toCap(mid$(s245, InStr(s245, "ßc"))) mid(s245, InStr(s245, "ßc")) = subC End If bool = CS.SetField(1, s245) 'Call function to modify each field. 1st argument is the field number; 2nd argument is a flag 'to either convert each word to uppercase or to convert everything to lowercase except the first word. '1 = Change first letter of each word to uppercase. 2 = Change only the first letter of the field to uppercase. bool = modField("240", 0) bool = modField("260", 1) bool = modField("246", 0) bool = modField("130", 0) bool = modField("362", 1) bool = modField("250", 1) End Sub