| Customize Help

JavaScript MILweb function reference



The following functions are available for creating a MILweb client with the JavaScript MILweb API.

To use these functions, you must load mil.js before loading your MILweb client application.

MilWeb.Mapp

The functions prefixed with MilWeb.Mapp make up the MILweb Application module. The MILweb Application module allows you to connect to a MILweb server, inquire the MIL identifiers of objects published by a MILweb server, and hook functions to connection and publishing events.

MilWeb.MappCloseConnection

This function closes a connection to a MILweb server application opened by MilWeb.MappOpenConnection.

This function is similar, but not identical, to the MIL function MappCloseConnection().

void MilWeb.MappCloseConnection (number ApplicationId)

ApplicationId

Specifies the client-side MIL application context identifier of the MILweb server application from which to disconnect. The application identifier must have been previously obtained, typically when connecting to the MILweb server application using MilWeb.MappOpenConnection.

MilWeb.MappControl

This function controls a specified application setting of a connected MILweb server application.

This function is similar, but not identical, to the MIL function MappControl().

void MilWeb.MappControl (number ApplicationId, number ControlType, number ControlValue)

ApplicationId

This parameter is reserved for future expansion and must be set to MilWeb.M_DEFAULT.

ControlType

Specifies the type of application setting to control. This parameter can be set to one of the following values:

MilWeb.M_CLOSE_CONNECTION

Closes the connection to the MIL object, specified by the ControlValue parameter.

Once the connection is closed (asynchronously), you will not be able to access the specified object until you reinquire its client-side MIL identifier using MilWeb.MappInquireConnection with MilWeb.M_OBJECT_ID and a new connection to the object is established (asynchronously).

MilWeb.M_ERROR

Controls whether to print error messages to the developer console of the web browser.

In this case, set ControlValue to one of the following values:

MilWeb.M_PRINT_DISABLE

Specifies not to print error messages to the developer console of the web browser.

If error printing is disabled, you can still check for errors. To do so, hook a function to application errors using MilWeb.MappHookFunction with MilWeb.M_ERROR. You can retrieve the error code within the hook-handler function, using MilWeb.MappGetHookInfo with MilWeb.M_ERROR.

MilWeb.M_PRINT_ENABLE

Specifies to print error messages to the developer console of the web browser.

This is the default value.

ControlValue

Specifies the setting's new value, or the identifier of the MIL object for which to close the connection.

MilWeb.MappGetHookInfo

This function retrieves information about the event that caused the hook-handler function to be called. This function should only be called within the scope of an application hook-handler function call (see MilWeb.MappHookFunction).

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MappGetHookInfo().

number MilWeb.MappGetHookInfo (number ApplicationId, number EventId, number InfoType, object UserVar)

ApplicationId

This parameter is reserved for future expansion and must be set to MilWeb.M_DEFAULT.

EventId

Specifies the client-side MIL application event identifier that was received by the hook-handler function.

InfoType

Specifies the type of information to get. This parameter can be set to one of the following number values:

MilWeb.M_OBJECT_ID

Retrieves the client-side MIL identifier of the MILweb server application or MIL object that generated the event.

Note that this client-side MIL identifier should only be used within the instance of your MILweb client application that called this function. The MILweb server application, and other instances of your MILweb client application, use a different MIL identifier to refer to the same object.

In this case, this function returns the client-side MIL identifier as a number.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MappHookFunction

This function allows you to attach or detach a user-defined function to a specified application event. Once a hook-handler function is defined and hooked to an event, it is automatically called when the event occurs.

This function is similar, but not identical, to the MIL function MappHookFunction().

void MilWeb.MappHookFunction (number ApplicationId, number HookType, string HookHandler, object UserData)

ApplicationId

Specifies the client-side MIL identifier of the MILweb server application to which to hook the function. The application identifier must have been previously obtained, typically when connecting to the MILweb server application using MilWeb.MappOpenConnection.

HookType

Specifies the event type. This parameter can be set to one of the following number values:

To detach (unhook) a function you previously hooked, combine the event type with MilWeb.M_UNHOOK (for example, MilWeb.M_CONNECT + MilWeb.M_UNHOOK).

MilWeb.M_CONNECT

Specifies to call the hook-handler function when your MILweb client application establishes a connection to the specified MILweb server application (or one of its published MIL objects).

