Page 1 of 1

Locating CR's / LF's in an email text string

Posted: 26 Aug 2014 07:57
by stevek
Hi all,

I'm in the process of creating a flow that will read out loud a received email.

Accessing the received email contents is straightforward by using the system variable: "notification_text".
However, the problem I'm trying to overcome is that "notification_text" displays the entire contents of the email as just a single string ... whereas I'd like to separate the single string of text back into it's original multiple line format.

E.g. The "notification_text" string contains the following:
"John Test This is a test email"
(where "John" = senders name, "Test" = email subject and "This is a test email" = email body).

But if I view "notification_text" in AM's text editor, I see the contents displayed like this:

John
Test
This is a test email

which is exactly what I need.


Obviously, AM's text editor is able to detect the embedded CR's / LF's hidden within the string "John Test This is a test email" and split it into individual lines.

So my question is whether there's some way that I can manually process the "notification_text" variable by searching for CR / LF occurrences and split the single string back into individual strings ?

Thanks in advance,

Steve

Re: Locating CR's / LF's in an email text string

Posted: 26 Aug 2014 10:46
by kintrupf
I didn't try it, but a Script action with something like

Code: Select all

lines = split(notification_text, "\\r?\\n");
might work. The resulting variable "lines" is a list which should contain the separate lines of the mail.

Re: Locating CR's / LF's in an email text string

Posted: 26 Aug 2014 11:09
by stevek
Many thanks ... that example of yours worked perfectly !

Re: Locating CR's / LF's in an email text string

Posted: 26 Aug 2014 17:21
by skiptannen
stevek:

This looks to be really useful for me, but for some reason I'm not able to get it to work using the example. Would you mind posting your flow?

Also, I know that you can view global variables in the AM text editor, but I was not aware that you could view a local variable. Would you mind telling me how that's done? Hopefully I'm not just missing something obvious...

Thanks very much.

Re: Locating CR's / LF's in an email text string

Posted: 27 Aug 2014 10:30
by angelatwork
If you use the debug dialog in your flow, you then can push the local variable in the debug window and choose to show in editor. Hope this helps.

Re: Locating CR's / LF's in an email text string

Posted: 27 Aug 2014 13:52
by skiptannen
That's good to know - thanks very much.

Re: Locating CR's / LF's in an email text string

Posted: 30 Aug 2014 08:18
by skahlhoefer
Hi angleatwork,

could you explain what is meant by the debug dialog? Where do I find vor activate this?
I have looked in the flow and global menus as well as the list of available actions but without success.
As oft today I log all my variables to debug a flow but maybe this dialog would be more helpful.

Stefan

Re: Locating CR's / LF's in an email text string

Posted: 30 Aug 2014 08:52
by Martin
Hi,

You can find the Debug Dialog in the list of conditions.
The condition displays a dialog with all available local and global variables at the time when the condition is executed. You can also manually modify the values of the local variables by tapping on a variable and selecting Change value. The buttons of the dialog can be used to continue the flow on the true- or false-branch of the condition.

Regards,
Martin