beep.java
/*
* Copyright (c) 2001-2005 Servertec. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* THIS NOTICE MUST NOT BE ALTERED NOR REMOVED.
*
* CopyrightVersion 1.0
*/
import stec.sfc.Win32.System;
import stec.sfc.Win32.BeepType;
public class beep
{
public static void main(String[] args) throws Exception
{
if(args == null)
{
syntax("type or duration and frequency were not specified.");
return;
}
if(args.length < 1)
{
syntax("type or duration and frequency were not specified.");
return;
}
if(args.length == 1)
{
int type = Integer.parseInt(args[0]);
switch(type)
{
case 0:
type = BeepType.BEEP;
break;
case 1:
type = BeepType.ASTERISK;
break;
case 2:
type = BeepType.EXCLAMATION;
break;
case 3:
type = BeepType.HAND;
break;
case 4:
type = BeepType.QUESTION;
break;
case 5:
type = BeepType.DEFAULT;
break;
default:
syntax("Invalid type: " + type);
return;
}
System.beep(type);
}
else
{
System.beep(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
}
}
static void syntax()
{
java.lang.System.out.println("usage: beep {| ");
java.lang.System.out.println();
java.lang.System.out.println("type:");
java.lang.System.out.println("0 = beep");
java.lang.System.out.println("1 = asterisk");
java.lang.System.out.println("2 = exclamation");
java.lang.System.out.println("3 = hand");
java.lang.System.out.println("4 = question");
java.lang.System.out.println("5 = default");
java.lang.System.out.println();
}
static void syntax(String message)
{
syntax();
if(message != null)
{
java.lang.System.out.println(message);
}
java.lang.System.out.println();
}
}