ftp.nice.ch/peanuts/GeneralData/Usenet/news/1990/CSN-90.tar.gz#/comp-sys-next/1990/Jun/Unix-Shell-version-of-NXRunAlertPanel

This is Unix-Shell-version-of-NXRunAlertPanel in view mode; [Up]


Date: Sun 08-Jun-1990 18:33:13 From: Unknown Subject: Unix Shell version of NXRunAlertPanel Below is a simple wrapper for the NextStep NXRunAlertPanel routine that allows it to be used from (interactive) Unix shell scripts (to provide consistent GUI alert panels across 'C' and shell executables ;-). The program, Alert, takes the message to display and three button labels as arguments. All arguments are optional--buttons are not drawn if labels are not supplied. The return value of NXRunAlertPanel is remapped into something useful for shell scripts; for the first (default) button (first button argument but first from the right on the panel), it returns '0' (success), otherwise '1' or '2' for the other buttons and '3' on error. Thus, you can do things like: Alert 'Are you sure?' 'Yes' 'No' 'Help' if ( $status == 2 ) ... I didn't include access to the 'printf' features of NXRunAlertPanel as you can provide the same functionality from within the script language, eg: Alert "Using the current time (`date`)" The 'title' of the alert panel is taken from the title of the program, so you can have a 'Warning' panel by doing 'ln -s Alert Warning' where Alert is stored (eg. /usr/local/bin). Comments and/or suggestions welcome, - Christopher /* File: Alert.m - (Interactive) Unix shell version of NXRunAlertPanel * * By: Christopher Lane (lane@sumex-aim.stanford.edu) * * Date: 7 June 1990 * * Copyright: 1990 by The Leland Stanford Junior University. * * Compile: cc -O -g -o Alert Alert.m -lNeXT_s -lsys_s */ #import <stdlib.h> #import <appkit/Panel.h> #import <appkit/Application.h> typedef enum {TITLE, MESSAGE, DEFAULT, ALTERNATE, OTHER, ARGC} ARGUMENTS; typedef enum {ALERTDEFAULT = EXIT_SUCCESS, ALERTALTERNATE, ALERTOTHER, ALERTERROR} RESULTS; void main(int argc, char *argv[]) { int result; NXApp = [Application new]; result = NXRunAlertPanel( (argc > TITLE) ? argv[TITLE] : NULL, (argc > MESSAGE) ? argv[MESSAGE] : NULL, (argc > DEFAULT) ? argv[DEFAULT] : NULL, (argc > ALTERNATE) ? argv[ALTERNATE] : NULL, (argc > OTHER) ? argv[OTHER] : NULL ); (void) [NXApp free]; switch(result){ case NX_ALERTDEFAULT: exit(ALERTDEFAULT); case NX_ALERTALTERNATE: exit(ALERTALTERNATE); case NX_ALERTOTHER: exit(ALERTOTHER); } exit(ALERTERROR); } ------- >From: giant@lindy.Stanford.EDU (Buc Richards)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.