Xliff

Untitled

Oct 16th, 2015
636
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. . the menu window definition
  2. windef      init "WINDOW=MENUWIN, TITLE=Menu, SIZE=440:270, FIXSIZE"
  3.  
  4. . the menu panel resource definition
  5. menudef     init "PANEL=MENUPAN,SIZE=440:375":
  6.                 ",H=14,V=15,LISTBOX=10:200:250,INSERTORDER":
  7.                 ",H=228,LISTBOX=20:200:250,INSERTORDER"
  8.  
  9. . The menu file
  10. menufile    file var=81, text
  11. mnfilename  init "menudemo"
  12.  
  13. . the menu record (records in the menu file)
  14. menu        record
  15. rtype       char 1      . record type: 1 (main menu), 2 (submenu), X (chain pgm)
  16. text        char 80     . text or program name
  17.             recordend
  18.  
  19. . the GUI objects
  20. windev      device
  21. winpan      resource
  22. mainq       queue entries=100, size=100
  23.  
  24. . the main queue message
  25. msg         record
  26. name        char 8
  27. func        char 4
  28. item        char 5
  29. data        char 83
  30.             recordend
  31.  
  32. . various work variables
  33. programs    char @[,]
  34. progname    char 60
  35. work        char 65000
  36. type1count  int 3
  37. type2count  int 3
  38. type2text   char @[,]
  39. zero        int "0"
  40. seq         int "-2"
  41.  
  42.  
  43. . prepare and show the menu window, linking messages to the main queue
  44.     prep windev, windef
  45.     change windev, "statusbar"; " "
  46.     link windev, mainq
  47.     prep winpan, menudef
  48.     change winpan, "itemon"
  49.     change winpan, "lineon"
  50.     change winpan, "focuson"
  51.     link winpan, mainq
  52.     show winpan, windev
  53.  
  54. . show the user name and password dialog, then read and show menu items
  55.     call showdialog
  56.     call initmenu
  57.  
  58. . receive and process messages
  59.     loop
  60.         wait mainq
  61.         get mainq; msg
  62.  display msg
  63.         switch msg.name
  64.         case "MENUWIN "
  65.             call menuwindow
  66.         case "MENUPAN "
  67.             call menupanel
  68.         endswitch
  69.     repeat
  70.  
  71. . process a message from the menu window device
  72. menuwindow
  73.     switch msg.func
  74.     case "CLOS"
  75.         stop
  76.     endswitch
  77.     return
  78.  
  79. . process a message from the menu panel resource
  80. menupanel
  81.     switch msg.func
  82.     case "PICK"
  83.         call menupick
  84.     case "ITEM"
  85.         call menuitem
  86.     case "FOCS"
  87.         call menufocus
  88.     case "FOCL"
  89.         call menufocus
  90.     case "NKEY"
  91.         call menukeypress
  92.     endswitch
  93.     return
  94.  
  95. . process a PICK message from the menu panel resource
  96. menupick lroutine
  97.  
  98. i1  num 5
  99. i2  num 5
  100. err char 60
  101.  
  102.     if (msg.item = "   20")
  103.         query winpan, "status10"; i1
  104.         query winpan, "status20"; i2
  105.         trap menupickfail giving err if cfail
  106.         move programs[i1, i2] to progname
  107.         chain progname
  108.     endif
  109.     return
  110. menupickfail
  111.     change windev, "statusbar"; ("CHAIN FAILURE: " + progname + " " + err)
  112.     noreturn
  113.     return
  114.     endroutine
  115.  
  116. . process an ITEM message from the menu panel resource
  117. menuitem
  118.     change windev, "statusbar"; " "
  119.     if (msg.item = "   10")
  120.         call leftlistselectionchanged
  121.     endif
  122.     return
  123.  
  124. . process a FOCS message from the menu panel resource
  125. menufocus
  126.     if (msg.item = "   20")
  127.         if (msg.func = "FOCS")
  128.             change winpan, "selectline20"; "1"
  129.         else
  130.             change winpan, "deselectline20"
  131.         endif
  132.     endif
  133.     return
  134.  
  135. .
  136. . routine to handle key press
  137. .
  138. menukeypress lroutine
  139.  
  140.     if ((int (squeeze msg.data)) = 256)
  141.         if (msg.item = "   10")
  142.             change winpan, "FOCUS20"
  143.         else if (msg.item = "   20")
  144.             call menupick
  145.         endif
  146.     endif
  147.     return
  148.     endroutine
  149.  
  150. .
  151. . routine to handle a change in the highlighted left side menu
  152. .
  153. leftlistselectionchanged lroutine
  154.  
  155. i1  int 5
  156. i2  num 5
  157.  
  158.     query winpan, "status10"; i2
  159.     clear work
  160.     for i1 from 1 to type2count
  161.         break if (size type2text[i2, i1] < 1)
  162.         if (i1 != 1)
  163.             append ",", work
  164.         endif
  165.         append type2text[i2, i1], work
  166.     repeat
  167.     change winpan, "erase20"
  168.     reset work
  169.     change winpan, "minsert20"; *ll, work
  170.     return
  171.     endroutine
  172.  
  173. .
  174. . routine to read the menu file and initialize the lists
  175. .
  176. initmenu lroutine
  177.  
  178. i1          int 3
  179. i2          int 4
  180. twocount    int 3
  181. twosize     int "  -1"
  182. execsize    int "  -1"
  183.  
  184.     open menufile, mnfilename
  185. . count the type 1 records, find the maximum type 2 record count per type 1 record
  186.     reposit menufile, zero
  187.     loop
  188.         read menufile, seq; menu
  189.         break if over
  190.         move (length (chop menu.text)) to i1
  191.         if (menu.rtype = "1")
  192.             add 1 to type1count
  193.             if (twocount > type2count)
  194.                 move twocount to type2count
  195.             endif
  196.             clear twocount
  197.         else if (menu.rtype = "2")
  198.             if (i1 > twosize)
  199.                 move i1 to twosize
  200.             endif
  201.             add 1 to twocount
  202.         else if (menu.rtype = "X" or menu.rtype = "x")
  203.             if (i1 > execsize)
  204.                 move i1 to execsize
  205.             endif
  206.         endif
  207.     repeat
  208.     if (twocount > type2count)
  209.         move twocount to type2count
  210.     endif
  211.    
  212. . make an array to hold the text of the type 2 records
  213.     return if (type2count < 1)
  214.     clear work
  215.     append "C", work
  216.     append twosize, work
  217.     append "[", work
  218.     append type1count, work
  219.     append ",", work
  220.     append type2count, work
  221.     append "]", work
  222.     reset work
  223.     makevar work, type2text
  224.  
  225. . make an array to hold the names of the programs
  226.     clear work
  227.     append "C", work
  228.     append execsize, work
  229.     append "[", work
  230.     append type1count, work
  231.     append ",", work
  232.     append type2count, work
  233.     append "]", work
  234.     reset work
  235.     makevar work, programs
  236.  
  237. . read the file again, capture the text of the type 2 and X records,
  238. . and insert the text of the type 1 records into the left list.
  239.     reposit menufile, zero
  240.     clear i1, i2, work
  241.     loop
  242.         read menufile, seq; menu
  243.         break if over
  244.         if (menu.rtype = "1")
  245.             add 1 to i1
  246.             chop menu.text to menu.text
  247.             if (i1 != 1)
  248.                 append ",", work
  249.             endif
  250.             append menu.text, work
  251.             clear i2
  252.         else if (menu.rtype = "2")
  253.             add 1 to i2
  254.             chop menu.text to type2text[i1, i2]
  255.         else if (menu.rtype = "X" or menu.rtype = "x")
  256.             chop menu.text to programs[i1, i2]
  257.         endif
  258.     repeat
  259.     close menufile
  260.     reset work
  261.     change winpan, "minsert10"; *ll, work
  262.  
  263. . select the first line in the left list and populate the right list
  264.     change winpan, "locateline10"; "1"
  265.     call leftlistselectionchanged
  266.     return
  267.     endroutine
  268.  
  269. .
  270. . routine to show a dialog to ask for user name and password
  271. . for this demo, we only look for 'pass' in the password edit box
  272. .
  273. showdialog lroutine
  274.  
  275. logindef    init "DIALOG=LOGINDLG,SIZE=290:150, TITLE=Login":
  276.                 ",H=60,V=17,TEXT=Enter user name and password":
  277.                 ",H=49,V=48,TEXT=User name\:":
  278.                 ",H=145,EDIT=10::80":
  279.                 ",H=49,V=75,TEXT=Password\:":
  280.                 ",H=145,PEDIT=20::80":
  281.                 ",H=49,V=110,DEFPUSHBUTTON=10000:Login:80:24":
  282.                 ",H=161,ESCPUSHBUTTON=20000:Cancel:80:24"
  283. logdlg      resource
  284. logdlgq     queue size=50
  285. user        char 30
  286. pswd        char 30
  287.  
  288.     prep logdlg, logindef
  289.     link logdlg, logdlgq
  290.     show logdlg, windev
  291. . get messages from the dialog queue
  292.     loop
  293.         wait logdlgq
  294.         get logdlgq; msg
  295.         stop if (msg.func = "CLOS")
  296.         stop if (msg.item = "20000" and msg.func = "PUSH")
  297.         break if (msg.item = "10000" and msg.func = "PUSH")
  298.     repeat
  299.     hide logdlg
  300.     unlink logdlg
  301.     query logdlg, "STATUS10"; user
  302.     query logdlg, "STATUS20"; pswd
  303.     stop if (trim(pswd) != "pass")
  304.     close logdlg
  305.     return
  306.     endroutine
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×