You can use MilWeb.MappGetHookInfo with MilWeb.M_OBJECT_ID to learn which application or object connected, and MilWeb.MobjInquire with MilWeb.M_OBJECT_TYPE to learn the type of the application or object.

MilWeb.M_DISCONNECT

Specifies to call the hook-handler function when your MILweb client application disconnects from the specified MILweb server application (or one of its published MIL objects).

You can use MilWeb.MappGetHookInfo with MilWeb.M_OBJECT_ID to learn which application or object disconnected, and MilWeb.MobjInquire with MilWeb.M_OBJECT_TYPE to learn the type of the application or object.

MilWeb.M_ERROR

Specifies to call the hook-handler function when an error occurs while attempting to connected to the MILweb server application or published MIL object.

MilWeb.M_OBJECT_PUBLISH_WEB

Specifies to call the hook-handler function when the MILweb server application publishes or unpublishes a MIL object.

HookHandler

Specifies the name of the JavaScript function that should be called when the event occurs. This function should have the following prototype: function HookHandler(HookType, EventId, UserVar) .

UserData

Specifies the JavaScript object containing the user data that you want to make available to the hook-handler function. This object is passed to the hook-handler function, through its UserDataPtr parameter, when the specified event occurs. Omit this parameter if not used.

MilWeb.MappInquire

This function inquires about a specified application setting of a connected MILweb server application.

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MappInquire().

number MilWeb.MappInquire (number ApplicationId, number InquireType, object UserVar)

ApplicationId

Specifies the client-side MIL identifier of the MILweb server application of which to inquire the application settings. The application identifier must have been previously obtained, typically when connecting to the MILweb server application using MilWeb.MappOpenConnection.

InquireType

Specifies the type of application setting about which to inquire. This parameter can be set to one of the following number values:

MilWeb.M_ERROR

Inquires whether error messages are printed to the console of the web browser.

In this case, the function returns one of the following number values:

MilWeb.M_PRINT_DISABLE

Specifies that error messages will not be printed to the developer console of the web browser.

MilWeb.M_PRINT_ENABLE

Specifies that error messages will be printed to the developer console of the web browser.

MilWeb.M_WEB_CLIENT_INDEX

Inquires the index used by the MILweb server application to identify this instance of the MILweb client application.

This index is guaranteed not to change until this instance of the MILweb client application is disconnected. Note that this is not an iterable index; connected instances of your MILweb client are not guaranteed to be assigned sequential indices, and the indices do not shift when a client disconnects.

In this case, this function returns the index as a number.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MappInquireConnection

This function inquires about the MIL web objects published by a MILweb server application.

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MappInquireConnection().

number or number[] MilWeb.MappInquireConnection (number ApplicationId, number InquireType, string ControlFlag, number ExtraFlag, object UserVar)

ApplicationId

Specifies the client-side MIL identifier of the MILweb server application, the published objects about which to inquire. The application identifier must have been previously obtained, typically when connecting to the MILweb server application using MilWeb.MappOpenConnection.

InquireType

Specifies the type of published object information about which to inquire. This parameter can be set to one of the following number values:

MilWeb.M_WEB_PUBLISHED_LIST

Inquires the list of client-side MIL identifiers associated with all MIL objects that have been published by the MILweb server application.

In this case, this function returns an array of client-side MIL identifiers of the published objects as a number[].

Note that these client-side MIL identifier should only be used within the instance of your MILweb client application that called this function. The MILweb server application, and other MILweb client applications, use different MIL identifiers to refer to the same objects.

MilWeb.M_WEB_PUBLISHED_LIST_SIZE

Inquires the current number of MIL objects published by the MILweb server application.

In this case, the function returns the number of published objects as a number.

MilWeb.M_WEB_PUBLISHED_NAME

Inquires the client-side MIL identifier of a published MIL object associated with the name specified by the ControlFlag parameter. This name must have been previously associated with an object in the MILweb server application using MobjControl() with M_OBJECT_NAME.

When inquiring the client-side MIL identifier, this function also asynchronously creates a connection to the published object (if this connection had not already been made by a previous call to MilWeb.MappInquireConnection). Execution of your program will continue before this connection process has completed. Therefore, the application identifier returned by this function is not valid at the time it is returned; you must not use it with any MILweb function except MilWeb.MobjHookFunction. To know when the connection is made (or canceled due to an error), you can hook to these events using MilWeb.MobjHookFunction with MilWeb.M_CONNECT and MilWeb.M_ERROR , respectively. After the MilWeb.M_CONNECT event is generated, the client-side MIL identifier is valid and can be used with other MILweb functions.

