<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Learn Postscript &#187; equal sign</title>
	<atom:link href="http://learnpostscript.wordpress.com/category/equal-sign/feed/" rel="self" type="application/rss+xml" />
	<link>http://learnpostscript.wordpress.com</link>
	<description>Programming Language</description>
	<lastBuildDate>Thu, 19 Mar 2009 17:55:53 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='learnpostscript.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/864cf471b5a5a7bd36d1cdc44c9cc488?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Learn Postscript &#187; equal sign</title>
		<link>http://learnpostscript.wordpress.com</link>
	</image>
			<item>
		<title>Named Variables</title>
		<link>http://learnpostscript.wordpress.com/2007/06/06/named-variables/</link>
		<comments>http://learnpostscript.wordpress.com/2007/06/06/named-variables/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 20:30:38 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[def]]></category>
		<category><![CDATA[equal sign]]></category>

		<guid isPermaLink="false">http://learnpostscript.wordpress.com/2007/06/06/named-variables/</guid>
		<description><![CDATA[Beside the integer and string types of operands, there is also a “name”
operand. You can recognize a literal name because it is preceded by a
slash. It can be any word you make up. Since all the built-in
commands in Postscript are lower case, you can’t go wrong by throwing
in an upper-case letter or two. Here are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&blog=1199990&post=4&subd=learnpostscript&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Beside the integer and string types of operands, there is also a “name”<br />
operand. You can recognize a literal name because it is preceded by a<br />
slash. It can be any word you make up. Since all the built-in<br />
commands in Postscript are lower case, you can’t go wrong by throwing<br />
in an upper-case letter or two. Here are some of the names I made up<br />
for a program we’ll be talking about later:</p>
<p><code>/pageHeight<br />
/pageWidth<br />
/countDown<br />
/countAcross<br />
/ProcessWhite<br />
/ProcessBlack<br />
/XtractCoords<br />
/MoveFrom<br />
/MoveTo<br />
/DrawMove<br />
/DrawPiece<br />
/DrawBoard</code></p>
<p>You get the idea.</p>
<p>Literal names are almost always first used with the <strong>def</strong> operator,<br />
which defines the name as a variable which contains an operand or a<br />
procedure. The Adobe reference manual says</p>
<p><em>key value</em> def</p>
<p>which means the <strong>def</strong> operator expects on the stack a key (the name) and<br />
a value (an operand or procedure) that you want the name to be<br />
associated with. The <strong>def</strong> operator doesn’t leave anything on the stack,<br />
but the result of using it is that your program will know the value of that variable when you use it. </p>
<p>For example, define three variables:</p>
<p><code>/firstNum 2 def<br />
/secondNum 3 def<br />
/MyProcedure { add } def<br />
</code></p>
<p>Notice that braces go around the add operator to defer it from<br />
executing immediately.</p>
<p>In the program, use the names without the slash prefix in order to<br />
execute them:</p>
<p><code>firstNum secondNum MyProcedure</code></p>
<p>is equivalent to saying</p>
<p><code>2 3 add</code></p>
<p>The number 5 will be left on the stack to do with as you will, such as<br />
storing it in another variable:</p>
<p><code>/theResult firstNum secondNum MyProcedure def</code></p>
<p>You want to increment theResult by two? Do this:</p>
<p><code>/theResult theResult 2 add def</code></p>
<p>or even</p>
<p><code>/bump { 2 add } def<br />
/theResult theResult bump def</code></p>
<p>By this time the value held by the variable <strong>theResult</strong> should be<br />
something like 9. How do you find out for sure? In our last lesson we<br />
introduced the &#8220;print&#8221; operator which is only good for printing<br />
strings. Another built-in procedure is the equal sign,<strong>=</strong>, which first converts<br />
anything into a string and then prints. Now is a good time to create a<br />
test file, save it as test.ps (or whatever), and run it thru your<br />
interpreter:</p>
<p><code>/firstNum 2 def<br />
/secondNum 3 def<br />
/MyProcedure { add } def<br />
/theResult firstNum secondNum MyProcedure def<br />
(theResult is ) print theResult =</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&blog=1199990&post=4&subd=learnpostscript&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/06/06/named-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e84d4622239b2738f7e572c9f43d88c2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Groggy</media:title>
		</media:content>
	</item>
	</channel>
</rss>