Thread View: alt.lang.awk
2 messages
2 total messages
Started by Vilok Kusumakar
Mon, 07 Jun 1993 18:00
Calling AWK function from within SC as a macro !!
Author: Vilok Kusumakar
Date: Mon, 07 Jun 1993 18:00
Date: Mon, 07 Jun 1993 18:00
23 lines
1562 bytes
1562 bytes
Has anybody used @ext(se, e) feature of SC - the spreadsheet calculator ?
I am trying to call an awk script "days" like this
@ext(days, C1)
where cell C1 has data in the format - 01/05/92
The "days" script looks like this
awk '{print (substr($1,1,2)+((substr($1,4,2)-1)*30)+((substr($1,7,2)-92)*365))}' $1
It converts the above date format into number of days since 1/1/92. I
think the problem is that C1 is not getting passed as $1 to this awk
script. In @ext(se, e), how does "e" gets passed to external function
"se" ?
Any help will be appreciated.
--
Vilok Kusumakar OSI Protocols for tomorrow......
vilok@bnr.ca Bell-Northern Research, Ltd.
Phone: (613) 763-2273 P.O. Box 3511, Station C
Fax: (613) 765-4777 Ottawa, Ontario, K1Y 4H7
Re: Calling AWK function from within SC as a macro !!
Author: tbates
Date: Tue, 08 Jun 1993 00:55
Date: Tue, 08 Jun 1993 00:55
57 lines
2800 bytes
2800 bytes
Vilok,
I think the problem may be confusion about shell parameter use in awk.
The $1 on the command line would be the input file to the awk program. The $1
in the awk program would be the first field in the input file. I don't believe
this is what you intended.
Try this:
awk -v "date=$1" 'BEGIN {print (substr(date,1,2)+((substr(date,4,2)-1)*30)+((sub
str(date,7,2)-92)*365))}'
-v causes awk to assign an awk variable prior to execution of the awk
program.
"date=$1" assigns the awk variable date to the shell parameter $1.
Placing your awk program within a BEGIN section makes all this happen
without reading an input file.
Please note how date is used within the substr's; instead of $1.
I hope this helps.
Sincerely,
Tom
In article <1993Jun7.180006.2670@bmerh85.bnr.ca>, vilok@bmerh322.bnr.ca (Vilok Kusumakar) writes:
> Has anybody used @ext(se, e) feature of SC - the spreadsheet calculator ?
> I am trying to call an awk script "days" like this
>
> @ext(days, C1)
>
> where cell C1 has data in the format - 01/05/92
>
> The "days" script looks like this
>
> awk '{print (substr($1,1,2)+((substr($1,4,2)-1)*30)+((substr($1,7,2)-92)*365))}' $1
>
> It converts the above date format into number of days since 1/1/92. I
> think the problem is that C1 is not getting passed as $1 to this awk
> script. In @ext(se, e), how does "e" gets passed to external function
> "se" ?
>
> Any help will be appreciated.
>
> --
> Vilok Kusumakar OSI Protocols for tomorrow......
> vilok@bnr.ca Bell-Northern Research, Ltd.
> Phone: (613) 763-2273 P.O. Box 3511, Station C
> Fax: (613) 765-4777 Ottawa, Ontario, K1Y 4H7
--
Tom Bates IBM Austin
My opinions are my own. email: tbates@austin.ibm.com
"Tom, we need that Design Specification NOW! But captain, I'm typing
as fast as I can!"
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads