Originally posted by Shaun Beckman
Below is a portion of a script provide by Goutham some time ago to filter on data in PV1 - 7.1,8.1,9.1 & 17.1. The issue we have encountered with a new system is PV1_9 repeats an indeterminate amount of times. We have tried using a counter with the foreach command, but are unable to make it work.
Can someone provide direction for iterating through PV1_9.1?
Any help would be greatly appreciated.
set fldcnt 0
# init - variables
set pv1_7_1 "";set pv1_8_1 "";set pv1_9_1 "";set pv1_17_1 ""
set obr_16_1 ""
# get message
set msg [split [msgget $mh] r]
# PV1 Seg - extract Dr codes from pv1 - 7.1,8.1,9.1 & 17.1
set pv1_loc [lsearch -regexp $msg {^PV1}]
set pv1_seg [lindex $msg $pv1_loc]
echo $pv1_seg
set pv1_7_1 [lindex [split [lindex [split $pv1_seg |] 7] ^] 0]
set pv1_8_1 [lindex [split [lindex [split $pv1_seg |] 8] ^] 0]
set pv1_9_1 [lindex [split [lindex [split $pv1_seg |] 9] ^] 0]
set pv1_17_1 [lindex [split [lindex [split $pv1_seg |] 17] ^] 0]
set dr_cd_in_msg "${pv1_7_1} ${pv1_8_1} ${pv1_9_1} ${pv1_17_1} "