[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: interpreting ARGV[]
From: |
Miriam English |
Subject: |
Re: interpreting ARGV[] |
Date: |
Wed, 30 Oct 2024 07:49:26 +1000 |
And of course I realise a relatively simple solution straight after I
send the email. Here is a bit of example code:
c["black"] = 1
color = ARGV[1]
print c[color]
Of course this means I'll have to reformat the assignments in the
library file's function so it defines the associative array's values
instead of simple values, but I can live with that.
Am I missing an even simple solution?
Cheers,
- Miriam
On Wed, 30 Oct 2024 07:19:20 +1000
Miriam English <mim@miriam-english.org> wrote:
> Hi folks,
>
> I'm reading some colors into an awk program on the commandline using
> ARGV[]. I also have colors defined by their names in a library file
> function that consists of just a long list of color definitions
> reformatted from the one at /usr/share/X11/rgb.txt and written like
> this:
>
> red="255 0 0"
> white="255 255 255"
> black="0 0 0"
> ...
>
> I want the user to be able to input number values, like "255 0 0" or
> color names like "red". The problem is, when I get the name "red"
> through ARGV[] I can't find a way to reinterpret it as the number
> value. It seems like there should be an obvious and simple way to do
> that, but I can't see it. Can anybody enlighten me?
>
> Cheers,
>
> - Miriam
>
--
There are two wolves and they're always fighting.
One is darkness and despair. The other is light and hope.
Which wolf wins?
Whichever one you feed.
-- Casey in Brad Bird's movie "Tomorrowland"