1

I've yet to find a way to display only the first letter as uppercase and rest of the text as lowercase. Is that even possible when setting a message? Currently it's posting always, everything in uppercase.

IF Not Empty(@Data) Then
 SET @Message = "Thanks!"
Else
 SET @Message = "Try again."
EndIF
]%%

Using AMPscript LowerCase doesn't seem to work.

1 Answer 1

3

If your expecting ONLY the first letter to be uppercase and then everything else following it to be lowercase you can do this;

  %%[
  VAR @Message
  SET @Message = "TRY AGAIN."
  SET @MessageLength = LENGTH(@Message)
  SET @subtract = SUBTRACT(@MessageLength,1)
  SET @upper = UPPERCASE(SUBSTRING(@Message,1,1))
  SET @lowercase = LOWERCASE(SUBSTRING(@Message,2,@subtract))
  SET @MessageNew = CONCAT(@upper, @lowercase)
  ]%%

The output will be - Try again.

Just to explain it a bit, this is what is happening to the code:

  1. The substring will get the first character in your string (denoted by the first 1 and will continue until the end (denoted by the second 1).
  2. Next you subtract the 1 character from your full string (used in the variable @lowercase) to essentially get varibable - 1.
  3. Again you repeat the process for the rest of your string inside of your declared variable (i.e. @Message). However, you need now make the rest of the string lowercase, so you start at the second character (denoted by the 2) and it will end at the end of the length of your declared subtract variable.
  4. You then concatenate it all into one string.

Here's some links to help you understand (unfortunately I can only link 2)

Concat
Substring

Here's a quick explaination of the others used;
Length spits out the length of your string (including spaces).
The subtract is a minus calculation.
The uppercase function makes the whole string uppercase.
The lowercase function makes the whole string lowercase.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .