Regarding obtaining a number

TT=170ms OTL=0mm CC=1 OI=1600384290470000000010 C128 63% ST=0 RA=46 CL=20 CS=_63 DIR=1 OD=524 FC=498

Ok, interesting.

Let's practice formatting the stuff you paste.

Top left of the keyboard. (Left of the number 1) there is a key.
Press it. Then paste from the clipboard and press that button again.

That should make it look something like:

TT=170ms OTL=0mm CC=1 OI=1600384290470000000010 C128 63% ST=0 RA=46 CL=20 CS=_63 DIR=1 OD=524 FC=498

TT=169ms OTL=0mm CC=1 OI=1200384290470000000010 C128 17% ST=0 RA=49 CL=20 CS=_17 DIR=1 OD=414 FC=498

This is what i obtain now. I have deleted the json node and the other otput node as well

So you could feed that output to a split node and split it on a space, feed to output to a switch and test if the payload contains OI=

Send that output to a function node and strip out the 'OI=' and you should be set.

Here is a basic picture of what you need to do:

1 - ignoring the TCP in node not being set correctly.
2 - Connect a split node as shown.
3 - Connect a switch node as shown.
4 - Configure the split node as shown.
Note there is a > space < in the field which you can't see. By default it has \n. Delete that and press the space bar.
5 - Configure the switch node as shown. That is OI (capitol i) OI=

That will get you the result you need to this point.

Andrew, that is not enough. Jatin wants to get the number portion of the string.

@jatin.pachisia so you have OI=1200384290470000000010 and you want to get rid of the first 7 characters of that string and return the results as a number (384290470000000010)...correct?

I also notice that inone o your debug's there is a ...OI=4[]*NoRead*... which I assume you want to ignore so you will need to check for that string and skip it if it exists. In the switch node, first check if the input string contains NoRead' and ignore it. Make sure to set the switch node to stop after first match

@jatin.pachisia do you really want it as a number, or do you want it as a string containing those digits? If you don't know then tell us what you want to do with it after you have got it.

Okay. I had to make a new account in order to be able to reply. Since a new user has limited amount of messages. I did whatever I was asked to above. I put in a split node and the switch node adn set them to use as mentioned above. What i need to do is to be able to split the variable into two. The value i see now is OI=200384290470000000010
The 20 here is the index number and the 0038 until 0 is the number i need as the output. My work is to basically be able to obtain this number which my barcode scanner will be reading of pallets. According to the numbers, i can decide where my automated vehicle should be heading towards to pick up the pallets. I think i will be needing a function node

The value that i obtain can be in Hexadecimal or ascii format. So i will need to know how to be able to code in order to be able to understand for future purposes. When the bar code scans a code of the pallete, I get the index number and the code. Which is perfect now. However, i am trying to split them into two parts. Because then later i will be able to send the output to some other place.

So you want to remove the first 5 characters not nescessaraly IO=20 since I see IO=16 in an earlier debug you posted.

I would do it wit a change node using two JSONata expressions - the first gets rid of the first 5 characters, the second returns it as a number
Screen Shot 2020-01-27 at 8.58.40 AM

(just thinking out loud.... I would also put the 16 or 20 (last two chars of the "header" into msg.topic... just in case... :wink:

1 Like

So i am supposed to add a change node after my switch node ? with the above mentioned ways. I will also be needing an inject node right ?

What have you tried and are you having an issue now?

Invalid JSONata expression: Unable to cast value to a number: "\n00384290470000000010\r\n"


This is what i get when i tried using the change node and using the JsoNata expressions

Please export your flow and attach it to a reply. Then put a debug node (set to display the complete msg object) on the output of the TCP node.

When you have the debug, click the payload to display the complete value in it. Copy that value and paste it into your reply too.

I really don't think you want to convert it to a number. If you do that you will lose some of the least significant digits as the largest integer that can be held in javascript is 9007199254740992. I think you want to keep it as a string of digits.
If you do convert it the result will be that the number in the string above will be stored as 3.8429047*10^17 and you will lose the 10 on the end.

Ok, but I made a flow which injected the string he posted.

The switch node worked because it looked for 'OI=` in the string.
Yes, I know there are better ways. But I did test it before posting.

Stripping the other stuff to get the 3842904..... would be the next step.

Invalid JSONata expression: Unable to cast value to a number: "\n00384290470000000010\r\n"
i cannot export flows and attach them here as i am a new user. But this is what the complete value says when i attached the change node after the switch like you asked me to.

sorry that was the wrong image

  1. Why didn't you add the code to the switch to ignore the *NoRead* entries?
  2. did you change the split value or the TCP 'Output' settings?
  3. In your prior debug outputs there were no special characters, now there are, what changed?

Please put a 'debug' node (set to display the 'Complete msg object') on the output of the TCP node so I can see what the data is again.