In this case, this function returns the client-side MIL identifier as a number.

Note that this client-side MIL identifier should only be used within the instance of your MILweb client application that called this function. The MILweb server application, and other instances of your MILweb client application, use a different MIL identifier to refer to the same object.

ControlFlag

Specifies an attribute of the inquire operation to perform. If this parameter is not required for the inquire operation, it must be set to MilWeb.M_DEFAULT.

ExtraFlag

The Extraflag parameter is reserved for future use and must be set to MilWeb.M_NULL.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MappOpenConnection

This function initiates a connection to a local or remote computer running a MILweb server application. It returns the client-side MIL application context identifier of the MILweb server application, and optionally writes it in the data property of the object you pass to UserVar.

Note that this client-side MIL identifier should only be used within the instance of your MILweb client application that called this function. The MILweb server application, and other MILweb client applications, use a different MIL identifier to refer to the same application context.

The connection is created asynchronously, meaning that your program will continue to execute before the connection is established. Therefore, the application identifier returned by this function is not valid at the time it is returned; you must not use it with any MILweb function except MilWeb.MappHookFunction. To know when the connection is made or canceled due to an error, you can hook to these events using MilWeb.MappHookFunction with MilWeb.M_CONNECT and MilWeb.M_ERROR, respectively. After the MilWeb.M_CONNECT event is generated, the MIL identifier is valid and can be used with other MILweb functions.

Note that MilWeb.MappHookFunction requires that you pass the application identifier written to the UserVar parameter by this function. Therefore, you cannot hook to the connection event until after you have called MilWeb.MappOpenConnection (unless you hook to all application connection events by setting the ApplicationId parameter of MilWeb.MappHookFunction to MilWeb.M_DEFAULT). You should typically call MilWeb.MappHookFunction immediately after MilWeb.MappOpenConnection to ensure that the connection or error event is caught.

You can close the connection in your MILweb client application using MilWeb.MappCloseConnection.

This function is similar, but not identical, to the MIL function MappOpenConnection().

void MilWeb.MappOpenConnection (string URL, number InitFlag, number ControlFlag, object UserVar)

URL

Specifies the computer to which to connect, and if necessary, the listening port of the MILweb server application.

You must specify the prefix "ws://", followed by the domain name or IP address of the computer, optionally followed by the listening port number. For example, "ws://localhost:7861" or "ws://192.168.1.51:7861".

You can always use the domain name localhost to connect to a MILweb server application running on the local computer.

In your MIL application, you can set the listening port using MappControl() with M_WEB_CONNECTION_PORT. The default port is 7861.

InitFlag

This parameter is reserved for future expansion and must be set to MilWeb.M_DEFAULT.

ControlFlag

This parameter is reserved for future expansion and must be set to MilWeb.M_DEFAULT.

UserVar

Specifies the JavaScript object in which to write the MILweb server application identifier. The information is written to the data property of the object.

MilWeb.Mdisp

The functions prefixed with MilWeb.Mdisp make up the MILweb Display module. The MILweb Display module allows you to show a published display in an HTML5 canvas, enable interactive manipulation of a published display, and hook functions to display events (such as user interaction).

MilWeb.MdispControl

This function controls a specified display setting.

This function is similar, but not identical, to the MIL function MdispControl().

void MilWeb.MdispControl (number DisplayId, number ControlType, number ControlValue)

DisplayId

Specifies the client-side MIL identifier of the display. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

ControlType

Specifies the type of display setting to control. This parameter can be set to one of the values below:

MilWeb.M_INTERACTIVE

Sets whether the local user can interact with the display.

To learn the default keyboard controls, see M_KEYBOARD_USE.

In this case, set ControlValue to one of the following values:

MilWeb.M_DISABLE

Specifies that the local user cannot interact with the display.

Note that this instance of your MILweb client application will still generate mouse and keyboard events for the purposes of hooked functions. However, the events are not sent to the MILweb server application or other instances of your MILweb client application.

This is the default value.

MilWeb.M_ENABLE

Specifies that the local user can interact with the display, using a keyboard and mouse.

Only one connected instance at a time of the MILweb client application can enable this feature for the specified display. If another instance of the MILweb client application has this feature enabled for the specified display, this function has no effect.

