postscript
Postscript
File extension: .ps
Script first line: %!PS-Adobe-2.0
Comment: % comment begins with percent symbol
Strings: (some text between parenthesis)
Numbers: 0 1 2 3 4 5 ...
Functions:
- def
/identifier value def
- exch
var1 var2 exch
- moveto
numberX numberY moveto
- mul
number1 number2 mul
- selectfont
/identifierFontFamily numberFontSize selectfont
- show
string show
Loops:
numberStart numberStep numberEnd {
instruction1
instruction2
} for
Example:
=======================
%!PS-Adobe-2.0
% comment
/n 6 def % define the variable n, set it to 6
/OCRA 30 selectfont
2 1 n {
100 mul 10 exch moveto
(Yan Morin) show
} for
=======================
Working with the stack:
1 1 3 { % for x = 1 to 3, step 1
% here the number (iteration) is on the stack
100 % push 100 on the stack
mul % multiply the last two numbers
10 % push 10 on the stack
exch % exchange the result of the multiplication with 10
moveto % moveto the last two numbers
} for