flashMessageGeneric function displaying a message without stopping program execution
File Name : flashMessage.js Requirement : none Author : Branimir Petrovic Submitted : 03/09/2001 Category : Other // FileName: flashMessage(sMsg, nTime, sTitl, Type).js /////////////////////////////////////////////////////////////////////// if (WScript.ScriptName == "flashMessage.js") flashMessage("Greetings to ya all!", 3, "DEMOING SELF", "i"); // ======================== FUNCTION ================================== function flashMessage(sMsg, nTime, sTitl, Type) { // Author: Branimir Petrovic // Date: 25 July 2001 // // Will popup (if run by WScript.exe) or echo (if run by CScript.exe) // sMsg message nTime seconds. // // Optional parameter "Type" is not case sensitive, // can be a number or a string like: // // (number) 16 OR // "C", "CRITICAL", "CRITICAL_MARK" // "S", "STOP", "STOP_MARK" // // (number) 32 OR // "Q", "QUESTION", "QUESTION_MARK" // // (number) 48 OR // "E", EXCLAMATION", "EXCLAMATION_MARK" // // (number) 64 OR // "I", "INFORMATION", "INFORMATION_MARK" var STOP_MARK = 16; var QUESTION_MARK = 32; var EXCLAMATION_MARK = 48; var INFORMATION_MARK = 64; var nType; if (typeof(Type) == "undefined" ) { nType = 0; } else { if (isNaN(parseInt(Type))) { // "Type" is string, choose appropriate mark to show Type = Type.toUpperCase(); switch (Type) { case "C" : case "CRITICAL" : case "CRITICAL_MARK" : case "S" : case "STOP" : case "STOP_MARK" : nType = 16; break; case "Q" : case "QUESTION" : case "QUESTION_MARK" : nType = 32; break; case "E" : case "EXCLAMATION" : case "EXCLAMATION_MARK" : nType = 48; break; case "I" : case "INFORMATION" : case "INFORMATION_MARK" : nType = 64; break; default : nType = 0; } } else { // "Type" is Integer, choose appropriate mark to show nType = parseInt(Type); switch (nType) { case STOP_MARK : break; case QUESTION_MARK : break; case EXCLAMATION_MARK : break; case INFORMATION_MARK : break; default : nType = 0; } } } if (isCScript()) WScript.Echo(sMsg); else { var oShell = new ActiveXObject("WScript.Shell"); oShell.Popup(sMsg, nTime, sTitl, nType); } // when nTime==0 popup will not timeout function isCScript() { var sHost = WScript.FullName.toUpperCase(); var sScriptHost = sHost.indexOf("CSCRIPT.EXE")>0 ? "CSCRIPT.EXE":"WSCRIPT.EXE"; return (sScriptHost == "CSCRIPT.EXE"); } } // --- end of flashMessage() function ----------------------- |
|||||
![]()
|
|