Silverfrost Logo About Us | Contact Us

Popup menu - %pm[menu_specification]

This format code is almost identical to %mn but a popup menu is activated when the right mouse button is pressed in the format window. Please refer to %mn for general information on how to contruct a menu.

In the example below a popup menu controls the mathematical operation carried out on two values that are provided by slider controls. The divide option is greyed out whenever the slider for the denominator gives zero. An attempt to divide by zero would cause a processor exception. This has been included to show how to use the tilde (~) character.

c-----Copy to pm.ins
      INCLUDE <windows.ins>
      INTEGER enable,mode,c(5)
      DOUBLE PRECISION r,v1,v2
      COMMON enable,mode,c,r,v1,v2
c-----End of pm.ins
      DOUBLE PRECISION min,max,step
      EXTERNAL calc,setmode
      INTEGER i,calc,setmode
      DO i=1,5
      i=winio@('  %dy&',0.3D0)
      i=winio@('  %dy&',0.3D0)
      i=winio@('%pm[#Multiply]&',        c(1),setmode)
      i=winio@('%pm[#Add]&',             c(3),setmode)
      i=winio@('%pm[#Subtract]',         c(4),setmode)
c ---------------------------------------
      INTEGER FUNCTION setmode()
      INCLUDE 'pm.ins'
      CHARACTER*10 item
      EXTERNAL calc
      INTEGER i,calc
      IF(item.EQ.'Multiply') mode=1
      IF(item.EQ.'Divide')   mode=2
      IF(item.EQ.'Add')      mode=3
      IF(item.EQ.'Subtract') mode=4
      INCLUDE 'pm.ins'
        IF(mode.EQ.2) mode=5
      IF(mode.EQ.1) r=v1*v2
      IF(mode.EQ.2) r=v1/v2
      IF(mode.EQ.3) r=v1+v2
      IF(mode.EQ.4) r=v1-v2
      IF(mode.EQ.5) r=0.0D0
      CALL window_update@(r)

See also %pm - Popup Menu.



Copyright © 1999-2017 Silverfrost Limited