File: mkspeak.m

package info (click to toggle)
pgplot5 5.2.2-19
  • links: PTS
  • area: non-free
  • in suites: jessie-kfreebsd, wheezy
  • size: 7,060 kB
  • sloc: fortran: 39,792; ansic: 22,549; objc: 1,534; sh: 1,305; makefile: 386; perl: 234; pascal: 233; tcl: 190; awk: 51; csh: 25
file content (42 lines) | stat: -rw-r--r-- 1,315 bytes parent folder | download | duplicates (15)
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
34
35
36
37
38
39
40
41
42
#import "pgvSpeaker.h"
#import <stdio.h>
// POSIX defines sleep in <unistd.h> which does not exist on the NeXT, sigh.
unsigned int sleep(unsigned int seconds);

void mkspeak( id *retSpeaker)
//
// This routine creates a Speaker object for communicating with the
// PGPLOT viewer.  If there is no Listener then the pgview program is
// launched, and waits up to 11 secs to connect to the port.  Of course,
// this means the pgview must lie in your current path.
//
{
#include "sername.h"
//#include <stdlib.h>

    port_t thePort;
    id     mySpeaker;
    int    icnt;

    mySpeaker = [[pgvSpeaker alloc] init];
    thePort = NXPortFromName(PGV_SERVER_NAME, NULL);
    if (thePort==PORT_NULL) {
        printf("Launching pgview...\n");
//        system("open -a pgview &");
        system("open /LocalApps/pgview.app/pgview");
        icnt=1;
        while (thePort==PORT_NULL && icnt<21) {
            sleep(1);
            if((icnt/5)*5 == icnt) printf("waiting...\n");
            thePort = NXPortFromName(PGV_SERVER_NAME, NULL);
            icnt=icnt+1;
        } /* end while */
        if (thePort==PORT_NULL) {
            printf("Could not find port connected to pgview.\n");
            exit(1);
        } /* end if */
    } /* end if */
    [mySpeaker setSendPort:thePort];

    *retSpeaker=mySpeaker;
}