This document was generated from CDN thread
Created by: Jean Lofrano on 26-03-2013 01:42:40 PM
Hey team, I´ve been receiving a variable with the value like this: 222|5555 So I have: if {[::httpios::status $token] == "ok"} { set ReturnData [string trim [::httpios::data $token]] } puts "Return is $ReturnData" ReturnData=222|5555 How can I divide that value in two variable like this: x = 222 y = 5555 thanks.
Subject: RE: How can I separate the variable value?
Replied by: Yaw-Ming Chen on 26-03-2013 02:09:30 PM
use split with separater "|"
assuming returndtat is "222|5555"
"lindex [split $returndata |] 0" will get 222
and
"lindex [split $returndata |] 1" will get 5555
Subject: RE: How can I separate the variable value?
Replied by: Jean Lofrano on 26-03-2013 02:19:52 PM
Hey,
I did the follow: right?
if {[::httpios::status $token] == "ok"} {
set ReturnData [string trim [::httpios::data $token]]
}
puts "Return is $ReturnData"
set a lindex [split $ReturnData] 0
set b lindex [split $ReturnData] 1
puts "a is $a"
puts "b is $b"
but I had a issue return below...
Mar 26 19:17:19.558: //6929//PACK:/tclhttp_handle_httpcb_event: Tcl_Eval to drive http callback failed. code=1 code=ERROR
*Mar 26 19:17:19.558: TCL script failure
Result:
wrong # args: should be "set varName ?newValue?"
*Mar 26 19:17:19.558: TCL script failure errorInfo:
wrong # args: should be "set varName ?newValue?"
while compiling
"set a lindex [split $ReturnData] 0
(compiling body of proc "ReturnConsult", line 19)
invoked from within
"ReturnConsult ::httpios::httpios_4211"
Subject: RE: How can I separate the variable value?
Replied by: Yaw-Ming Chen on 26-03-2013 02:37:53 PM
no
set a [lindex [split $data |] 0]
set b [lindex [split $data |] 1]
Subject: RE: How can I separate the variable value?
Replied by: Jean Lofrano on 26-03-2013 03:11:19 PM
Ok! Great!
thanks.