Using variables to perform a calc

source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Using variables to perform a calc

Post by source1ben »

I am unable to get the following variables to perform a basic calc. fyi - I can get them to work in another program.

<readln "c:\data\filename.htm">
<$in = $ret>
<strstr "<" $in>
<$begincalc = $ret>
<strstr ">" $in>
<$endcalc = $ret>
<$length = (($endcalc - $begincalc) + 1)>
<substr $in $begincalc $length>
Final Results: $ret
</readln>

I am trying to parse out the beginning tag value in a file - i.e. <sometext>1234 more stuff</sometext> so the results should be = <sometext>

The scripting doesn't seem to recognize the addition or subtraction.

Any ideas ???

thx.

Ben
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Using variables to perform a calc

Post by source1ben »

More info - I am not using the readln finction in my version that works.

Ben
User avatar
John
Site Admin
Posts: 2623
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH

Using variables to perform a calc

Post by John »

You may be ending up with multiple values in $begincalc and $endcalc, which could be messing up the calculation. It looks like it would be much simpler just to use rex, e.g.

<rex "<\P=[^>]+" $in>
Final Results: <loop $ret>
$ret
</loop>
John Turnbull
Thunderstone Software
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Using variables to perform a calc

Post by source1ben »

Worked like a charm ! ...thx.

fyi - I also got my version to work by adding the 'ROW' keyword into the readln call.

Ben