Received: by 10.224.189.16 with SMTP id dc16mr2847703qab.0.1350853195887; Sun, 21 Oct 2012 13:59:55 -0700 (PDT) Received: by 10.52.97.101 with SMTP id dz5mr1034472vdb.2.1350853195831; Sun, 21 Oct 2012 13:59:55 -0700 (PDT) Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!x14no3540842qar.0!news-out.google.com!r17ni43198841qap.0!nntp.google.com!x14no3540837qar.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.graphics.apps.gnuplot Date: Sun, 21 Oct 2012 13:59:55 -0700 (PDT) In-Reply-To: <0665cef1-fa95-4d16-aa5f-8030d8674cb7@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=132.170.112.134; posting-account=PuLrswoAAADOCumTdENk-35uZLyKLL68 NNTP-Posting-Host: 132.170.112.134 References: <0665cef1-fa95-4d16-aa5f-8030d8674cb7@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: accesssing shell array variable with a gnuplot loop index From: fh.faraz.hussain@gmail.com Injection-Date: Sun, 21 Oct 2012 20:59:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2807 Xref: csiph.com comp.graphics.apps.gnuplot:1423 Hello, I got this to work by using "${var[*]}":=20 http://unix.stackexchange.com/questions/52453/gnuplot-shell-variable-substi= tution-and-arrays Best Faraz On Saturday, October 20, 2012 10:22:33 PM UTC-4, fh.faraz...@gmail.com wrot= e: > Hello all, >=20 >=20 >=20 > I need to use shell variables in my gnuplot commands, for which I'm using= the here document style. I also need to use loops inside the gnuplot code.= Both these things are working. >=20 >=20 >=20 > Now -- I want to use a gnuplot for loop's index to access a shell array v= ariable. This is where I've been stuck all day. >=20 >=20 >=20 > I have something like this: >=20 >=20 >=20 > for ((i=3D0; i<=3D10; i++)) >=20 > do >=20 > var[$i] =3D i*10 >=20 > done >=20 >=20 >=20 > gnuplot<=20 > do for [j=3D1:10]{ >=20 > #need to access ${var[j]} somehow >=20 > val=3Dsprintf("${var[%d]", j) ##doesn't work >=20 > } >=20 > EOF >=20 >=20 >=20 > (Individual access like ${var[1]} works.)=20 >=20 >=20 >=20 > I thought of first storing the *name* of the shell variable somewhere and= then dereferencing it (using $), but didn't work.=20 >=20 >=20 >=20 > I suspect this may need using backquotes and/or expr, but am not sure. Th= e manual mentions the 'value' command which seems to be what would be requi= red here, but I couldn't get it to work. The 'evaluate' command also looks = relevant. I have been reading the bash and gnuplot manuals -- have learned = a lot the past few hours, but couldn't solve the problem. >=20 >=20 >=20 >=20 >=20 > Best >=20 > Faraz