MilWeb.M_UPDATE_WEB

Sets whether the MILweb server application should send updated images of this display to this instance of the MILweb client application.

To control updating of the display for all instances of the MILweb client application, use MdispControl() with M_UPDATE in the MILweb server application.

In this case, set ControlValue to one of the following values:

MilWeb.M_DISABLE

Specifies not to send updated images of the display.

MilWeb.M_ENABLE

Specifies to send updated images of the display. Also, the display is forced to update immediately.

This is the default value.

MilWeb.M_NOW

Forces an immediate update of the display. In this case, the display is updated even if MilWeb.M_UPDATE_WEB is set to MilWeb.M_DISABLE.

ControlValue

Specifies the setting's new value.

MilWeb.MdispGetHookInfo

This function retrieves information about the event that caused the hook-handler function to be called. This function should only be called within the scope of a display hook-handler function call (see MilWeb.MdispHookFunction).

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MdispGetHookInfo().

number MilWeb.MdispGetHookInfo (number EventId number InfoType, object UserVar)

EventId

Specifies the display event identifier that was received by the hook-handler function.

InfoType

Specifies the type of information to get. This parameter can be set to one of the following values:

MilWeb.M_DISPLAY

Retrieves the client-side MIL identifier of the display that generated the event.

In this case, this function returns the client-side MIL identifier as a number.

Note that this client-side MIL identifier should only be used within the instance of your MILweb client application that called this function. The MILweb server application, and other instances of your MILweb client application, use a different MIL identifier to refer to the same object.

MilWeb.M_MOUSE_POSITION_X

Retrieves the X-position of the cursor, in display coordinates (which might not be the same as canvas coordinates). This setting is only available if the function was called due to a MilWeb.M_MOUSE_MOVE event.

In this case, this function returns the X-position of the cursor as a number.

MilWeb.M_MOUSE_POSITION_Y

Retrieves the Y-position of the cursor, in display coordinates (which might not be the same as canvas coordinates). This setting is only available if the function was called due to a MilWeb.M_MOUSE_MOVE event.

In this case, this function returns the Y-position of the cursor as a number.

MilWeb.M_MOUSE_WHEEL_VALUE

Retrieves the value for the mouse wheel's rotation. This setting is only available if the function was called due to a MilWeb.M_MOUSE_WHEEL event.

In this case, this function returns the mouse wheel's rotation as a number.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MdispHookFunction

This function allows you to attach a user-defined function to a specified display event.

The hook-handler function is only called if a display event is generated in this instance of your MILweb client application. If a display event is generated in another instance, or in the MILweb server application, the hook-handler function is not called.

This function is similar, but not identical, to the MIL function MdispHookFunction().

void MilWeb.MdispHookFunction (number DisplayId, number HookType, string HookHandler, object UserVar)

DisplayId

Specifies the client-side MIL identifier of the display. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

HookType

Specifies the display-related event on which to hook the function. This parameter can be set to one of the following values:

To detach (unhook) a function you previously hooked, combine the event type with MilWeb.M_UNHOOK (for example, MilWeb.M_KEY_DOWN + MilWeb.M_UNHOOK).

MilWeb.M_KEY_DOWN

Specifies to call the hook-handler function each time the user presses a keyboard key, while the mouse cursor is in the display.

MilWeb.M_KEY_UP

Specifies to call the hook-handler function each time the user releases a keyboard key, while the mouse cursor is in the display.

MilWeb.M_MOUSE_LEFT_BUTTON_DOWN

Specifies to call the hook-handler function each time the user presses the left mouse button, while the mouse cursor is in the display.

MilWeb.M_MOUSE_LEFT_BUTTON_UP

Specifies to call the hook-handler function each time the user releases the left mouse button, while the mouse cursor is in the display.

MilWeb.M_MOUSE_MIDDLE_BUTTON_DOWN

Specifies to call the hook-handler function each time the user presses the middle mouse button, while the mouse cursor is in the display.

MilWeb.M_MOUSE_MIDDLE_BUTTON_UP

Specifies to call the hook-handler function each time the user releases the middle mouse button, while the mouse cursor is in the display.

MilWeb.M_MOUSE_RIGHT_BUTTON_DOWN

Specifies to call the hook-handler function each time the user presses the right mouse button, while the mouse cursor is in the display.

MilWeb.M_MOUSE_RIGHT_BUTTON_UP

