#!/bin/sh
# \
exec oagtclsh "$0" "$@"

# $Log: not supported by cvs2svn $

set auto_path [linsert $auto_path 0  /usr/local/oag/apps/lib/$env(HOST_ARCH) ]
set auto_path [linsert $auto_path 0 /usr/local/oag/lib_patch/$env(HOST_ARCH)]
APSDebugPath

set usage "usage: printEnumeratedValues -PV <string>"
set args $argv 
set PV ""
APSParseArguments {PV}

if {$PV == ""} {
    puts stderr $usage
    exit
}

if [catch {exec cavget -list=$PV.RTYP} type] {
    puts stderr "Problem connecting with $PV: $type"
    exit
}
if ![regexp {\\?} $type] {
    puts stderr "Problem connecting with PV $PV."
    exit
}
if ![regexp {mbb} $type] {
    puts stderr "Problem with PV $PV, probably not an enumerated type."
    exit
}

catch {exec cavget -list=$PV -list=. -list=ZR,ON,TW,TH,FR,FV,SX,SV,EI,NI,TE,EL,TV,TT,FT,FF -list=ST } results

set i 0
foreach item $results {
    if {$item != ""} {
        puts stdout "state $i \"$item\""
    }
    incr i
}

exit
