X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:reply-to:subject:references:from:to:message-id
	:date:mime-version:in-reply-to:content-type
	:content-transfer-encoding; q=dns; s=default; b=Hx6q+yav3ekFykNq
	u5OBOsapx1ywlDhqCHXa7JX8JeESQXm1WWT54qBW2BO5ADC0HxafJvcz8s4LWw9Y
	AWjOmMZIVusjI/BaLoV282mbv4eBf7DhEh78RjKAUMJGoYi9r0m7uoEHN9dklWMo
	DuMJAe8Xl7+J+M8yYJqnD1G31Bs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:reply-to:subject:references:from:to:message-id
	:date:mime-version:in-reply-to:content-type
	:content-transfer-encoding; s=default; bh=HD+xGKpIkb9ED4LXNSHZ5c
	WT0aw=; b=smu7UWBN7J9wzbHnq1qjA3kCr7x61+pPZTOOvTenLRkCfLI6/mDa+o
	t1oLjFViOckN/ybKIbNKclq0OQN6WLg341xRfk1I5cnxwYiND/GRuHX9xWkFzl7M
	8vek46TtbOOGk7swpTmloFBoBALrBW9poXdQkB+A3B1k3rwpzoE1g=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2
X-HELO: csmail.cs.umass.edu
Reply-To: moss@cs.umass.edu
Subject: Re: Awk not ouputting results via echo
References: <CAE3taFC=tjki1FTfbjyt+KnEGsWmrj63FMeBjgRswRwRSKdAWQ@mail.gmail.com> <56532F6A.3020906@cs.umass.edu> <CAE3taFDt50FGGCdQNnH5P84RCFt7t4j1SqyTTkVsbHf0XhVBDg@mail.gmail.com>
From: Eliot Moss <moss@cs.umass.edu>
To: Lester Anderson <arctica1963@gmail.com>, cygwin@cygwin.com
Message-ID: <56534492.80804@cs.umass.edu>
Date: Mon, 23 Nov 2015 11:53:38 -0500
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
MIME-Version: 1.0
In-Reply-To: <CAE3taFDt50FGGCdQNnH5P84RCFt7t4j1SqyTTkVsbHf0XhVBDg@mail.gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes

On 11/23/2015 11:24 AM, Lester Anderson wrote:
> Hi Eliot,
>
> I can see the logic of the function, but not sure how it is
> implemented from the section I have:

This has to do with bash and shells in general, and is not
specific to awk or to the cygwin Unix-like environment.

But what I meant was something like the code below.  When I
run it under bash in cygwin, I get this output:

-13.8013 1.80133 26.4979 40.5021 -12.2157 0.215728

Here's the code.  The use of the first echo is just to send one
line to awk, so it will run its code for that line.  You can drop
the echo and | if you put BEGIN just after the open quote of the
argument to awk, and add exit(0) in the awk code after awk's print
statement.

lon_min=-12
lon_max=0
lat_min=28
lat_max=39
R_d=167
R_i=20

bindvars () {
   lon_e_min=$1
   lon_e_max=$2
   lat_e_min=$3
   lat_e_max=$4
   lon_i_min=$5
   lon_i_max=$6
}

bindvars $(echo | awk "{R_t=6370;
        pi=3.14159;
        lat_av=(($lat_max+$lat_min)/2)*(pi/180.);
        lon_av=(($lon_min+$lon_max)/2);
        d_lat_e=($R_d/R_t)*180./pi;
        d_lon_e=($R_d/(R_t*cos(lat_av)))*180./pi;
        d_lat_i=($R_i/R_t)*180./pi;
        d_lon_i=($R_i/(R_t*cos(lat_av)))*180./pi;
        lon_e_min=$lon_min-d_lon_e;
        lon_e_max=$lon_max+d_lon_e;
        lat_e_min=$lat_min-d_lat_e;
        lat_e_max=$lat_max+d_lat_e;
        lon_i_min=$lon_min-d_lon_i;
        lon_i_max=$lon_max+d_lon_i;
        lat_i_min=$lat_min-d_lat_i;
        lat_i_max=$lat_max+d_lat_i;
        print 
lon_e_min,lon_e_max,lat_e_min,lat_e_max,lon_i_min,lon_i_max,lat_i_min,lat_i_max,lat_av*180./pi,lon_av;
}")
echo $lon_e_min $lon_e_max $lat_e_min $lat_e_max $lon_i_min $lon_i_max $lat_i_min $lat_i_max $lat_av 
$lon_av

Regards -- Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