Specifies to call the hook-handler function each time the user releases the right mouse button, while the mouse cursor is in the display.

MilWeb.M_MOUSE_MOVE

Specifies to call the hook-handler function each time the mouse cursor moves, while in the display.

MilWeb.M_MOUSE_WHEEL

Specifies to call the hook-handler function each time the user moves the mouse wheel, while the mouse cursor is in the display.

MilWeb.M_UPDATE_INTERACTIVE_STATE

Specifies to call the hook-handler function each time any MILweb client application enables or disables interactive control of the display (using MilWeb.MdispControl with MilWeb.M_INTERACTIVE).

MilWeb.M_UPDATE_WEB

Specifies to call the hook-handler function each time the contents of the display is changed.

HookHandler

Specifies the name of the JavaScript function that should be called when the event occurs. This function should have the following prototype: function HookHandler(HookType, EventId, UserVar) .

UserVar

Specifies the JavaScript object containing the user data that you want to make available to the hook-handler function. This object is passed to the hook-handler function, through its UserVar parameter, when the specified event occurs. Set this parameter to MilWeb.M_NULL if not used.

MilWeb.MdispInquire

This function inquires about a specified display setting.

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MdispInquire().

number MilWeb.MdispInquire (number DisplayId, number InquireType, object UserVar)

DisplayId

Specifies the client-side MIL identifier of the display. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

InquireType

Specifies the type of display setting about which to inquire. This parameter can be set to one of the following values:

MilWeb.M_IMAGE_HOST_ADDRESS

Inquires the pixel color values of the last bitmap image of the display transmitted by the MILweb server application. This information is returned as an array of type number, whereby the different color components of the pixel are stored in separate entries.

This setting does not return an address. It is named MilWeb.M_IMAGE_HOST_ADDRESS for consistency with the C/C++ MILweb API.

The pixel values are always returned in the RGBA packed format. The first 4 values store the color components of the first pixel (0,0) (starting with the R value), the next 4 values store the color components of the second pixel (1,0) and so on. You do not need to consider pitch when using this data.

Typically, you should hook a function to the display update event using MilWeb.MdispHookFunction with MilWeb.M_UPDATE_WEB, so that you can inquire new image data when the contents of the display changes.

In this case, this function returns the array of pixel values as a number[].

MilWeb.M_INTERACTIVE

Inquires whether the user can interact with the display.

This inquiry only returns information about this instance of your MILweb client application. If another instance of your MILweb client application is interactively controlling the specified display, this function returns MilWeb.M_DISABLE.

In this case, the function returns one of the following number values:

M_DISABLE

Specifies that the local user cannot interact with the display.

This is the default value.

M_ENABLE

Specifies that the local user can interact with the display, using a keyboard and mouse.

MilWeb.M_SIZE_X

Inquires the width of the displayed image, in pixels. Note that this is unrelated to the size of the HTML5 canvas in which the display is presented.

In this case, the function returns the width as a number.

MilWeb.M_SIZE_Y

Inquires the height of the displayed image, in pixels. Note that this is unrelated to the size of the HTML5 canvas in which the display is presented.

In this case, the function returns the height as a number.

MilWeb.M_UPDATE_WEB

Inquires whether the MILweb server application should send updated images of the display to this instance of the MILweb client application.

In this case, the function returns one of the following values:

MilWeb.M_DISABLE

Specifies not to send updated images of the display.

MilWeb.M_ENABLE

Specifies to send updated images of the display.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MdispMessage

This function genrates a mouse or keyboard event to be for the specified display. This manipulates the display if interactive control is enabled (using MilWeb.MdispControl with MilWeb.M_INTERACTIVE), and generates an event for the purposes of hooked functions. This allows you to simulate keyboard and mouse input.

Note that if interactive control is not enabled, the event is only generated for this instance of your MILweb client application (not for the MILweb server application). The event is never generated for other instances of your MILweb client application.

This function is not similar to any MIL function.

void MilWeb.MdispMessage (number DisplayId, number EventType, number MousePositionX, number MousePositionY, number EventValue, number CombinationKeys, number UserVar)

DisplayId

Specifies the client-side MIL identifier of the display for which to generate the event. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

EventType

Specifies the type of event to generate. This parameter can be set to one of the following number values:

MilWeb.M_KEY_DOWN

Specifies to generate an event as though a key was depressed.

In this case, set EventValue to the JavaScript standard keycode of the key to simulate being pressed.

