Command WR LOCK COMMAND

4D Write

WR LOCK COMMAND

version 6.5


WR LOCK COMMAND (area; cmdNumber; locked)

ParameterTypeDescription
areaLongint4D Write area
cmdNumberLongintNumber of the command to process
lockedInteger0=enables the execution
1=does not enable the execution

Description

The WR LOCK COMMAND command allows you to prevent the user from being able to execute the command whose number is passed in cmdNumber. This can concern either a menu command or a palette command. This command affects the user's access to the indicated command only in the 4D Write area referenced by area. Access to the command is unaffected in other 4D Write areas.

In the locked parameter, you can pass one of the following constants, found in the "WR Parameters" theme:

Constants (value)Description
wr enabled command (0)the command will be executed when it is called
wr locked command (1)the command will not execute when it is called and will be disabled
(grayed out) in the menus and palettes where it appears

Notes:

• Even if a command is locked, your code can still execute it using the WR EXECUTE COMMAND command.

WR ON COMMAND will not be called if the user tries to select a command that is disabled.

• When a menu or submenu is passed in cmdNumber, the menu and all its commands will be disabled (grayed out).

Although the commands of a disabled menu cannot be selected, keyboard equivalents or toolbar buttons can still be used. If you want to completely lock these commands, you must call WR LOCK COMMAND specifically for each menu item.

Note: The list of menus, commands and their reference is available in in the "WR Commands" constants theme. You can either pass a constant name or its values.

Examples

1. You want the designer to be the only user that can access the Design environment:

   If(Current user="Designer")
      WR LOCK COMMAND(Area;wr cmd insert 4D expression;wr enabled command)
   Else
      WR LOCK COMMAND(Area;wr cmd insert 4D expression;wr locked command)
   End if

2. If the user name is not "Guru", the user will not be allowed to create new documents:

   If(Form event=On load)
      If (Current user#"Guru")
         WR LOCK COMMAND(Area;wr cmd new;wr locked command)
      End if
   End if

See Also

Appendix B: Menu Item Numbers, WR ON COMMAND.