Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

I am using a serial plugin to receive data into a field, I need to manipulate this data so that I get the most recently received reading each time.

The data feeds into a holding field, when it populates into the field it appears as either 1 reading, 2 readings or 3 readings at a time with the newest one being the last one to appear in the field.

Each reading has a leading and ending identifier (I can't enter them here as the character set isn't supported).

The data looks like this:

3.156G 4.541G

The leading identifier, 3 spaces, THE DATA I WANT, a G and an ending identifier.

Going by the above, my end result would be "4.541"

Can anyone help me out with how I will get the data required.

I am using the Troi Serial Plugin

Let(

values = Substitute ( Trim ( YourField ) ; " " ; ¶ ) ;

GetValue ( values ; ValueCount ( values ) )

)

That wouldn't drop the 'G' off the end. Another possible option would be:

GetAsNumber ( RightWords ( field ; 1 ) )

Or Filter( RightWords( field ; 1 ) ; "01234567890." )

Nope. That wouldn't work.

KIDDDDDDDIIIIINNNNNNNGGGGGGG!!!!:giggle:

Hi Vaughan!!

Or Filter( RightWords( field ; 1 ) ; "01234567890." )

Isn't there some point in using the layout pulled formatting, the dot makes hardly any point if the receiving field is number, but could make a hell of a difference if the system setting is other than "new world" default.

--sd

You could use =

GetAsNumber ( RightWords ( field ; 1 ) )

However, if you are using a comma as your decimal separator, and the input data contains a dot instead (as shown in the OP example) you already have a problem.

---

Oops - didn't see LaRetta already suggested this.

Edited by Guest

I didn't use a calculation based on the GetAsNumber( ) function because nobody said that an identifier must be a number.

What if his system has the comma as a decimal separator, but the identifier isn't a number ( only a sequenze of digit and dots ) ?

Also I didn't discard the G because he said:

"THE DATA I WANT, a G and an ending identifier." that isn't exactly the same of their next: "Going by the above, my end result would be "4.541"

The way I read it: "..., THE DATA I WANT, [and] a G and an ending identifier."

... and now I remember why I didn't use RightWords ( )...

If the identifier was a decimal number starting with a dot ?

If the identifier was a decimal number starting with a dot ?

Doesn't seem very likely:

Each reading has a leading and ending identifier (I can't enter them here as the character set isn't supported).

But it would be better if the OP clarified this point.

"The leading identifier, 3 spaces, THE DATA I WANT, a G and an ending identifier."

I read that this is the description of the sequence of how the characters will appear ... the leading identifier, 3 spaces, THE DATA HE WANTS, then a G and an ending identifier.

It was clearly indicated the final result of 4.541. BTW, GetAsNumber() drops invalid characters at the beginning, middle or end since FM sees numbers only (or as indicated by Michael, a comma if the OS was so inclined). Invalid characters are not seen as word separators either.

RightWords() applied to 313.44 417.22445G would automatically drop the first invalid character because it does not see it as a character.

313.44 417.22445G would be considered two words (only because of the space between) and the calculation I provided will give the result of 417.22445. You can go on until the cows come home but we can only go by the information presented. If the person presenting the data doesn't provide all possible strings then it is their responsibility to come back and provide further detail.

Also, a period or dash does NOT belong to invalid character set as was indicated by "Each reading has a leading and ending identifier (I can't enter them here as the character set isn't supported). And sorry, Michael, my response was more directed towards Daniele but overall I was speaking to the both of you. :laugh2:

Edited by Guest

I agree 100%.

I sure misunderstood the sequence and what he considered an identifier.

So now, thanks to LaRetta, I understand that the string could be:

[LeadingIdentifier][3spaces][TheData][G][EndingIdentifier][LeadingIdentifier][3spaces][[color:red]TheDataHeWants][G][EndingIdentifier]

In this case RightWords ( string ; 1 ) may give incorrect value if:

[[color:red]TheDataHeWants] starts with a dot

[[color:red]TheDataHeWants] ends with a dot

The lone sure thing is that there are 3 spaces before the last part of the string.

So my calc could be modified to:

Let(

values = Substitute ( Trim ( YourField ) ; " " ; ¶ ) ;

Substitute ( GetValue ( values ; ValueCount ( values ) ) ; [ "G" ; "" ] ; [ "EndingIdentifier" ; "" ] )

)

This can evaluate correctly a string like:

313.44G .44G

or

313.44G 31344.G

RightWords ( string ; 1 ) may give incorrect value if:

[[color:red]TheDataHeWants] starts with a dot

Right. Good catch.

It might be nice to hear back from the OP. He hasn't been back since he posted his question.

Lee

Yes !

BTW: it is now much time I wanted to ask: what "OP" stands for ?

OP is 'other person', original poster or sometimes called On Point.

I'm joking of course ... it can stand for many things just as LOL can stand for different things. Here's where you will find the answers

Edited by Guest

Thank you.

I like:

Old Patient

OutPatient

because some times the OP needs to be patient with us till he becomes old. ( or, like an OutPatient, must come many times to the Forum/Hospital ) :

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.