HP3000-L Archives

September 2013, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Lars Appel <[log in to unmask]>
Reply To:
Lars Appel <[log in to unmask]>
Date:
Wed, 11 Sep 2013 21:23:13 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
James B. Byrne wrote:
> :SETVAR V1 "31.1"
> :SETVAR v2 "4.7"
> :XEQ SH.HPBIN.SYS;INFO='-c "callci setvar result $(echo ""!V1 * !V2"" | bc |
> cut -f1 -d.)"'
> :SHOWVAR RESULT
> RESULT = 146

Hmmm....

I wonder if it would be more efficient to save a couple of process creations...

  :xeq /bin/awk "'BEGIN {print !V1 + !V2}'"
  35.8

  :xeq /bin/awk "'BEGIN {print int(!V1 + !V2)}'"
  35


One could use a TEMP file to capture and input the result...

  :xeq /bin/awk "'BEGIN {print int(!V1 + !V2)}'" >sum

  :input result <sum


Or you could let awk output the SETVAR command...

  :xeq /bin/awk "'BEGIN {printf(""setvar result,%i\n"", !V1 + !V2)}'" >cmd

  :xeq cmd


Of course, you could also waste a child process by awk invoking callci setvar...

  :xeq /bin/awk "'BEGIN {sum=int(!v1 + !v2); system(""callci setvar uv,"" sum)}'"


Okay okay... I'll shut up now ;)

Cheers, Lars.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2