Popup menu - %pm[menu_specification]

In this section:

This format code, %pm (Popup Menu), 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 construct 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.

      WINAPP
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
        c(i)=0
      ENDDO
      min=0.0D0
      max=100.0D0
      step=1.0D0
      enable=1
      mode=3
      c(mode)=1
      v1=0.0D0
      v2=1.0D0
      i=winio@('%ww[no_border,no_maxbox]%ca[Popup]&')
      i=winio@('%2.2ob[thin_panelled]&')
      i=winio@('%^10sl%cb&',v1,min,max,calc)
      i=winio@('  %dy&',0.3D0)
      i=winio@('%df%^4rf%cb&',step,v1,calc)
      i=winio@('%^10sl%cb&',v2,min,max,calc)
      i=winio@('  %dy&',0.3D0)
      i=winio@('%df%^4rf%cb&',step,v2,calc)
      i=winio@('%ff%ob[status,thin_panelled]&')
      i=winio@('%ta%dy%`7rf%cb&',0.3D0,r)
      i=winio@('%pm[#Multiply]&',        c(1),setmode)
      i=winio@('%pm[~#Divide,|]&',enable,c(2),setmode)
      i=winio@('%pm[#Add]&',             c(3),setmode)
      i=winio@('%pm[#Subtract]',         c(4),setmode)
      END
c ---------------------------------------
      INTEGER FUNCTION setmode()
      INCLUDE 'pm.ins'
      CHARACTER*10 item
      EXTERNAL calc
      INTEGER i,calc
      c(mode)=0
      item=clearwin_string@('CURRENT_MENU_ITEM')
      IF(item.EQ.'Multiply') mode=1
      IF(item.EQ.'Divide')   mode=2
      IF(item.EQ.'Add')      mode=3
      IF(item.EQ.'Subtract') mode=4
      c(mode)=1
      i=calc()
      setmode=2
      END
c----------------------------------------
      INTEGER FUNCTION calc()
      INCLUDE 'pm.ins'
      enable=1
      IF(v2.LT.1D-6)THEN
        enable=0
        IF(mode.EQ.2) mode=5
      ENDIF
      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)
      calc=2 
      END

See also %pm (Popup Menu).

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited