<< 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; |
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; |
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; |
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:
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.