using LoginPI.Engine.ScriptBase;
public class Logging : ScriptBase
{
void Execute()
{
// ----------- LOG -----------
// DESCRIPTION
// The log function will log to console if you are using the scriptrunner
// When using it as part of the PI appliance it logs to %temp%\LoginPI\Logs
// PARAMETER LIST
// 1: message is the message that's logged
// EXAMPLES
Log(message:"insert logging here");
// ----------- CreateEvent -----------
// DESCRIPTION
// The CreateEvent function will create a custom event in the event page on the Web interface.
// This can prove to be useful when using in a if statement.
// PARAMETER LIST
// 1: title: Describes the title of the custom event.
// 2: description: Here you can fill in a description of the event.
// EXAMPLES
CreateEvent(title:"Custom Event", description:"This is a custom event");
var Open = MainWindow.FindControl(title:"*Open*",continueOnError:true); // search for a window with the name "Open", continueOnError
if(Open != null){ // If the window is found Log a message and continue
Log("Go on with script");
}
else{
CreateEvent(title:"Custom Event", description:"This is a custom event");
Log("Continue with the rest of the script");
}
// ----------- WAIT -----------
// DESCRIPTION
// The Wait function will wait for an x amount of time in seconds before continuing with the script.
// PARAMETER LIST
// 1: seconds the amount of time in seconds to wait
// EXAMPLES
Wait(seconds:10);
Wait(seconds:0.5);
// ----------- GetEnvironmentVariable -----------
// DESCRIPTION
// GetEnvironmentVariable is used as the name suggest to retrieve an environment variable.
// The GetEnvironmentVariable can be stored in a variable to use multiple times in your script.
// Note that if a continueOnError is not set and if you do not have permissions to retrieve the variable, the script will stop.
// PARAMETER LIST
// 1: string: Name of the environment variable. e.q. temp
// 2: continueOnError, we can indicate if the engine should keep going with the next set of actions in case of a error. This could be especially helpful with if else statements.
// EXAMPLES
var TempEnv = GetEnvironmentVariable("temp", continueOnError:true);
Log ($"The environment path = {TempEnv}");
Type ($"{TempEnv}");
// ----------- ABORT -----------
// DESCRIPTION
// Abort is used to gracefully exit the script and throw an error message.
// This error will be shown as an Application Error in the events of PI3
// This comes in handy when using if else statements.
// PARAMETER LIST
// 1: error is the string of text which will be logged to events
// EXAMPLES
ABORT(error:"This will be logged to the events");
var Save = MainWindow.FindControl(title:"Save"); // search for a window with the name "Save"
if(Save != null){ // If the window is found Log a message and continue
Log("Go on with script");
}
else{
ABORT(error:$"Control {Save} could not be found"); // If it isn't found abort the script and log an application error to the events
}
}
}
Comments
0 comments
Please sign in to leave a comment.