Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse command -last line of data

Status
Not open for further replies.

joeb5110

Technical User
May 8, 2009
42
US
I'm not getting the hang of the parse command, despite reading some tutorials and posts. I want to break up a line of text and retrieve data.
For example, my pbx tells me: TEMPERATURE IS 85 DEGREES
I should be able to split that into 4 parts, and just care about the "85" and make a variable out of it.
Thanks for any assistance.
 
Something like this
Code:
line [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]'TEMPERATURE IS 85 DEGREES'[/color]
[COLOR=#0000ff]/* using parse */[/color]
[COLOR=#804040][b]parse var[/b][/color] line p1 p2 p3 p4
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"the number is"[/color] p3

[COLOR=#0000ff]/* using the function word */[/color]
num [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]word([/color]line[COLOR=#804040][b],[/b][/color] 3[COLOR=#008080])[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"the number is"[/color] num
 
Thanks for the tip. I did find an example in the documentation that helped me. In my application, I need to read the line that was output.
For example, TEMPERATURE IS: 25 DEGREES C 77 DEGREES F

I came up with:

temp=ZocLastLine()
PARSE VAR temp temp1 temp2 temp3 temp4 temp5 temp6 temp7 temp8
CALL ZocSend "^M"
a=" "
SAY store||a||temp6 temp7 temp8
CALL ZocSend "^M"

"store" is set earlier and is the telnet connection name.
"a" is just a space. The result comes out the way I want:
Store 100 77 DEGREES F
From there I can play around, maybe have a statement if temp6>90 "put out the fire!" and so on.

jb
 
If you do not need the other parts of the line use dot variables...

Parse line . . . temp .

And concatenating this way...
store temp6 temp7 temp8
is the same as store||" "||temp6 temp7 temp8
which is the same as what you have used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top