Wednesday, August 26, 2015

String to Boolean


I needed a way to convert a string to a boolean. Specifically, I wanted to use a message in the message catalog to store a variable to allow us to easily change the flow in a specific page. This turned out to be much easier than I expected.

Using the following short hand returns a true if the string matches or false if it does not.

(&theString = "Y")

Here is how I used it with the message catalog text:
  1. Local array of number &openMonths = CreateArray(1, 5, 9);
  2. Local boolean &openSeason = (MsgGetText(21027, 8, "false") = "true");
  3. ...
  4. If (&openMonths.Find(Month(&today)) > 0 And
  5. Day(&today) < 16) Or
  6. &openSeason Then
  7. ...
  8. end-if;