home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 600-699 / ff634.lha / APIG / apig33.lzh / newmenus2.rexx < prev    next >
OS/2 REXX Batch file  |  1992-03-11  |  5KB  |  152 lines

  1.  
  2. /* Example of hard coding a new menu structure  */
  3. /* I imagine you wont be doing much of this     */
  4.  
  5.  
  6.  x = addlib("apig.library",0,-30,0)
  7.  
  8.  portname = "nmex2_port"
  9.  p = openport(portname)
  10.  
  11.  call set_apig_globals()
  12.  
  13.  scrtitle    = "Hey Buddy, Yea You,  This is Your New Screen  !"
  14.  wintitle    = "APIG 3.1 Simple Menu Example"
  15.  winidcmp    = IDCMP_CLOSEWINDOW+IDCMP_MENUPICK
  16.  winflags    = WFLG_CLOSEGADGET+WFLG_DEPTHGADGET+WFLG_ACTIVATE
  17.  
  18.  scr = openscreen(0,0,640,400,4,4,5,LACE+HIRES,CUSTOMSCREEN,scrtitle)
  19.  
  20. scrvinfo     = GETVISUALINFO(scr)
  21. scrfont      = GETVALUE(scr,40,4,'p')
  22.  
  23.  /* open window */
  24. w1  = openwindow(portname,,,640,400,2,4,winidcmp,winflags,wintitle,scr,,,) 
  25. w1rptr = getwindowrastport(w1)
  26.  
  27. newmdata = ALLOCMEM(400,MEMF_CLEAR) /* allocate a NewMenu array  */
  28.                                     /* with 20 slots             */
  29.                                     /* sizeof of NewMenu = 20    */
  30. moffset = 0
  31.  
  32. call SETVALUE(newmdata,moffset+0,1,'n',NM_TITLE)  /* set nm_Type     */
  33. label = ALLOCMEM(80,MEMF_CLEAR)
  34. call export(label,"Project")
  35. call SETVALUE(newmdata,moffset+2,4,'p',label)     /* set nm_Label    */
  36. call SETVALUE(newmdata,moffset+6,4,'p',null())    /* set nm_CommKey  */
  37. call SETVALUE(newmdata,moffset+10,2,'n',0)        /* set nm_Flags    */
  38. call SETVALUE(newmdata,moffset+12,4,'n',0)        /* set nm_MutExc   */
  39. call SETVALUE(newmdata,moffset+16,4,'p',null())   /* set nm_UserData */
  40.  
  41. moffset = moffset + 20
  42. call SETVALUE(newmdata,moffset+0,1,'n',NM_ITEM)   /* set nm_Type     */
  43. i1 = ALLOCMEM(80,MEMF_CLEAR)
  44. call export(i1,"New")
  45. call SETVALUE(newmdata,moffset+2,4,'p',i1)        /* set nm_Label    */
  46.  
  47. moffset = moffset + 20
  48. call SETVALUE(newmdata,moffset+0,1,'n',NM_ITEM)   /* set nm_Type     */
  49. i2 = ALLOCMEM(80,MEMF_CLEAR)
  50. call export(i2,"Open")
  51. call SETVALUE(newmdata,moffset+2,4,'p',i2)        /* set nm_Label    */
  52.  
  53. moffset = moffset + 20
  54. call SETVALUE(newmdata,moffset+0,1,'n',NM_ITEM)   /* set nm_Type     */
  55. i3 = ALLOCMEM(80,MEMF_CLEAR)
  56. call export(i3,"Close")
  57. call SETVALUE(newmdata,moffset+2,4,'p',i3)        /* set nm_Label    */
  58.  
  59. moffset = moffset + 20
  60. call SETVALUE(newmdata,moffset+0,1,'n',NM_ITEM)   /* set nm_Type     */
  61. i4 = ALLOCMEM(80,MEMF_CLEAR)
  62. call export(i4,"Save")
  63. call SETVALUE(newmdata,moffset+2,4,'p',i4)        /* set nm_Label    */
  64.  
  65. moffset = moffset + 20
  66. call SETVALUE(newmdata,moffset+0,1,'n',NM_SUB)    /* set nm_Type     */
  67. i41 = ALLOCMEM(80,MEMF_CLEAR)
  68. call export(i41,"Save As New")
  69. call SETVALUE(newmdata,moffset+2,4,'p',i41)       /* set nm_Label   */
  70. i4K1 = ALLOCMEM(80,MEMF_CLEAR)
  71. call export(i4K1,"W")
  72. call SETVALUE(newmdata,moffset+6,4,'p',i4K1)       /* set nm_CommKey */
  73.  
  74. moffset = moffset + 20
  75. call SETVALUE(newmdata,moffset+0,1,'n',NM_SUB)     /* set nm_Type    */
  76. i42 = ALLOCMEM(80,MEMF_CLEAR)
  77. call export(i42,"Save As Old")
  78. call SETVALUE(newmdata,moffset+2,4,'p',i42)        /* set nm_Label */
  79. i4K2 = ALLOCMEM(80,MEMF_CLEAR)
  80. call export(i4K2,"S")
  81. call SETVALUE(newmdata,moffset+6,4,'p',i4K2)        /* set nm_CommKey */
  82.  
  83. moffset = moffset + 20
  84. call SETVALUE(newmdata,moffset+0,1,'n',NM_ITEM)   /* set nm_Type     */
  85. call SETVALUE(newmdata,moffset+2,4,'p',NM_BARLABEL) /* set nm_Label    */
  86.  
  87. moffset = moffset + 20
  88. call SETVALUE(newmdata,moffset+0,1,'n',NM_ITEM)   /* set nm_Type     */
  89. i5 = ALLOCMEM(80,MEMF_CLEAR)
  90. call export(i5,"Quit")
  91. call SETVALUE(newmdata,moffset+2,4,'p',i5)        /* set nm_Label    */
  92.  
  93. /* you get the idea, just use ADDTO_NEWMENU !!!  */
  94. /* and let APIG do all the grunt work            */
  95.  
  96. /* the point is CREATEMENUSA will try and validate newmdata as an */
  97. /* APIG nmdata structure, its gonna fail so CREATEMENUSA uses it  */
  98. /* as-is.                                                         */
  99.  
  100. realmenu = CREATEMENUSA(newmdata,null())
  101. call LAYOUTMENUSA(realmenu,scrvinfo,null())
  102.  
  103. x = SETMENUSTRIP(w1,realmenu)
  104.  
  105. exitme = 0
  106.  
  107. z = pitext(w1rptr,200,80,"A Simple Menu Example",1,0,JAM2,0)
  108.  
  109. do forever
  110.      x = waitpkt(portname)
  111.   
  112.      do forever 
  113.   
  114.         msg = '0000 0000'x
  115.         msg = getpkt(portname)
  116.  
  117.         if msg = '0000 0000'x then leave
  118.  
  119.         class = getarg(msg,0)
  120.       
  121.         if class = IDCMP_CLOSEWINDOW then exitme = 1
  122.  
  123.         x = reply(msg,0)  
  124.      end  
  125.  
  126.    if exitme = 1 then leave
  127.    
  128. end
  129.  
  130.  
  131. z = CLOSEWINDOW(w1)
  132.  
  133. z = FREEMENUS(realmenu)
  134.  
  135. call FREEVISUALINFO(scrvinfo)
  136.  
  137. z = CLOSESCREEN(scr)
  138.  
  139. z = FREEMEM(newmdata,400)
  140. z = FREEMEM(label,80)
  141. z = FREEMEM(i1,80)
  142. z = FREEMEM(i2,80)
  143. z = FREEMEM(i3,80)
  144. z = FREEMEM(i4,80)
  145. z = FREEMEM(i41,80)
  146. z = FREEMEM(i42,80)
  147. z = FREEMEM(i4K1,80)
  148. z = FREEMEM(i4K2,80)
  149. z = FREEMEM(i5,80)
  150. exit
  151.  
  152.