MilWeb.M_KEY_UP

Specifies to generate an event as though a key was released.

In this case, set EventValue to the JavaScript standard keycode of the key to simulate being released.

MilWeb.M_MOUSE_LEFT_BUTTON_DOWN

Specifies to generate an event as though the left mouse button was depressed.

In this case, set EventValue to MilWeb.M_NULL.

MilWeb.M_MOUSE_LEFT_BUTTON_UP

Specifies to generate an event as though the left mouse button was released.

In this case, set EventValue to MilWeb.M_NULL.

MilWeb.M_MOUSE_MIDDLE_BUTTON_DOWN

Specifies to generate an event as though the middle mouse button was depressed.

In this case, set EventValue to MilWeb.M_NULL.

MilWeb.M_MOUSE_MIDDLE_BUTTON_UP

Specifies to generate an event as though the middle mouse button was released.

In this case, set EventValue to MilWeb.M_NULL.

MilWeb.M_MOUSE_MOVE

Specifies to generate an event as though the mouse was moved.

In this case, set MousePositionX and MousePositionY to the X and Y positions (in display coordinates) to which to simulate moving the mouse.

MilWeb.M_MOUSE_RIGHT_BUTTON_DOWN

Specifies to generate an event as though the right mouse button was depressed.

In this case, set EventValue to MilWeb.M_NULL.

MilWeb.M_MOUSE_RIGHT_BUTTON_UP

Specifies to generate an event as though the right mouse button was released.

In this case, set EventValue to MilWeb.M_NULL.

MilWeb.M_MOUSE_WHEEL

Specifies to generate an event as though the mouse wheel was moved.

In this case, set EventValue to the simulated value for the wheel's rotation. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotate backward, toward the user.

EventValue

Specifies additional information related to the event specified by the EventType parameter. If not used, set this parameter to MilWeb.M_NULL.

MousePositionX

Specifies the simulated position of the mouse cursor along the X-axis in display coordinates. If not used, set this value to MilWeb.M_DEFAULT.

MousePositionY

Specifies the simulated position of the mouse cursor along the Y-axis in display coordinates. If not used, set this value to MilWeb.M_DEFAULT.

CombinationKeys

Specifies which combination keys to simulate holding. This parameter can be set to MilWeb.M_DEFAULT (which specifies no combination keys), or any combination of the following number values:

MilWeb.M_KEY_ALT

Specifies the Alt key.

MilWeb.M_KEY_CTRL

Specifies the CTRL key.

MilWeb.M_KEY_SHIFT

Specifies the Shift key.

MilWeb.M_KEY_WIN

Specifies the Windows key.

UserVar

Reserved for future expansion and must be set to MilWeb.M_NULL.

MilWeb.MdispPan

This function associates X- and Y-panning offsets with the specified display. The selected image buffer is displaced on the display, from the top-left corner of the HTML5 canvas.

This pans the display for all instances of your MILweb client application. If you need to pan the image separately for each instance of your MILweb client application, you must allocate and publish a separate display for each instance and select the image to each display.

This function causes the MILweb server application to call the MIL function MdispPan().

void MilWeb.MdispPan (number DisplayId, number XOffset, number YOffset)

DisplayId

Specifies the client-side MIL identifier of the display. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

XOffset

Specifies the number of image pixels by which to pan an image buffer horizontally when it is displayed. Specify a positive offset value to displace the image to the left. This value can be a decimal fraction.

YOffset

Specifies the number of image pixels by which to pan an image buffer vertically when it is displayed. Specify a positive offset value to displace the image upwards. This value can be a decimal fraction.

MilWeb.MdispSelectWindow

Presents the display in a user-defined HTML5 canvas element.

Unlike MdispSelectWindow(), this function does not select an image to the 2D display. you must select an image to the display using MdispSelect() in the MILweb server application.

void MilWeb.MdispSelectWindow (number DisplayId, string CanvasElement)

DisplayId

Specifies the client-side MIL identifier of the display. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

CanvasElement

Specifies the id attribute of the user-defined HTML5 canvas element in which to present the display.

You manually set the id attribute when you create an HTML5 canvas element in the HTML file for your webpage. For example, you might include the following in the HTML file:

<canvas id="PlaceToShowAMILDisplay" width="1600" height="900"></canvas>

