xref: /trunk/main/xmerge/source/palmtests/bin/spose (revision cdf0e10c)
1#!/bin/perl
2#
3# spose - start pose
4#
5
6use Getopt::Std;
7
8# Location of needed files
9#
10$pose2_exe = $ENV{'POSE2_EXE'};
11$pose3_exe = $ENV{'POSE3_EXE'};
12$pose_prc = $ENV{'POSE_PRC'};
13
14
15if (getopts('23qmwo:r:d:v') != 1)
16{
17   &usage();
18}
19
20$apps_load = "";
21
22if ($opt_q)
23{
24   &add_app("$pose_prc/Quickword.PRC");
25}
26if ($opt_m)
27{
28   &add_app("$pose_prc/MiniCalc.prc");
29}
30if ($opt_w)
31{
32   &add_app("$pose_prc/WordSmith.PRC");
33}
34if ($opt_o)
35{
36   &add_app("$opt_o");
37}
38if ($opt_r)
39{
40   $run_prog .= "-run_app $opt_r";
41}
42if ($opt_d)
43{
44   $directory = $opt_d;
45   @files = `/bin/ls -1 $directory/*.pdb`;
46
47   for ($i=0; $i <= $#files; $i++)
48   {
49      $add_file = "$files[$i]";
50      chomp $add_file;
51      &add_app("$add_file");
52   }
53}
54
55if ($opt_3)
56{
57   $pose_exe = $pose3_exe;
58}
59else
60{
61   $pose_exe = $pose2_exe;
62}
63if ($pose_exe eq "")
64{
65    print "\nPose not found: Please set \n       POSE2_EXE\n    or POSE3_EXE\n";
66    exit 0;
67}
68if ($opt_v)
69{
70   print ("\n$pose_exe $apps_load $run_prog &\n\n");
71}
72else
73{
74   system ("$pose_exe $apps_load $run_prog &");
75}
76
77exit 0;
78
79sub usage
80{
81   print "\nUsage: getopt [ -m ] [ -q ] [ -w ] [ -o <PrcFile> ] [ -r <RunProg> ]\n";
82   print " -2            Runs pose version 3.2 [ current default ]\n";
83   print " -3            Runs pose version 3.3\n";
84   print " -d            Load all PDB files in specified directory\n";
85   print " -m            Load MiniCalc PRC file\n";
86   print " -q            Load QuickWord PRC file\n";
87   print " -w            Load WordSmith PRC file\n";
88   print " -o <PrcFile>  Other PRC files to load\n";
89   print " -r <RunProg>  Program to run on startup\n";
90   print " -v            Display the command instead of running\n\n";
91   exit(-1);
92}
93
94sub add_app
95{
96   my $new_app = $_[0];
97
98   if ($apps_load ne "")
99   {
100      $apps_load .= ",";
101   }
102   else
103   {
104      $apps_load = "-load_apps ";
105   }
106
107   $apps_load .= "$new_app";
108}
109