<?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</title>
	<atom:link href="http://learnpostscript.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://learnpostscript.wordpress.com</link>
	<description>Programming Language</description>
	<lastBuildDate>Wed, 19 Jan 2011 18:52:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='learnpostscript.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Learn Postscript</title>
		<link>http://learnpostscript.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://learnpostscript.wordpress.com/osd.xml" title="Learn Postscript" />
	<atom:link rel='hub' href='http://learnpostscript.wordpress.com/?pushpress=hub'/>
		<item>
		<title>gsave &#8230; grestore</title>
		<link>http://learnpostscript.wordpress.com/2007/07/19/gsave-grestore/</link>
		<comments>http://learnpostscript.wordpress.com/2007/07/19/gsave-grestore/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 19:10:52 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[gsave]]></category>
		<category><![CDATA[lineto]]></category>

		<guid isPermaLink="false">http://learnpostscript.wordpress.com/2007/07/19/gsave-grestore/</guid>
		<description><![CDATA[To keep that string from affecting the path of the line, save the graphics state with a gsave command before showing the string. Then, restore it with grestore before the next lineto: %!PS 0 0 moveto 306 396 lineto % CURRENT POINT IS 306 396 gsave /Helvetica 10 selectfont (the effect of showing this string [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=9&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To keep that string from affecting the path of the line, save the graphics state with a <strong>gsave</strong> command before showing the string. Then, restore it with <strong>grestore</strong> before the next lineto:</p>
<p><code>%!PS<br />
0 0 moveto 306 396 lineto<br />
% CURRENT POINT IS 306 396<br />
gsave<br />
/Helvetica 10 selectfont<br />
(the effect of showing this string is isolated) show<br />
% CURRENT POINT IS AT END OF STRING (306+? 396)<br />
grestore<br />
% CURRENT POINT IS AT BEGIN OF STRING (306 396)<br />
612 792 lineto<br />
stroke<br />
showpage % END OF PROGRAM</code></p>
<p><a href="http://learnpostscript.files.wordpress.com/2007/07/gsavegrestore.gif"><img class="alignnone size-full wp-image-14" title="gsavegrestore" src="http://learnpostscript.files.wordpress.com/2007/07/gsavegrestore.gif?w=450&#038;h=582" alt="gsavegrestore" width="450" height="582" /></a></p>
<p>Get it? The current point (within the graphics state) at the end of the first line is saved to be used by the start of the second line. The effect of changing the current point by showing the string is thus negated.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/learnpostscript.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=9&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/07/19/gsave-grestore/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>

		<media:content url="http://learnpostscript.files.wordpress.com/2007/07/gsavegrestore.gif" medium="image">
			<media:title type="html">gsavegrestore</media:title>
		</media:content>
	</item>
		<item>
		<title>show Characters</title>
		<link>http://learnpostscript.wordpress.com/2007/07/19/characters/</link>
		<comments>http://learnpostscript.wordpress.com/2007/07/19/characters/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 19:06:35 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://learnpostscript.wordpress.com/2007/07/19/characters/</guid>
		<description><![CDATA[To paint a string of characters, use the show command, which requires a string argument, and expects the font face and size to have been selected: /Helvetica 10 selectfont (any string of text characters) show The show command creates a path of its own. Look what happens when you combine lines with text: %!PS 0 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=8&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To paint a string of characters, use the <strong>show</strong> command, which requires a string argument, and expects the font face and size to have been selected:</p>
<p><code>/Helvetica 10 selectfont<br />
(any string of text characters) show</code></p>
<p>The <strong>show</strong> command creates a path of its own. Look what happens when you combine lines with text:</p>
<p><code>%!PS<br />
0 0 moveto 306 396 lineto<br />
/Helvetica 10 selectfont<br />
(this adds to the path and moves the current point) show<br />
612 792 lineto<br />
stroke<br />
showpage % END OF PROGRAM</code><br />
<a title="show Characters" href="http://learnpostscript.files.wordpress.com/2007/07/show1.gif"><img src="http://learnpostscript.files.wordpress.com/2007/07/show1.thumbnail.gif?w=450" alt="show Characters" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/learnpostscript.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=8&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/07/19/characters/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>

		<media:content url="http://learnpostscript.files.wordpress.com/2007/07/show1.thumbnail.gif" medium="image">
			<media:title type="html">show Characters</media:title>
		</media:content>
	</item>
		<item>
		<title>Comments</title>
		<link>http://learnpostscript.wordpress.com/2007/07/19/comments/</link>
		<comments>http://learnpostscript.wordpress.com/2007/07/19/comments/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 19:06:02 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://learnpostscript.wordpress.com/2007/07/19/comments/</guid>
		<description><![CDATA[Now&#8217;s a good time to introduce a little documentation to your programming. Words appearing after a % are comments. (It&#8217;s just me, but I like to make them all caps.) Run the following program in Distiller or Preview to make a PDF file, or in Ghostscript to make an image. You&#8217;ll see that all the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=7&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now&#8217;s a good time to introduce a little documentation to your programming. Words appearing after a <strong>%</strong> are comments. (It&#8217;s just me, but I like to make them all caps.)</p>
<p>Run the following program in <strong>Distiller</strong> or <strong>Preview</strong> to make a <strong>PDF</strong> file, or in <strong>Ghostscript</strong> to make an image. You&#8217;ll see that all the lines end up running through the exact center of the page:</p>
<p><code>%!PS<br />
0 396 moveto 612 396 lineto % HORIZ LINE HALFWAY UP THE PAGE<br />
306 0 moveto 306 792 lineto % VERTICAL LINE HALFWAY OVER<br />
0 0 moveto 612 792 lineto % DIAGONAL LINE UP<br />
0 792 moveto 612 0 lineto % DIAGONAL LINE DOWN<br />
stroke % PAINT THE CURRENT PATH<br />
showpage % SEND TO OUTPUT</code></p>
<p><a href='http://learnpostscript.files.wordpress.com/2007/06/lines.gif' title='Lines'><img src='http://learnpostscript.files.wordpress.com/2007/06/lines.thumbnail.gif?w=450' alt='Lines' /></a></p>
<p>We need <strong>stroke</strong> to paint the current path. It expects nothing on the stack and doesn&#8217;t push anything onto the stack. The <strong>showpage</strong> command doesn&#8217;t expect any arguments either. It finally creates the <strong>PDF</strong> file or image.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/learnpostscript.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=7&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/07/19/comments/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>

		<media:content url="http://learnpostscript.files.wordpress.com/2007/06/lines.thumbnail.gif" medium="image">
			<media:title type="html">Lines</media:title>
		</media:content>
	</item>
		<item>
		<title>Line Graphics</title>
		<link>http://learnpostscript.wordpress.com/2007/06/07/line-graphics/</link>
		<comments>http://learnpostscript.wordpress.com/2007/06/07/line-graphics/#comments</comments>
		<pubDate>Thu, 07 Jun 2007 02:50:31 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[lineto]]></category>

		<guid isPermaLink="false">http://learnpostscript.wordpress.com/2007/06/07/line-graphics/</guid>
		<description><![CDATA[Lines are drawn from point to point on the page. The positions of each point are given by two coordinates, the x and y coordinates. They are the number of the point across the page horizontally from the left, and the number of the point vertically from the bottom, respectively. So, the bottom left point [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=5&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lines are drawn from point to point on the page. The positions of each point are given by two coordinates, the x and y coordinates. They are the number of the point across the page horizontally from the left, and the number of the point vertically from the bottom, respectively. So, the bottom left point is 0 0, and on a letter size page, the top right point is 612 792.</p>
<p>The <strong>lineto</strong> command is an operator requiring two operands, or arguments. Use it to make a line from the current point (set by the &#8220;moveto&#8221; command) to the point specified by the <strong>lineto</strong> arguments. Thus, to create a diagonal from the bottom left to the top right of the page:</p>
<p><code>0 0 moveto<br />
612 792 lineto</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/learnpostscript.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=5&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/06/07/line-graphics/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>
		<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 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=4&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<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>
<br /><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/gofacebook/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/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&amp;blog=1199990&amp;post=4&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></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>
		<item>
		<title>Reverse Polish Notation</title>
		<link>http://learnpostscript.wordpress.com/2007/06/05/reverse-polish-notation/</link>
		<comments>http://learnpostscript.wordpress.com/2007/06/05/reverse-polish-notation/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 21:16:54 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[exch]]></category>

		<guid isPermaLink="false">http://learnpostscript.wordpress.com/2007/06/05/reverse-polish-notation/</guid>
		<description><![CDATA[Like most programming languages, Postscript code consists of operators and operands. Consider the arithmatic operation 2 + 3 = 5. The operands are 2 and 3, and the operator is plus (+). In Postscript this same operation would be coded as 2 3 add The Postscript operation appears to be the reverse of “add 2 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=3&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Like most programming languages, Postscript code consists of operators and operands. </p>
<p>Consider the arithmatic operation 2 + 3 = 5. The operands are 2 and 3, and the operator is plus (+). In Postscript this same operation would be coded as</p>
<p><code>2 3 add</code></p>
<p>The Postscript operation appears to be the reverse of “add 2 and 3.” The reason for this is that Postscipt is a “stack” based language. The numbers 2 and 3 are “pushed” onto the stack and then subsequently “popped” off the stack by the add operator which expected to find its two operands, the integers, on the stack. The result, 5, is then pushed onto the stack waiting invisibly for the next operation.</p>
<p>Another “type” of operand is the string of characters. Where some programming languages might say</p>
<p><code>PRINT “Hello world!”</code></p>
<p>Postscript says:</p>
<p><code>(Hello world!) print</code></p>
<p>The term Polish in &#8220;reverse-polish notation&#8221; refers to the fact that operators and operands are kept to one side or another. Postscript finds the operands to the left. </p>
<p>For instance, the common notation (2 + 3) * (4 &#8211; 1) is stated in Postscript as:</p>
<p><code>2 3 add 4 1 sub mul</code></p>
<p>Notice how the results of add and sub are left waiting invisibly on the stack for the mul operator.  And the final result, 15, is also left waiting on the stack.</p>
<p>Another operator, <strong>exch</strong>, is very useful in Postscript because it <em>exchanges</em> the top two positions on the stack.</p>
<p><code>4 1 exch sub</code> </p>
<p>results in the number <em>minus three</em> being left on the stack. </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/learnpostscript.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=3&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/06/05/reverse-polish-notation/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>
		<item>
		<title>Hello World!</title>
		<link>http://learnpostscript.wordpress.com/2007/06/05/hello-world/</link>
		<comments>http://learnpostscript.wordpress.com/2007/06/05/hello-world/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 21:14:54 +0000</pubDate>
		<dc:creator>macenable</dc:creator>
				<category><![CDATA[Preview]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[There is an application, comes with Mac OS X, called Preview that interprets postscript code. With it, you can open a text file containing code like this: %!PS /fontSize 12 def /charRow 16 string def % BUFFER /Symbol fontSize selectfont 20 770 translate 0 0 moveto 0 1 15 {     /y exch 16 mul def [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=1&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is an application, comes with Mac OS X, called <strong>Preview</strong> that<br />
interprets postscript code. With it, you can open a text file containing code like this:</p>
<p><code>%!PS<br />
/fontSize 12 def<br />
/charRow 16 string def % BUFFER<br />
/Symbol fontSize selectfont<br />
20 770 translate<br />
0 0 moveto<br />
0 1 15 {<br />
    /y exch 16 mul def<br />
    0 1 15 {<br />
        charRow exch dup y add put<br />
        } for<br />
    gsave charRow show grestore<br />
    0 fontSize neg rmoveto<br />
    } for<br />
showpage</code></p>
<p>and <strong>Preview</strong> will automatically interpret the code and give you the image.  </p>
<p>The above code generates a page showing all the Symbol font characters:</p>
<p><img src="http://www.zapmap.com/learnpostscript/symbol.png" alt="Symbol character set" /></p>
<p>The <strong>Preview</strong> application is an interpreter, albeit not a full-featured interpreter like <strong>Distiller</strong>, but it&#8217;s very useful for running simple postscript programs.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/learnpostscript.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/learnpostscript.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/learnpostscript.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/learnpostscript.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/learnpostscript.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/learnpostscript.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/learnpostscript.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/learnpostscript.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/learnpostscript.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/learnpostscript.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnpostscript.wordpress.com&amp;blog=1199990&amp;post=1&amp;subd=learnpostscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnpostscript.wordpress.com/2007/06/05/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</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>

		<media:content url="http://www.zapmap.com/learnpostscript/symbol.png" medium="image">
			<media:title type="html">Symbol character set</media:title>
		</media:content>
	</item>
	</channel>
</rss>