Note that the width and height of the displayed image is always the same as the width and height of the selected image buffer, regardless of the size of the HTML5 canvas. For more information, see the Size of a MILweb display subsection of the Fundamentals for creating your MILweb client application section earlier in this chapter.

MilWeb.MdispZoom

This function associates a zoom factor in X and/or in Y with the specified display.

This zooms the display for all instances of your MILweb client application. If you need to zoom the image separately for each instance of your MILweb client application, you must allocate and publish a separate display for each instance and select the image to each display.

This function causes the MILweb server application to call the MIL function MdispZoom().

void MilWeb.MdispZoom (number DisplayId, number XFactor, number YFactor)

DisplayId

Specifies the client-side MIL identifier of the display. This identifier must have been previously inquired, typically using MilWeb::MappInquireConnection with M_WEB_PUBLISHED_NAME.

XFactor

Specifies the zoom factor for the X-direction of the display. This value must be larger than 0. A value greater than 1.0 will zoom in, while a value less than 1.0 will zoom out.

YFactor

Specifies the zoom factor for the Y-direction of the display. This value must be larger than 0. This value must be larger than 0. A value greater than 1.0 will zoom in, while a value less than 1.0 will zoom out.

MilWeb.Mobj

The functions prefixed with MilWeb.Mobj make up the MILweb Object module. The MILweb Object module allows you to read and write messages in MIL message mailboxes, inquire the types of published objects, and hook functions to the update and connection events of published objects.

MilWeb.MobjGetHookInfo

This function retrieves information about the event that caused the hook-handler function to be called. This function should only be called within the scope of an object hook-handler function call (see MilWeb.MobjHookFunction).

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MobjGetHookInfo().

number MilWeb.MobjGetHookInfo (number EventId, number InfoType, object UserVar)

EventId

Specifies the client-side MIL object event identifier that was received by the hook-handler function.

InfoType

Specifies the type of information about the event to return. This parameter can be set to one of the following values:

MilWeb.M_OBJECT_ID

Retrieves the client-side MIL identifier of the object that generated the event.

In this case, this function returns the client-side MIL identifier as a number.

Note that this client-side MIL identifier should only be used within the instance of your MILweb client application that called this function. The MILweb server application, and other instances of your MILweb client application, use a different MIL identifier to refer to the same object.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MobjHookFunction

This function allows you to attach a user-defined function to a specified object-related event.

This function is similar, but not identical, to the MIL function MobjHookFunction().

void MilWeb.MobjHookFunction (number ObjectId, number HookType, string HookHandler, object UserVar)

ObjectId

Specifies the client-side MIL identifier of the object to which to hook the function. This identifier must have been previously inquired, typically using MilWeb.MappInquireConnection with MilWeb.M_WEB_PUBLISHED_NAME.

HookType

Specifies the object-related event to which to hook the function. This parameter can be set to one of the following number values:

To detach (unhook) a function you previously hooked, combine the event type with MilWeb.M_UNHOOK (for example, MilWeb.M_CONNECT + MilWeb.M_UNHOOK).

MilWeb.M_CONNECT

Specifies to call the hook-handler function when the connection to the MILweb object is established.

MilWeb.M_DISCONNECT

Specifies to call the hook-handler function when the connection to the MILweb server application is closed (either using MilWeb.MappCloseConnection, or MilWeb.MappControl with MilWeb.M_CLOSE_CONNECTION, or because of a network error).

MilWeb.M_UPDATE_WEB

Specifies to call the hook-handler function each time the contents of the object changes.

HookHandler

Specifies the name of the JavaScript function that should be called when the event occurs. This function should have the following prototype: function HookHandler(HookType, EventId, UserVar) .

UserVar

Specifies the JavaScript object containing the user data that you want to make available to the hook-handler function. This object is passed to the hook-handler function, through its UserVar parameter, when the specified event occurs. Omit this parameter if not used.

MilWeb.MobjInquire

This function inquires about general MIL object settings in a publishing application.

The returned value is the requested information.

This function is similar, but not identical, to the MIL function MobjInquire().

number or string MilWeb.MobjInquire (number ObjectId, number InquireType, object UserVar)

ObjectId

Specifies the client-side MIL identifier of the object. This identifier must have been previously inquired, typically using MilWeb.MappInquireConnection with MilWeb.M_WEB_PUBLISHED_NAME.

InquireType

Specifies the type of object setting about which to inquire. This parameter can be set to one of the values below.

