OpenVMS Source Code Demos

HELLO_OPENVMS_WORLD.C

//================================================================================================
// title    : hello_openvms_world.c
// author   : Neil Rieck
// created  : 1999-09-30
// purpose  : to test the new DECC compiler on AlphaServer 4100
// vms build: cc   hello_openvms_world
//          : link hello_openvms_world
// DCL prep : junk = f$environment("DEFAULT")
//          : yada = "$"+ junk +"hello_openvms_world"
// DCL run  : yada 123 456 789
//================================================================================================
#define __NEW_STARLET	1			// enable new (strict) starlet for OpenVMS Alpha 7.0 and later
#include <stdio.h>				// standard i/o
#include <stdlib.h>				// standard library

int main(int argc, char *argv[])		//
{   int counter;				//
    printf("Hello OpenVMS World!\n");		//
    for (counter=1;counter<=3;counter++){	// loop 1 to 3
	printf(" line count: %d\n",counter);
    }
    printf("\nCommand Line Arguments:\n");	//
    printf("total number: %d\n",argc);		//
    for (counter=0;counter<argc;counter++){
	printf(" arg %d : %s\n",counter,argv[counter]);
    }
    printf("\nEnvironmentals:\n");		//
    printf("HOME: %s\n",getenv("HOME"));	//
    printf("TERM: %s\n",getenv("TERM"));	//
    printf("PATH: %s\n",getenv("PATH"));	//
    printf("USER: %s\n",getenv("USER"));	//
    //
    // "getenv" is a quick way to provide UNIX compatibility
    // "getenv" first checks the logical tables. If a logical
    // is not found, then the CLI symbol tables are checked
    //
    printf("ABC : %s\n",getenv("ABC"));		//
    printf("abc : %s\n",getenv("abc"));		//
    //
    //	the return code is stored in DCL symbol $STATUS ("$sho sym $STATUS")
    //
    // notes   : in the UNIX world, exiting with 0 means okay (anything else is an error)
    //           in the VMS world, the exit code is a little more complicated like so:
    //           0 000 warning
    //           1 001 success
    //           2 010 error
    //           3 011 informatinal
    //           4 100 fatal
    //           5 101 undefined
    //           6 110 undefined
    //           7 111 undefined
    return 1;					// exit with vms success
}