Syntax for randomized greeting with time of day If statement

Can you provide the syntax for the following:

Randomized greeting with "Hi, Hello, and Good (morning/afternoon/evening)" as the choices?
(morning triggers if current time is before 12pm, afternoon if between 12:01pm and 5:59pm, evening if after 6pm)

Thank you.

Hi @John_Gay,

For this, you'll need to install the "Randomize" command pack in your Text Blaze dashboard. Here's how to do that:

And here's the snippet ready for you to copy/paste into your dashboard.

{greeting={random-text: Hi, Hello, Good}; trim=yes}
{if: greeting=="Good"}Good {if: {time: HH} <12}morning{elseif: {time: HH}>=12 and {time: HH} <18}afternon{else}evening{endif}
{else: trim=yes}{=greeting}{endif}

P.S. The preview on the forum won't work for this snippet, since the Randomize command pack isn't installed here.

Perfect, thanks.

Related: how about the syntax for a closing that randomizes: Best, Regards, and Enjoy your____ (blank is either "week" if current day is M or T, "day" if current day is W or TH, or "weekend," if current day is F, S, or Su.

Thanks.

Here you go :slight_smile:

{salutation={random-text: Best, Regards, Enjoy your}; trim=yes}
{if: salutation=="Enjoy your"}Enjoy your {if: {time: ddd} == "Mon" or {time: ddd} == "Tue"}week{elseif: {time: ddd} === "Wed" or {time: ddd} == "Thu"}day{else}weekend{endif}
{else: trim=yes}{=salutation}{endif}

Here's the complete template for anyone who wants to grab it:

Lovin the randomizer command pack and the other awesome code goodies. You guys are seriously taking Text Blaze to the next level. Literally use it every day.
Rock on!_!

1 Like

Thanks @frank, that's really good to hear. If you have any other questions or suggestions, you know where to find us :slight_smile:

P.S. Would you like to see Text Blaze on other platforms like Windows, Mac, Android, iOS and others?
Tell us here: