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.

 


 

Example 4: Dynamic channel for a countdown in an info

 

This example shows a script with which you can display a countdown in your Infoticker or pop-up.

Here are some examples:

countdown_band countdown_popup

 


program ClientScript;

var

  DDiffInDays: Double;

 

  IHours: Integer;

  IMinutes: Integer;

  IPos: Integer;

  ISeconds: Integer;

 

  SCountdown: String;

  SDateTime: String;

  SHours: String;

  SInfo: String;

  SMinutes: String;

  SNewInfo: String;

  SSeconds: String;

begin

  // Get the current info text

  SInfo := InfoClientValue('$Info$');

  SNewInfo := '';

 

  // Loop through the info text and replace the countdowns

  while (Length(SInfo) > 0) do

  begin

    // Find the next countdown

    IPos := Pos('[Countdown=', SInfo);

 

    // If no countdown was found, add the rest of the info text to the new info text

    if IPos = 0 then

    begin

      SNewInfo := SNewInfo + SInfo;

      SInfo := '';

    end

    else

    begin

      // Extract the countdown time

      SDateTime := Copy(SInfo, IPos + 11, 19);

      // Calculate the countdown

      DDiffInDays := StrToDatetime(SDateTime) - Now;

      // Format the countdown

      IHours := trunc(DDiffInDays * 24) mod 24;

      // Make sure the countdown hours don't go below 0

      if IHours < 0 then

        IHours := 0;

        SHours := IntToStr(IHours);

      // Add a leading zero if necessary

      if Length(SHours) = 1 then

        SHours := '0' + SHours;

        IMinutes := trunc(DDiffInDays * 24 * 60) mod 60;

      // Make sure the countdown minutes don't go below 0

      if IMinutes < 0 then

        IMinutes := 0;

        SMinutes := IntToStr(IMinutes);

      // Add a leading zero if necessary

      if Length(SMinutes) = 1 then

        SMinutes := '0' + SMinutes;

        ISeconds := trunc(DDiffInDays * 24 * 60 * 60) mod 60;

      // Make sure the countdown seconds don't go below 0

      if ISeconds < 0 then

        ISeconds := 0;

        SSeconds := IntToStr(ISeconds);

      // Add a leading zero if necessary

      if Length(SSeconds) = 1 then

        SSeconds := '0' + SSeconds;

        SCountdown := SHours + ':' + SMinutes + ':' + SSeconds;

 

      // Add the countdown to the new info text

      if Copy(SInfo, IPos - 4, 4) = '<!--' then

      begin

        SNewInfo := SNewInfo + Copy(SInfo, 1, IPos + 34 - 1) + SCountdown;

        Delete(SInfo, 1, IPos + 42 - 1);

      end

      else

      begin

        SNewInfo := SNewInfo + Copy(SInfo, 1, IPos - 1) + '<!--[Countdown=' + SDateTime + ']-->' + SCountdown;

        Delete(SInfo, 1, IPos + 31 - 1);

      end;

    end;

  end;

 

  // Set the new info text

  SetInfoText(SNewInfo);

  // Restart the info

  RestartInfo;

end.

 

To be able to display the countdown now, insert the following text in your info editor. The countdown counts down to the time specified here:


[Countdown=dd.mm.yyyy hh:ii:ss]

(dd=day mm=month yyyy=year hh=hour ii=minute ss=second)

 

An example of this would be: [Countdown=14.10.2024 17:00:00] This countdown counts down to 14.10.2024 17:00. The countdown depends on the respective computer time.