MilWeb.M_OBJECT_NAME

Inquires the MIL object's user-defined name (set in the MILweb server application, using MobjControl() with M_OBJECT_NAME).

In this case, the function returns a string containing the name.

MilWeb.M_OBJECT_TYPE

Inquires the type of the specified MIL object.

In this case, the function returns one of the following number values:

MilWeb.M_APPLICATION

Specifies a MILweb server application.

MilWeb.M_DISPLAY

Specifies a MIL display (allocated using MdispAlloc() in the MILweb server application).

MilWeb.M_MESSAGE_MAILBOX

Specifies a MIL message mailbox (allocated using MobjAlloc() with M_MESSAGE_MAILBOX in the MILweb server application).

MilWeb.M_WEB_PUBLISH

Inquires what type of access to the object your MILweb client application has (set in the MILweb server application, using MobjControl() with M_WEB_PUBLISH).

In this case, the function returns one of the following number values:

MilWeb.M_READ_ONLY

Specifies that the object can only be read from by the MILweb client application.

MilWeb.M_READ_WRITE

Specifies that the object can be read from and written to by the MILweb client application.

UserVar

Specifies the JavaScript object in which to write the requested information. The information is written to the data property of the object. Since this function also returns the requested information, you can set this parameter to MilWeb.M_NULL.

MilWeb.MobjMessageRead

This function reads from a message sent to a message mailbox (previously published by a MILweb server application).

The returned value is the size of the message (the same value written in the data property of the object you pass to MessageOutSize).

This function is similar, but not identical, to the MIL function MobjMessageRead().

number MilWeb.MobjMessageRead (number MessageId, object MessageVar, number MessageInSize, object MessageOutSize, object MessageTag, object MessageStatus, number OperationFlag)

MessageId

Specifies the client-side MIL identifier of the message mailbox. This identifier must have been previously inquired, typically using MilWeb.MappInquireConnection with MilWeb.M_WEB_PUBLISHED_NAME.

MessageVar

Specifies the JavaScript object in which to write the contents of the message. If the read operation is successful, MessageVar.Data is set to the contents of the message (as an array of type number). Otherwise, it is set to MilWeb.M_NULL.

MessageInSize

This parameter is reserved for future expansion and must be set to MilWeb.M_NULL.

MessageOutSize

Specifies the JavaScript object in which to write the length of the message. If the read operation is successful, MessageOutSize.data is set to the length of the message (as a number). Otherwise, it is set to MilWeb.M_NULL.

If unused, set this parameter to MilWeb.M_NULL.

MessageTag

Optionally specifies the JavaScript object in which to write the user-defined tag sent with the message. If the read operation is successful MessageTag.Data is set to the message tag (as a number). Otherwise, it is set to MilWeb.M_NULL.

If unused, set this parameter to MilWeb.M_NULL.

MessageStatus

Specifies the JavaScript object in which to write the status of the read operation. MessageTag.Data is set to the one of the following number values:

MilWeb.M_NULL

Specifies that the read operation was not successful. The returned message has a length of 0.

MilWeb.M_SUCCESS

Specifies that the read operation is successful. The message is copied to MessageVar.Data.

OperationFlag

Reserved for future expansion and must be set to MilWeb.M_NULL.

MilWeb.MobjMessageWrite

This function writes a message to a message mailbox (previously published by a MILweb server application).

This function is similar, but not identical, to the MIL function MobjMessageWrite().

void MilWeb.MobjMessageWrite (number MessageId, string or number[] MessageData, number MessageLength, number MessageTag, number OperationFlag)

MessageId

Specifies the client-side MIL identifier of the message mailbox. This identifier must have been previously inquired, typically using MilWeb.MappInquireConnection with MilWeb.M_WEB_PUBLISHED_NAME.

MessageData

Specifies the message to send. You must set this parameter to a string, or an array of whole numbers.

If you set this parameter to a string, it is sent using UTF-8 encoding.

MessageLength

Specifies the length of the message to send, in number of characters or array elements. If the message specified by the MessageData parameter is longer than this length, the message is truncated. If the message is shorter than this length, the entire message is sent.

To send the entire message, you can also set this parameter to MilWeb.M_DEFAULT.

MessageTag

Specifies a user-defined tag to send with the message. You must set this parameter to a whole number.

OperationFlag

This parameter is reserved for future expansion and must be set to MilWeb.M_DEFAULT.