-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcase.ps
More file actions
33 lines (31 loc) · 1 KB
/
case.ps
File metadata and controls
33 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%!
% http://www.acumentraining.com/acumenjournal.html
% Case statements: see April 2001
% http://www.acumentraining.com/resources.html
% http://www.acumentraining.com/resources.html#PSResources
/case { % <<dict>> key => ---
{ % We'll do this in a stopped context
2 copy known not { % Does our key not exist?
pop /Default % Replace the key with "/Default"
2 copy known not { stop } if % If "Default" is missing, exit
} if
get exec % Get the proc and execute it
} stopped
} bind def
% Sample usage
% /CompanyProcs
% <<
% (Hot Doggie Portapotties) { (PottyProc) = }
% (Monstrous Heights Real Estate) { (MonstrousProc) = }
% (Out of My Mind, Inc.) { (Crazy) = }
% /Default { (Default) = }
% >> def
%
%
% [ (Hot Doggie Portapotties)
% (Albequerque Turkey)
% (Monstrous Heights Real Estate)
% (Out of My Mind, Inc.)
% (Gorilla My Dreams Parties)
% ]
% { CompanyProcs exch case } forall