Examples for Dynamic channels

<< Click to display Table of Contents >>

Navigation:  Channels > Dynamic Channels >

Examples for Dynamic channels

 

Example 1: Dynamic Channel for running applications

 

This example shows how you can address all users which are currently using a specific application (in this example: Notepad). The application is identified by checking the process list for a specific process name.

 


program ChannelScript;
var
// Variable Declaration
Res: Boolean;
// Used for defining the parameters and the result of the live-query
SType,SValue,SResult: String;
begin
// set type of query
SType := 'diProcessRuns';
// set value of query
SValue := 'notepad.exe';
// perform query and save result
SResult := DICV(SType,SValue);
// Check if result matches desired condition
Res := SResult = '1';
// in case desired condition is met
If Res = True then begin
// edit message
SetInfoText('Notepad is running on your system');
// display message
StartInfo;
end;
end.

 


 

Example 2: Dynamic Channel for Website / Application Titles

 

This example shows how you can identify application/window titles with a Dynamic Channel. in this example, the message is displayed repeatedly as long as a window/application title exists. Additionally, the message is stopped if it was displayed but the conditions aren't met anymore.

 


program ChannelScript;
var
// Variable declaration
Res: Boolean;
// used for defining the parameters and the result of the live-query
SType,SValue,SResult: String;
begin
// set type of query
SType := 'diTitleExists';
// set value of query, diTitelExists allows to use wildcards for checking
// any application/window title that matches
SValue := '*the*social*network*';
// perform query and save result
SResult := DICV(SType,SValue);
// check if result matches desired condition
Res := SResult = '1';
// if info was or is currently displayed but condition now is false
// then stop display
If ((InfoRan = true) OR (InfoRuns = true)) and (Res = false) then
StopInfo
else
// in case desired condition is met
If Res = True then begin
// edit message
SetInfoText('Using *the*social*network* is against workplace guidelines. Please quit the application NOW.');
// handle display of message, message is displayed repeatedly if user closes it
RestartInfo;
end;
end.

 


 

Example 3: Send Response from Dynamic Channels

 

In this example, we're using the Dynamic Channel for monitoring a certain item in the Infoclient.ini configuration file. The user is notified on the ongoing monitoring process, the result of the monitoring process is sent as a response to the Infoserver. Since the monitoring process is monitoring a static value, it should only run once. This can be achieved by setting the Dynamic Channel with type "Static" or by setting so in the Channel Script (as it is the case in this example).

 


program ChannelScript;
var
// variables declaration
Res: Boolean;
// used for defining the parameters of the live-query
SType,SValue,SResult,FileName,SectionItem: String;
begin
// initial condition: message was not yet displayed
If ((InfoRan = false) AND (InfoRuns = false)) Then begin
// set query-type
SType := 'diInifileValue';
// set location and filename
FileName := 'C:\Program Files\Cordaware\Infoband\Infoclient.ini';
// set SECTION [General] and ITEM Serverlist for query
SectionItem := 'General=Serverlist';
// concatenate FileName and SectionItem for valid query-value
SValue := FileName + ';' + SectionItem;
// perform query
// query gets the value of the item "Serverlist" in the [General] section
// if item is not present or has no value, then result is an empty string
// if item is present and has value, then result is the value
SResult := DICV(SType,SValue);
// send result of query as response with label 'Serverlist'
SendResponse(SResult,'Serverlist');
// Edit message
SetInfoText('Monitoring in progress - Please be patient');
// Notify user, sets InfoRuns to TRUE <- Precondition!!!
StartInfo;
end;
end.