How do I use system variables?

Mediator system variables are very helpful. They can give you information about the end user’s computer, the time and date, location of specific folders, etc. The system variables are particularly useful when you use Mediator’s programming functions.

You can access the list of all the system variables provided by Mediator by clicking the Expression button found in most programming dialogs.

All system variables begin with the character @.

All the Mediator system variables are listed below. The type of variable that the system variable returns is shown between brackets.

@ColorBits (integer)

Description: Returns the number of colors on the screen in bits. Values are 8, 15, 16, 24 or 32.

Usage: Identical to @Colors, but @ColorBits can also detect 32-bit color resolution.

@Colors (integer)

Description: Returns the number of colors on the screen. Typical values are 16, 256, 65536 or 16777216. Screen drivers with 256 or less colors normally have a palette. Returns 1 for 32-bit color resolution.

Usage: If your project is created for a specific color resolution, you can check the color resolution of the end user’s computer, and perhaps ask the user to change it before continuing. To check for color resolutions higher than 256 colors, you can use the condition:

IF @colors > 256 OR @colors < 2

This condition will be true for all color resolutions higher than 256 (including 32 bit).

@ComputerName (text)

Description: Returns the NetBIOS name of the local computer.

@CPU (integer)

Description: Returns a number representing the processor type i.e. 386, 486, 586. This is detected by a Windows call. @CPU also returns 586 for unknown CPU’s.

Usage: If you have created different versions of your project depending on the computer power of the end user, you can check the processor type first and run the corresponding project.

@CursorXpos and @CursorYpos (integer)

Description: Returns the X and Y position of the mouse pointer.

Usage: Determine if the pointer crosses a specific line or point or exits the screen. Then show an object, play a sound etc.

@Date (text)

Description: Returns a text string indicating today’s date. The string format varies according to the Windows installation of the computer on which Mediator is running. This means that if Windows is using the US standard, May 10th 2010 will give the text string 5-10-2010.

Usage: You can use the date system variables to show the date, day, month, year etc. in an input object.

@DateDay (integer)

Description: The number of the current day. If the date is May 10th 2010, the content of this variable will be 10.

Usage: Check the current date using @DateDay, @DateMonth and @DateYear (see below) to see if the demonstration period for your project has expired.

@DateMonth (integer)

Description: The number of the current month. If the date is May 10th 2010, the content of this variable will be 5, since May is the 5th month.

@DateYear (integer)

Description: Indicates the current year. If the date is May 10th 2010, the content of this variable will be 2010.

@DesktopDir (text)

Description: Returns the path to the desktop folder.

Usage: Gives you the exact path to the desktop of the end user’s computer. Use this for instance to place a file on the desktop during the project.

@DocDir (text)

Description: Returns the path to the folder containing the Mediator project file (.md8).

Usage: If you are planning to export a project containing actions or expressions that refer to external data files, using @DocDir to specify the location of these external data files will enable Mediator to find them when running the exported version. For this to work, you also need to copy these external data files in your Mediator project folder using the command Prepare | Additional Data Files before exporting the project.

If for instance your Mediator project file is stored in the folder “C:\MyProjects”, the expression @DocDir + “MyDocument.doc” will be equivalent to the path name “C:\MyProjects\MyDocument.doc”.

@Key (text)

Description: Returns the value of the last key pressed.

Usage: Check which key the user presses. Use an If action to set up actions depending on the key pressed last.

@OS (text)

Description: Returns a text string identifying the operating system used (“Windows 2000”, “Windows XP”, “Windows 2003”, “Vista”, “Unknown”).

Usage: Some commands may vary depending on the operating system used. Using @OS you can check the operating system, and then set up the corresponding commands with the If action.

@PageCount (integer)

Description: Returns the number of pages in the document.

Usage: Gives you an easy way to create a page counter, for instance with:

“You are now on page ” + @PageNum +” of ” + @PageCount

@PageName (text)

Description: Returns the name of the current page.

Usage: You can save the name of the current page for further use, e.g. if the end user leaves the project and wants to return to the same page later. Or you can place the value of @PageName in an INI file, and jump to the page the next time the user opens your project.

@PageNum (integer)

Description: Returns the number of the current page. The first page is number 1.

Usage: See @PageCount.

@PageRange (integer)

Description: This variable indicates the number of pages in the current chapter.

Usage: Gives you an easy way to create a page counter within the current chapter, for instance with:

“You are now on page ” + @PageNum +” of ” + @PageRange

@ProgramDir (text)

Description: Returns the path to the folder containing the runtime Mediator Viewer (md8rntm.exe).

Usage: Lets you place additional program files in the same folder as the md8rntm.exe file.

If you are planning to export a project containing actions or expressions that refer to external program files, using @ProgramDir to specify the location of these external program files will enable Mediator to find them when running the exported version. For this to work, you also need to copy these external program files in the same folder as the md8rntm.exe file using the command Prepare | Additional Program Files before exporting the project.

@ScreenXsize and @ScreenYsize (integer)

Description: Returns the width (X) and height (Y) of the screen indicated in the number of physical pixels.

Usage: Check if the end user’s screen resolution is high enough for your project. If not ask the end user to change it, or create a project for each screen resolution.

@SystemDir (text)

Description: Returns the path to the Windows system folder.

Usage: When you create INI files (or other files) you can choose to save them in the Windows system folder, enabling you to access them later.

WARNING: This is for advanced users only. Do not use if you are uncertain of the consequences.

@TempDir (text)

Description: Returns the path to the user’s Temp folder (a folder that stores files temporarily).

Usage: When you create INI files (or other files) you can choose to save them in the user’s temporary folder, enabling you to access them later. However, if the user deletes the temp folder, the files created in it are also deleted.

@ThisObject

Description: Is used in actions to refer to the object to which the action is applied.

Usage: If you have programmed an object to be hidden when clicked, you can use @ThisObject instead of the object name. This is especially useful if you copy the same action to many objects that all use this action. Also useful when creating Drag&Drop functionality.

@Time (text)

Description: Returns a text string holding the computer system time.

Format: “HH:MM:SS”, HH=hours, MM=minutes and SS=seconds.

Usage: You can use the time system variables to show the time, hour, minutes etc. in an input object.

@TimeHour (integer)

Description: Returns the specific “hour” number for the computer system time.

Usage: Check the time required by the user to perform a particular action using @TimeHour, @TimeMin and @TimeSec (see below).

@TimeMin (integer)

Description: Returns the specific “minute” number for the computer system time.

@TimeSec (integer)

Description: Returns the specific “second” number for the computer system time.

@Timer (integer)

Description: The number of seconds since Mediator was started

Usage: Use this for instance to calculate the time spent on a specific task by saving the @Timer value at the start of the task and subtracting this initial value from the value of @Timer at the end of the task.

@UserName (text)

Description: Returns the name of the user currently logged on the computer.

@WindowDir (text)

Description: Returns the path to the Windows folder.

Usage: When you create INI files (or other files) you can choose to save them in the Windows folder, enabling you to access them later.