Artifact Content

Artifact 2e81f84b0a362b16f7e1c9990534105957eaac5a:

Wiki page [More Values Techniques] by mrwellan 2011-11-02 17:04:55.
D 2011-11-02T17:04:55.330
L More\sValues\sTechniques
P 4064423a0dde3c3843abc35a1ff7178dffc99e14
U mrwellan
W 1935
<h3>Techniques to Extract Values</h3>

Extracting multiple values from a line and calling separate programs on each:

In your logpro file create a hook and either an expect (can be any of error, warning, ignore or required).

(hook:add "quadval" "echo \"Value1: #{m1}\";echo \"Value2: #{m2}\";echo \"Value3: #{m3}\";echo \"Value4: #{m4}\"") 

;; Use expect:required to extract some values
(expect:required   in "LogFileBody" = 1 "Quad values" #/First:\s+(\d+)\s+Second:\s+(\d+)\s+Third:\s+(\d+)\s+Fourth:\s+(\d+)/ hook: "quadval")

If the logfile for this example contains this line:
// A case where we are capturing multiple values on a single line and exectuting 
// multiple calls to load them

First: 1 Second: 2 Third: 3 Fourth: 4

Then the output will show the calls to echo in the hook:add line:

LOGPRO Required: Quad values = 1 in section LogFileBody on line 40
NONERR HOOK CALLED: echo "Value1: 1";echo "Value2: 2";echo "Value3: 3";echo "Value4: 4"
Value1: 1
Value2: 2
Value3: 3
Value4: 4
First: 1 Second: 2 Third: 3 Fourth: 4

If you are using megatest to capture results and roll them up you could use a hook specification like this:

megatest -set-values :value #{m1} :expected_value 0 :tol 1 :category extents :variable ll :units km 
(hook:add "qualval" (conc 
     "megatest -set-values :value #{m1} :expected_value 0   :tol 1 :category extents :variable first  :units km;"
     "megatest -set-values :value #{m2} :expected_value 0   :tol 1 :category extents :variable second :units km;"
     "megatest -set-values :value #{m3} :expected_value 100 :tol 1 :category extents :variable third  :units km;"
     "megatest -set-values :value #{m4} :expected_value 100 :tol 1 :category extents :variable fourth :units km"))
Note: "conc" is the string concatenation operator in Chicken Scheme.
Z 2d0b7733769155366e1dd761d7d7377e