Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 591c941c2fdf0a32dc57bb5f10791cde > files > 610

gnuplot-doc-4.4.0-5.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>String variables, macros, and command line substitution</TITLE>
<META NAME="description" CONTENT="String variables, macros, and command line substitution">
<META NAME="keywords" CONTENT="gnuplot">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="gnuplot.css">

<LINK REL="previous" HREF="node50.html">
<LINK REL="up" HREF="node48.html">
<LINK REL="next" HREF="node52.html">
</HEAD>

<BODY >
<!--Navigation Panel-->
<A NAME="tex2html1463"
  HREF="node52.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1457"
  HREF="node48.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1453"
  HREF="node50.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1459"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1461"
  HREF="node467.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1464"
  HREF="node52.html">Syntax</A>
<B> Up:</B> <A NAME="tex2html1458"
  HREF="node48.html">Substitution and Command line</A>
<B> Previous:</B> <A NAME="tex2html1454"
  HREF="node50.html">Substitution of string variables</A>
 &nbsp; <B>  <A NAME="tex2html1460"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1462"
  HREF="node467.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION020213000000000000000"></A>
<A NAME="mixing_macros_backquotes"></A><A NAME="1368"></A>
<A NAME="substitution_mixing_macros_backquotes"></A>
<BR>
String variables, macros, and command line substitution
</H2>
The interaction of string variables, backquotes and macro substitution is
somewhat complicated.  Backquotes do not block macro substitution, so

<P>
<BR>
<PRE>
     filename = "mydata.inp"
     lines = ` wc --lines @filename | sed "s/ .*//" `
</PRE>
<BR>

<P>
results in the number of lines in mydata.inp being stored in the integer
variable lines. And double quotes do not block backquote substitution, so

<P>
<BR>
<PRE>
     mycomputer = "`uname -n`"
</PRE>
<BR>

<P>
results in the string returned by the system command <B>uname -n</B> being stored
in the string variable mycomputer.

<P>
However, macro substitution is not performed inside double quotes, so you
cannot define a system command as a macro and then use both macro and backquote
substitution at the same time.

<P>
<BR>
<PRE>
      machine_id = "uname -n"
      mycomputer = "`@machine_id`"  # doesn't work!!
</PRE>
<BR>

<P>
This fails because the double quotes prevent @machine_id from being interpreted
as a macro. To store a system command as a macro and execute it later you must
instead include the backquotes as part of the macro itself.  This is
accomplished by defining the macro as shown below.  Notice that the sprintf
format nests all three types of quotes.

<P>
<BR>
<PRE>
     machine_id = sprintf('"`uname -n`"')
     mycomputer = @machine_id
</PRE>
<BR>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1463"
  HREF="node52.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1457"
  HREF="node48.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1453"
  HREF="node50.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1459"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1461"
  HREF="node467.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1464"
  HREF="node52.html">Syntax</A>
<B> Up:</B> <A NAME="tex2html1458"
  HREF="node48.html">Substitution and Command line</A>
<B> Previous:</B> <A NAME="tex2html1454"
  HREF="node50.html">Substitution of string variables</A>
 &nbsp; <B>  <A NAME="tex2html1460"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1462"
  HREF="node467.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>

2010-08-17
</ADDRESS>
</BODY>
</HTML>