home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / basic / mnusys21 / menulib.doc < prev    next >
Encoding:
Text File  |  1993-10-06  |  18.6 KB  |  565 lines

  1. Menulib for Menusys-PB
  2. Add-On Library Routines V2.1
  3. Documentation/Reference
  4. for SUBs/FUNCTIONs
  5.  
  6. Total SUBs/FUNCTIONs: 40 (38 SUBs, 2 FUNCTIONs)
  7.  
  8. --------------------------------------------------------------------------------
  9. * sub alertbox (msg$)  
  10.  
  11.  
  12. Prints a one-line alert message on the screen and
  13. waits for user to select OK with mouse or ENTER.
  14.  
  15. Example: CALL alertbox("File not Found")
  16.  
  17. --------------------------------------------------------------------------------
  18. * sub background (ch%)  
  19.  
  20.  
  21. Fills the screen with a special character, creating a
  22. background.  Uses colors in clr%, bckg%.
  23. Set chr% = 0 for black background, 1 for dark background, 2 for medium,
  24. 3 for light, 4 for pure
  25.  
  26. Example: CALL background(2)
  27.  
  28. --------------------------------------------------------------------------------
  29. * sub checkbox (title$, optn$(), optn%())  
  30.  
  31.  
  32. Lets the user pick from a list of options with the mouse cursor or
  33. the keyboard.  More than one option can be selected.  Set title$
  34. to the title to display on the list and DIM optn$() to the text
  35. for the list of options.  Upon return, optn%(x) will contain either
  36. a zero (user didn't select it) or a one (user selected it).  Subsequent
  37. calls to checkbox will retain the user's choices in optn%() if the array
  38. isn't erased or redimensioned.
  39.  
  40. Note: Use LBOUND of 1 for arrays (DIM 1 : X)
  41.  
  42. Example: title$="Select Options:" : REDIM optn$(1:3), optn%(1:3)
  43.      optn$(1)="Option 1":optn$(2)="Option 2":optn$(3)="Option 3"
  44.      CALL checkbox(title$, optn$(), optn%())
  45.  
  46. --------------------------------------------------------------------------------
  47. * sub choosebox (msg$(), choice%)  
  48.  
  49.  
  50. Prints a multi-line message on the screen in a box,
  51. and waits for user to select OK or CANCEL.
  52. Returns 0 (OK) or 1 (Cancel)
  53. Shortest string in msg$(x) should be >20.
  54. Returns with user's choice in choice%
  55.  
  56. Note: Use LBOUND of 1 for arrays (DIM 1 : X)
  57.  
  58. Example: DIM msg$(1:2)
  59.      msg$(1)="Would you like to"
  60.      msg$(2)="continue the current operation?"
  61.      CALL choosebox(msg$(), choice%)
  62.      if choice% = 1 then print "Nope!" : END
  63.  
  64. --------------------------------------------------------------------------------
  65. * sub choosedir (d$, ch$, rod%)  
  66.  
  67.  
  68. Changed in V2.0 (rod% parameter added).
  69. Lets a user select from a directory entry on the screen.  Includes
  70. the ability to switch to new drives/subdirectories.  Call with d$ =
  71. directory mask (normally "*.*").  Routine returns with user's choice
  72. of filename in ch$ (or null string in ch$ if cancelled).  Set rod% to
  73. 1 to Return to the Original Directory when the routine was first called,
  74. or 0 to stay at the user-selected directory.  If rod% = 1, the entire
  75. path of the user's choice will be returned, otherwise just the filename,
  76. and the default directory will be set to the user's choice.
  77. Set global variable flash% to 1 for "flashing" entry when selected
  78. with mouse or ENTER.
  79.  
  80. ROD% = 1: Stay at current directory/drive and return full path.
  81. ROD% = 0: Change to directory/drive selected by user and return filename.
  82.  
  83. Example: CALL choosedir("*.*", ch$, 0)
  84.  
  85. --------------------------------------------------------------------------------
  86. * sub getdirectory (fi$, atype%)  
  87.  
  88.  
  89. An internal routine used by CHOOSEDIR to get the current
  90. directory.  Requires shared variables within module.
  91. This routine may be made accessible to external programs
  92. in future versions of Menulib.
  93.  
  94. --------------------------------------------------------------------------------
  95. * sub getdisk (d%)  
  96.  
  97.  
  98. Returns drive code of current or default drive.
  99. 0 = A, 1 = B, 2 = C, Etc.
  100.  
  101. Example: CALL getdisk(d%)
  102.  
  103. --------------------------------------------------------------------------------
  104. * sub hscrollbar (starty%, startx%, length%)  
  105.  
  106.  
  107. Displays a horizontal "scroll bar" on the screen starting at position
  108. starty%/startx%, of length length% characters.  See the demo program
  109. for an example of hscrollbar.  This routine displays the scroll bar only-
  110. it does not control scrolling or any other related functions.  A future
  111. version of Menulib may more fully implement the hscrollbar feature.
  112.  
  113. Example: CALL hscrollbar(23, 1, 20)
  114.  
  115. --------------------------------------------------------------------------------
  116. * sub infobox (msg$())  
  117.  
  118.  
  119. Prints a multi-line message on the screen in a box,
  120. and waits for user to select OK with mouse or ENTER.
  121. This differs from alertbox in that you can display
  122. more than one line of text in the box.
  123.  
  124. Note: Use LBOUND of 1 for arrays (DIM 1 : X)
  125.  
  126. Example: DIM msg$(2)
  127.      msg$(1)="Disk Problem-"
  128.      msg$(2)="Select OK"
  129.      CALL infobox(msg$())
  130.  
  131. --------------------------------------------------------------------------------
  132. * sub inpbox (msg$, ip$, mx%, ll%, ul%)  
  133.  
  134.  
  135. Allows user input in a shadowed screen box.
  136.  
  137. Set msg$ to message, mx% to max length of user input,
  138. ll% = lowest ASCII value permitted for input,
  139. ul% = highest ASCII value permitted for input.
  140.  
  141. The string the user enters is returned in ip$.
  142.  
  143. If the user presses ENTER alone, ip$ will be set
  144. to CHR$(13).  If the user presses ESC or CANCEL,
  145. ip$ will be the null string ("").  ip$ is re-used
  146. as the default for the next user input, so you can
  147. control the "default" input by setting ip$ before
  148. calling this routine.
  149.  
  150. For example, to input a 3-digit number
  151. with "100" being the default value:
  152.  
  153. msg$="Enter Number:"
  154. mx% = 3:ip$ = "100"
  155. ll% = 48  :' ASCII value of "0"
  156. ul% = 57  :' ASCII value of "9"
  157. CALL inpbox(msg$, ip$, mx%, ll%, ul%)
  158. number% = val(ip$)
  159. print "You Entered ";ip%
  160.  
  161. --------------------------------------------------------------------------------
  162. * sub marklist (lst$(), mrk?())  
  163.  
  164.  
  165. New for V2.0.
  166. Similar to picklist, but lets the user "mark off"
  167. options, instead of selecting one.
  168. Call with lst$() = the list of items, mrk?() =
  169. the array of "markers" (1=marked, 0=not).
  170.  
  171. Example: CALL marklist (lst$(), mrk?())
  172.  
  173. --------------------------------------------------------------------------------
  174. * sub mcls  
  175.  
  176.  
  177. New for V2.0.
  178. Clears the screen and turns the mouse cursor
  179. on/off to prevent "mouse droppings."
  180.  
  181. Example: CALL mcls
  182.  
  183. --------------------------------------------------------------------------------
  184. * sub menupick (title$, mb$(), help$(), choice%)  
  185.  
  186.  
  187. Allows user to choose from a menu using either
  188. the mouse or the cursor keys.  This is the typical
  189. "vertical" menu displayed in the center of the screen,
  190. with a highlighted bar than can be moved with the
  191. mouse or crsr keys.  Screen is saved upon calling
  192. and automatically restored when done.  Set global
  193. variable flash% to 1 for "flashing" entry when
  194. selected with mouse or ENTER.
  195.  
  196. title$ = title to display on menu
  197. mb$() = text for menu choices
  198. help$() = one-line help message for each menu option
  199. choice% = choice returned by the user (0 if cancelled).
  200.  
  201. Set the cursor position (using LOCATE) to where you want
  202. the upper left corner of the menu before calling this
  203. routine.  help$() must be dimensioned to the same value
  204. as mb$(), but need not be defined.  For ONE helpline for
  205. all menu selections, set help$(1) to the text desired.
  206.  
  207. Example: title$="Select an Option"
  208.      redim mb$(2),help$(2)
  209.      mb$(1)="Option 1":mb$(2)="Option 2"
  210.      help$(1)="Select an option or press ESC to cancel"
  211.      CALL menupick(title$, mb$(), help$(), choice%)
  212.      print "You Picked ";choice%
  213.  
  214. --------------------------------------------------------------------------------
  215. * sub messagebox (title$, msg$())  
  216.  
  217.  
  218. This routine prints a multi-line message in a box and exits
  219. without delay.  Use for messages you want to remain on the
  220. screen.  Title$ is printed at the top of the box, followed by
  221. a horizontal line, followed by the text in msg$().  Upon exit,
  222. the cursor is located at the position corresponding to the upper
  223. left corner of the box.  You can use this to calculate where to
  224. print further messages inside the box.
  225.  
  226. Example: LOCATE 10, 10
  227.      redim msg$(1:1)
  228.      title$="Loading..."
  229.      msg$(1)="Record #:"
  230.      call messagebox(title$, msg$())
  231.      LOCATE csrlin+3, pos(0)+11
  232.      print "5";  'Print Record #
  233.  
  234. --------------------------------------------------------------------------------
  235. * sub mgetpos  
  236.  
  237.  
  238. Checks current position of mouse cursor and updates the
  239. corresponding global variables msy% and msx%.
  240.  
  241. Example: CALL mgetpos
  242.      PRINT msy%; msx%
  243.  
  244. --------------------------------------------------------------------------------
  245. * sub mgetpress (button%, numpresses&, ycc%, xcc%)
  246.  
  247.  
  248. Checks button indicated in button% (1 = left, 2 = right)
  249. and returns status of buttons in globals lb% and rb%, number
  250. of presses of specified button since last call (in numpresses&),
  251. and Y and X coordinates of mouse cursor the last time the specified
  252. button was pressed (in ycc% and xcc%).
  253.  
  254. Example: CALL mgetpress(button%, numpresses&, ycc%, xcc%)
  255.  
  256. --------------------------------------------------------------------------------
  257. * sub mgetrelease (button%, numreleases&, ycc%, xcc%)  
  258.  
  259.  
  260. Checks button indicated in button% (1 = left, 2 = right)
  261. and returns status of buttons in globals lb% and rb%, number
  262. of releases of specified button since last call (in numreleases&),
  263. and Y and X coordinates of mouse cursor the last time the specified
  264. button was released (in ycc% and xcc%).
  265.  
  266. Example: CALL mgetrelease(1, numreleases&, ycc%, xcc%)
  267.  
  268. --------------------------------------------------------------------------------
  269. * sub mousepick (ypos%(), xmin%(), xmax%(), pick%)  
  270.  
  271.  
  272. Checks arrays to see if mouse cursor is at positions specified
  273. in: ypos%(x) = line, xmin%(x) = minimum x pos. on line ypos%(x)
  274. and xmax%(x) = maximum x pos. on line ypos%(x).  If mouse cursor is
  275. at any of these locations (inclusive) AND left button is pressed,
  276. hilights desired area, waits til left button released, then returns
  277. with position number in pick%.
  278.  
  279. This routine requires quite a bit of setting up to use effectively,
  280. but essentially simulates a number of "buttons" on the screen that
  281. can be "pressed" with the mouse.  This routine does not utilize the
  282. keyboard at all, just the mouse, and you must draw the "buttons" on
  283. the screen first before calling the routine.  DIM the arrays to the
  284. number of "buttons" desired, Specify the Y position of each "button"
  285. in ypos%(), the minimum (lowest) X position of each "button" in
  286. xmin%(), and the maximum (highest) X position of each button in
  287. xmax%().
  288.  
  289. Example: DIM ypos%(1:5), xmin%(1:5), xmax%(1:5): '5 "buttons"
  290.      ... draw 5 "buttons" on the screen
  291.      ... (set ypos%(1) thru ypos%(5), same with xmin%()
  292.      and xmax%()
  293.      CALL mousepick(ypos%(), xmin%(), xmax%(), pick%)
  294.      
  295.      'Check to see if any of the "buttons" were pressed,
  296.      'if so, return the button number in pick%.
  297.  
  298. --------------------------------------------------------------------------------
  299. * sub mprint (mp$)  
  300.  
  301.  
  302. New for V2.0
  303. Same as normal PRINT, but turns off mouse cursor first if
  304. necessary.  Only prints strings, and does not work with PRINT
  305. USING.  No carriage return afterwards.
  306.  
  307. Example: mprint a$
  308. or     : call mprint (a$)
  309.  
  310. --------------------------------------------------------------------------------
  311. * sub msetpos  
  312.  
  313.  
  314. Uses global variables msy% and msx% to set a new
  315. position for the mouse cursor.  Change msy% and/or
  316. msx% before calling this routine.
  317.  
  318. Example: msy% = 1: msx% = 1: CALL msetpos
  319.  
  320. --------------------------------------------------------------------------------
  321. * sub mwaitpress
  322.  
  323.  
  324. Waits for a Mouse Button to be Pressed.
  325.  
  326. Example: CALL mwaitpress
  327.  
  328. --------------------------------------------------------------------------------
  329. * sub mxbounds(mn%, mx%)  
  330.  
  331. Sets minimum and maximum x-axis boundaries for mouse cursor
  332. movement.  In other words, confines the mouse cursor to a
  333. certain range of (horizontal) columns on the screen.
  334.  
  335. Example: CALL mxbounds(3, 77)
  336.  
  337. --------------------------------------------------------------------------------
  338. * sub mybounds (mn%, mx%)  
  339.  
  340.  
  341. Sets minimum and maximum y-axis boundaries for mouse cursor
  342. movement.  In other words, confines the mouse cursor to a
  343. certain range of (vertical) rows on the screen.
  344.  
  345. Example: CALL mybounds(2, 24)
  346.  
  347. --------------------------------------------------------------------------------
  348. * function pathstring$  
  349.  
  350.  
  351. Returns current disk/path in a string of the
  352. form C:\QB\EXE\ ... Trailing backslash included.
  353. Updated for Menusys 2.0 using curdir$ function.
  354.  
  355. Example: PRINT pathstring$
  356.  
  357. --------------------------------------------------------------------------------
  358. * sub picklist (lst$(), choice%)  
  359.  
  360.  
  361. Lets the user pick from a long list of options in a window, sizing
  362. and scrolling the window as necessary.  Set lst$() to the text for
  363. the list.  User's choice is returned in choice% (0 if cancelled).
  364. Set global variable flash% to 1 for "flashing" entry when selected
  365. with mouse or ENTER.
  366.  
  367. Example: DIM lst$(100)
  368.      ... Read in text file to lst$(x)
  369.      CALL picklist(lst$(), choice%)
  370.      PRINT "You Picked ";choice%
  371.  
  372. --------------------------------------------------------------------------------
  373. * sub printborder  
  374.  
  375.  
  376. Prints a border around the text screen -
  377. See demo program for example usage.
  378.  
  379. Example: CALL printborder
  380.  
  381. --------------------------------------------------------------------------------
  382. * sub printtitle (title$, starty%, hilight%)  
  383.  
  384.  
  385. Prints a title on the screen, either highlighted
  386. or not highlighted.  See the demo program (title
  387. is printed one line below the menu bar at the top).
  388.  
  389. Example: CALL printtitle("Program.dat", 20, 1)
  390.  
  391. --------------------------------------------------------------------------------
  392. * sub radiobox (title$, optn$(), choice%)  
  393.  
  394.  
  395. Displays a "radio button box" and lets user select one
  396. option from a list of options.  Set title$ to title of
  397. radio button box, optn$() to the options.  User's choice
  398. is returned in choice%.  Use instead of checkbox if only
  399. one option is possible out of a list of many.
  400. If cancelled (with ESC), choice% = 0.
  401.  
  402. Example: DIM optn$(3)
  403.      optn$(1) = "Option 1"....
  404.      CALL radiobox("Pick One",optn$(), choice%)
  405.      PRINT "You Chose ";choice%
  406.  
  407. --------------------------------------------------------------------------------
  408. * sub screenedit (x1%, x2%, y1%, y2%, ky$)  
  409.  
  410.  
  411. An advanced routine that allows a user to edit a portion of the
  412. screen, using all the normal cursor keys and editing controls.
  413.  
  414. x1%, x2% = Minimum and Maximum X Positions allowed (1-80).
  415. y1%, y2% = Minimum and Maximum Y Positions allowed (1-25).
  416. ky$ = keypress returned (if ESC or a scancode key is
  417. pressed that the routine doesn't recognize).
  418.  
  419. Example: CALL screenedit(1, 80, 1, 25, ky$)
  420.  
  421. See the MNSDEMO.BAS program for an example of how screenedit
  422. can be used.
  423.  
  424. --------------------------------------------------------------------------------
  425. * sub screenrecall(scn%)  
  426.  
  427.  
  428. New for V2.0
  429. Recalls a screen previously saved with SCREENSTORE.
  430. See SCREENSTORE for details on how to use.
  431.  
  432. Example: CALL screenrecall(4)
  433.  
  434. --------------------------------------------------------------------------------
  435. * sub screenstore(scn%)  
  436.  
  437.  
  438. New for V2.0
  439. Stores a screen in the global buffer variable
  440. SCRNBUF?.  Set the second dimension of SCRNBUF?
  441. to the highest value desired (depending on how many
  442. screens you want to store).  It's recommended you
  443. don't store to screens 0-3, as these are reserved by
  444. Menusys/Menulib.  For example, you could use:
  445. DIM scrnbuf?(1:4096, 0:7)
  446. which would provide storage space for screens 0-7.
  447. You could then CALL SCREENSTORE (4) to store the
  448. current text screen in slot number 4, and
  449. CALL SCREENRECALL(4) to recall it.  In this case, you'd
  450. have set aside 32K (8*4096) bytes for screen storage,
  451. and you could use slots 4-7 for storing your own screens.
  452.  
  453. Example: CALL screenstore(4)
  454.  
  455. --------------------------------------------------------------------------------
  456. * sub selectback (ch%)  
  457.  
  458.  
  459. Allows a user to select a background color from a menu, and
  460. returns selection in cl% ... -1 if user cancelled.
  461. See MLIBDEMO.BAS for example of use.
  462.  
  463. Example: CALL selectback(ch%)
  464.  
  465. --------------------------------------------------------------------------------
  466. * sub selectfore (ch%)  
  467.  
  468.  
  469. Allows a user to select a foreground color from a menu, and
  470. returns selection in cl% ... -1 if user cancelled.
  471. See MLIBDEMO.BAS for example of use.
  472.  
  473. Example: CALL selectfore(cl%)
  474.  
  475. --------------------------------------------------------------------------------
  476. * sub setdisk (d%)  
  477.  
  478.  
  479. Sets disk in d% to be default (current drive):
  480. 0 = A, 1 = B, 2 = C, etc.
  481. Returns number of logical drives in system in d%.
  482.  
  483. Example: CALL setdisk(0) :' Set to A:
  484.  
  485. --------------------------------------------------------------------------------
  486. * sub showarray (title$, maxline%, holdit$())  
  487.  
  488.  
  489. New to Version 2.0 - Displays passed text array.
  490. Called by SHOWTEXTFILE in Menulib V2.0.  Does not
  491. save previous screen or change array in holdit$().
  492. Call with title$ = title to display at bottom
  493. of screen and maxline% maximum element of the
  494. array (line) to display.
  495.  
  496. Example: CALL showarray("DEMO.BAS", 32, holdit$())
  497.  
  498. --------------------------------------------------------------------------------
  499. * sub showtextfile (fi$, clr%)  
  500.  
  501.  
  502. An advanced routine that displays a textfile specified in fi$.
  503. Set clr% to the foreground color to display the text file in
  504. before calling this routine.  This routine calls SHOWARRAY after
  505. loading a text file into an array.
  506.  
  507. Example: CALL showtextfile("test.dat", 15)
  508.  
  509. --------------------------------------------------------------------------------
  510. * sub sounds (num%)  
  511.  
  512.  
  513. Plays a sound on the PC's speaker.
  514. Set num% to:
  515.  
  516. 1 = popup
  517. 2 = popdown
  518. 3 = klaxon
  519. 4 = siren
  520. 5 = blip
  521. 6 = 2-tone
  522. 7 = 2-tone triple
  523. 8 = 3-tone
  524. 9 = buzz
  525. 10 = chirp
  526. 11-14 = beep1-4
  527. 15 = 60hz
  528.  
  529. Example: CALL sounds(1)
  530.  
  531. --------------------------------------------------------------------------------
  532. * function trimpath$(fi$)  
  533.  
  534.  
  535. New to V2.0 -
  536. Trims the path off a filename, returning
  537. just the original filename (12 char. max).
  538.  
  539. Example: PRINT trimpath$("C:\TEMP\TEST.BAS")
  540.  
  541. --------------------------------------------------------------------------------
  542. * sub vscrollbar (starty%, startx%, length%)  
  543.  
  544.  
  545. Displays a vertical "scroll bar" on the screen starting at position
  546. starty%/startx%, of length% characters (vertically).  See the demo
  547. program for an example of vscrollbar.  This routine displays the
  548. scrollbar only - does not control scrolling or anything else.  A
  549. future version of Menulib may more fully implement the VSCROLLBAR
  550. feature.
  551.  
  552. Example: CALL vscrollbar (1, 78, 15)
  553.  
  554. --------------------------------------------------------------------------------
  555. * sub yesnobox (msg$, choice%)  
  556.  
  557.  
  558. Prints a one-line message on the screen in a box,
  559. and waits for user to select YES, NO or CANCEL.
  560. Returns 1 (YES), 0 (NO) or -1 (Cancel) in choice%.
  561. Shortest string in msg$ should be >20.
  562.  
  563. Example: CALL yesnobox("Are you Sure?", choice%)
  564.  
  565.