42 |
|
print "\n\n"; |
43 |
|
|
44 |
|
foreach $query ( $userquery->querylist() ) { |
45 |
< |
# -- informational for each query |
46 |
< |
print $userquery->querymessage($query)."\n"; |
47 |
< |
|
48 |
< |
# -- ship off to the correct routine based on type |
49 |
< |
foreach $command ( @{$self->{allowed_commands}} ) { |
50 |
< |
$type=$userquery->querytype($query); |
51 |
< |
if ( $command=~/^$type/ ) { |
52 |
< |
$rv=$self->_calltype($command, $userquery, $query); |
53 |
< |
$found='true'; |
54 |
< |
last; |
55 |
< |
} |
56 |
< |
} |
57 |
< |
if ( $found ne "true" ) { |
58 |
< |
# default to basic |
59 |
< |
$rv=$self->_calltype("basic", $userquery, $query); |
60 |
< |
} |
45 |
> |
$rv=$self->_executequery($userquery,$query); |
46 |
|
} |
47 |
|
|
48 |
|
|
65 |
|
return $rv; |
66 |
|
} |
67 |
|
|
68 |
+ |
sub _executequery { |
69 |
+ |
my $self=shift; |
70 |
+ |
my $userquery=shift; |
71 |
+ |
my $query=shift; |
72 |
+ |
|
73 |
+ |
# -- informational for each query |
74 |
+ |
print $userquery->querymessage($query)."\n"; |
75 |
+ |
|
76 |
+ |
# -- ship off to the correct routine based on type |
77 |
+ |
foreach $command ( @{$self->{allowed_commands}} ) { |
78 |
+ |
$type=$userquery->querytype($query); |
79 |
+ |
if ( $command=~/^$type/ ) { |
80 |
+ |
$rv=$self->_calltype($command, $userquery, $query); |
81 |
+ |
$found='true'; |
82 |
+ |
last; |
83 |
+ |
} |
84 |
+ |
} |
85 |
+ |
if ( $found ne "true" ) { |
86 |
+ |
# default to basic |
87 |
+ |
$rv=$self->_calltype("basic", $userquery, $query); |
88 |
+ |
} |
89 |
+ |
return $rv; |
90 |
+ |
} |
91 |
+ |
|
92 |
|
sub _calltype { |
93 |
|
my $self=shift; |
94 |
|
my $command=shift; |
99 |
|
my $rv=$self->$command( $userquery->queryprompt($query), @options ); |
100 |
|
|
101 |
|
# now process the response |
102 |
< |
$userquery->lodgevalue($query,$rv); |
102 |
> |
my ($ret,$message,@vals)=$userquery->lodgevalue($query,$rv); |
103 |
> |
if ($ret ne 0 ) { # invalid response |
104 |
> |
print "Input not valid :"; |
105 |
> |
print $message->read(); |
106 |
> |
$rv=$self->_executequery($userquery,$query); |
107 |
> |
} |
108 |
|
return $rv; |
109 |
|
} |
110 |
|
|