Groups | Search | Server Info | Login | Register
Groups > comp.lang.awk > #10006
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Kaz Kylheku <643-408-1753@kylheku.com> |
| Newsgroups | comp.lang.awk |
| Subject | Re: FIELDWIDTHS helper |
| Date | Sun, 10 Aug 2025 19:51:17 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 27 |
| Message-ID | <20250810124827.931@kylheku.com> (permalink) |
| References | <b208cecc-acca-4a4b-bce8-013c66682fcc@scorecrow.com> <107arnd$23gng$1@dont-email.me> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Sun, 10 Aug 2025 19:51:17 +0000 (UTC) |
| Injection-Info | dont-email.me; posting-host="5ff04a435e4cc704184760778f9af3ed"; logging-data="2229370"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1889/qBSE51s3RK3QpOKAjleQBPGlpyE2U=" |
| User-Agent | slrn/pre1.0.4-9 (Linux) |
| Cancel-Lock | sha1:PPyRERlXgrQIVCR0Igf6ZV/yAaA= |
| Xref | csiph.com comp.lang.awk:10006 |
Show key headers only | View raw
On 2025-08-10, Ed Morton <mortonspam@gmail.com> wrote:
> On 8/6/2025 4:23 AM, Bruce wrote:
>> The other day I found myself unable to count field sizes accurately so I
>> wrote this little helper.
>>
>> NR == 1 { # Pick a line
>> print
>> nf = split(FIELDWIDTHS, fw)
>> for (i = 1; i <= nf; i++)
>> for (j = 1; j <= fw[i]; j++)
>> printf "%d", (i % 10)
>> print ""
>> }
>
> FWIW you could do that without nested loops and without using
> FIELDWIDTHS so it'll work in any POSIX awk, not just gawk:
But I suspect that the program is intended to be a helper
when developing a program that uses FIELDWIDTHS.
Your portable example is no longer testing/displaying what the value of
FIELDWIDTHS is doing against the input data.
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Back to comp.lang.awk | Previous | Next — Previous in thread | Next in thread | Find similar
FIELDWIDTHS helper Bruce <07.013@scorecrow.com> - 2025-08-06 10:23 +0100
Re: FIELDWIDTHS helper Ed Morton <mortonspam@gmail.com> - 2025-08-10 14:25 -0500
Re: FIELDWIDTHS helper Kaz Kylheku <643-408-1753@kylheku.com> - 2025-08-10 19:51 +0000
Re: FIELDWIDTHS helper gazelle@shell.xmission.com (Kenny McCormack) - 2025-08-10 21:34 +0000
Re: FIELDWIDTHS helper Kaz Kylheku <643-408-1753@kylheku.com> - 2025-08-11 04:10 +0000
Re: FIELDWIDTHS helper Bruce <07.013@scorecrow.com> - 2025-08-15 08:14 +0100
Re: FIELDWIDTHS helper Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-08-11 11:51 +0200
csiph-web