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

Post your questions and help other users.

Moderator: Martin

Post Reply
stevek
Posts: 9
Joined: 26 Aug 2014 07:32

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

Post by stevek » 26 Aug 2014 07:57

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

User avatar
kintrupf
Posts: 257
Joined: 10 Sep 2013 08:59

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

Post by kintrupf » 26 Aug 2014 10:46

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.

stevek
Posts: 9
Joined: 26 Aug 2014 07:32

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

Post by stevek » 26 Aug 2014 11:09

Many thanks ... that example of yours worked perfectly !

skiptannen
Posts: 82
Joined: 13 Jan 2014 21:39

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

Post by skiptannen » 26 Aug 2014 17:21

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.

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

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

Post by angelatwork » 27 Aug 2014 10:30

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.
Best regards,
AngelAtwOrk

skiptannen
Posts: 82
Joined: 13 Jan 2014 21:39

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

Post by skiptannen » 27 Aug 2014 13:52

That's good to know - thanks very much.

skahlhoefer
Posts: 12
Joined: 02 Dec 2013 22:35

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

Post by skahlhoefer » 30 Aug 2014 08:18

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

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 30 Aug 2014 08:52

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

Post Reply