home *** CD-ROM | disk | FTP | other *** search
/ hobbes.nmsu.edu / 2008-06-02_hobbes.nmsu.edu.zip / new / time4z12.zip / FS.TXT next >
Text File  |  2008-05-29  |  11KB  |  190 lines

  1. DGDs REXX Text-Mode File Selector v1.0 (Code is stable at V1.0, 05-29-2008,
  2. however, several applications are still being developed. One is KMPFS10.ZIP
  3. on Hobbes, or later versions.)
  4.  
  5. Features:
  6. ■ All keyboard navigation: EASILY TEN TIMES AS FAST AS MOUSING!
  7. ■ Navigation using the arrows keys plus page-up and page-down.
  8. ■ No hunting for the "." to exit a directory; left-arrow ALWAYS goes up tree.
  9. ■ No hunting for a directory you've JUST exited: cursor STAYS on it rather
  10.   than resetting to top of the list: right-arrow instantly goes back in.
  11. ■ Instant drive change: tap 'a'-'z', and it's shown, if available.
  12. ■ Most options are both programmable AND key-selectable.
  13. ■ Keys are mnemonic (use capitals as below), plus the standard F1 for Help.
  14. ■ Initial position in displayed list of: Head, Middle, or Tail.
  15. ■ Sorting on: Date, Extension, Name, or Size.
  16. ■ REXX SOURCE. Uses only OS/2 classic REXX and RexxUtil library.
  17. ■ Uses FULL height of current screen. (Could restrict with minor tweaks.)
  18. ■ Can use FULL width of current screen (40 columns for name is a good minimum).
  19. ■ Programmable file details, any or all of: Date, Time, Size, and Attributes,
  20.   in any order, with Long form having four-digit year and time with seconds.
  21. ■ Long file names are shortened with an obvious ellipsis marker. (Though still
  22.   can be ambiguous if names are long and similar. No obvious cure for it.)
  23. ■ Volume label and current path are displayed at bottom.
  24. ■ Retrieves multiple filespecs (besides all directories) with one call.
  25. ■ Filtering can include by Attributes.
  26. ■ Filtering automatically turned off when going UP tree.
  27. ■ "F" toggles Filtering: off to view ALL files, including system and hidden,
  28.     or back to as programmed.
  29. ■ TAGGING of files and directories with unambiguous indication.
  30. ■ Tag in either direction with ctrl-up or ctrl-down, moving to next in list.
  31. ■ Uses SysSleep to avoid hogging CPU with keyboard polling. (RexxUtil only
  32.   allows sleep times of whole seconds; a split-second "sleep" from another
  33.   library will avoid the lag in response this causes.)
  34.  
  35.  
  36. KMPFS.CMD (search for "KMPFS" on Hobbes) is an application with purpose beyond
  37. exercising file selector. It can be easily modified to filter for any files
  38. and then call any executable. -- There's a more general purpose version in
  39. progress, which implements command-line file associations. -- In the meantime,
  40. modifying KMPFS.CMD to filter for *.txt, *.doc, and various other text files,
  41. and calling TEDIT.EXE makes browsing through shareware documention more fun.
  42.  
  43. The old "documentation" has been extracted and duplicated below for reference.
  44. If you see "LD4" anywhere, it has no particular meaning, started as a quick
  45. and dirty "look at drive" with SysFileTree(), then version 4 was merged with
  46. old Turbo Pascal code. If numbered by significant changes and bug fixes, it'd
  47. be well into three digits.
  48.  
  49. >>> NOTE: filtering starts ON in applications so if you first go into
  50. sub-directories, you will see only sub-directories if they exist, no files!
  51. Puzzled even me just now, because in testing I usually went up from \OS2
  52. first, which turns the filter off. But the code is working -- as programmed.
  53.  
  54. ------------------------------------------------------------------------------
  55.  
  56. Input Parameters (see further below for handling returned strings):
  57.  
  58.                 fs_lmar, glo_var, fs_path,  fs_flspc, fs_attr, fs_cur,
  59. rv= file_select(40,      glo_var, 'C:\OS2', '*.ico',  '',      'REXX.ICO',
  60.                 'N',     'M',        'DTSAL', 1)
  61.                 fs_sort, fs_initpos, fs_view, fs_filter
  62.  
  63. fs_scol   : Start Column. Details go to left of this; names to right.
  64. glo_var   : Global Variable; stem into which the formatted directory is put.
  65. fs_path   : Path. Ensure before calling that it exists.
  66. fs_flspc  : File Specification(s). Space delimited, so NONE allowed IN a spec.
  67. fs_attr   : Attributes for search. See REXX info for SysFileTree().
  68. fs_cur    : Current. Will be highlighted if exists; if not, uses H, M, or T.
  69. fs_sort   : Sorting. First letter of: Date, Time, Extension, or Size.
  70. fs_initpos: Initial Position. First letter of: Head, Middle, or Tail.
  71. fs_view   : View details: Date, Time, Size, Attribute, Long date; sets order.
  72. fs_filter : Filter switch, '0' or '1' determines whether only shows specified.
  73.  
  74.  
  75. rv= get_1_directory(glo_var, 'C:\OS2\', 'rexx* *.ini', '*****', 1,         1)
  76.                     glo_var, g1_path,   g1_flspc,      tattr,   g1_filter, g1_dirs
  77.  
  78. glo_var  : Global Variable; stem into which the formatted directory is put.
  79. g1_path  : Path.
  80. g1_flspc : File Specification(s). As above.
  81. tattr    : Attributes, as above.
  82. g1_filter: Filter switch, '1' use g1_flspc, '0' use '*.*'.
  83. g1_dirs  : Directories switch, '1' get directories too; '0' no directories.
  84.  
  85. ------------------------------------------------------------------------------
  86.  
  87. Usage notes (extracted from LD4 exercise program):
  88.  
  89. Variables. Need the color definitions, plus the following:
  90.  
  91. parse value systextscreensize() with scry scrx
  92. scry= scry - 1; scrx= scrx - 1; /* adj to 0, 0 based values */
  93.  
  94. numeric digits 12 /* necessary to display bytes of gigabytes */
  95.  
  96. glo_var= 'dirlist.' /* MUST SPECIFY 1ST so value(glo_var) is valid for call.
  97.   glo_var is passed to get_1_directory, where its main purpose is ability
  98.   to use more than one stem variable. Originally to support multiple
  99.   directory lists, glo_var and the use of value() became too annoying when
  100.   throughout file_select(), so remains only in get_1_directory(), which
  101.   can be called separately if more than one (formatted) list is needed.
  102. */
  103.  
  104. rv= file_select(40, glo_var, 'C:\OS2', '*.ico', '', 'REXX.ICO', 'N', 'M', 'DTSAL', 1)
  105. /*  Provides 40 ^ columns for name in 80 col window, about minimum useful
  106.     for HPFS long file names. NOTE that FILE NAMES GO TO RIGHT of specified
  107.     column and that any DETAILS ARE PLACED TO LEFT of it (in variable order).
  108. */
  109. say
  110. say ansi_clreol'===================== Returned string: ======================'
  111. say rv||ansi_clreol
  112. if pos('█', rv) > 0 then do
  113. say ansi_clreol'======================= Tagged files: ======================='
  114. /* NOTE: may be spaces in returned file name! -- Get ALL starting at 4th word!
  115.    Tagging is done in 3rd word having character for each file:
  116.    "Enter 32 ·······█████········ C:\OS2\REXX.ICO" < remainder is file name
  117.     ^key  ^index  ^character for each file in directory; blocks mark tagged
  118.    The file at cursor is NOT TAGGED BY <enter>; caller must decide what to do.
  119.    Caller must also check attributes and handle directories.
  120. -- NOTE THAT <enter> IS AN EXCEPTION: all other keys return just scan CODES.
  121.    This is to be able to able to SEE it when testing; change below.
  122. */
  123. do loop= 1 to length(word(rv, words(rv)))
  124.   if substr(word(rv, words(rv)), loop, 1) = '█' then say ansi_clreol||loop' 'dirlist.loop
  125. end
  126. end
  127. else say ansi_clreol'============== No files were tagged ================'
  128.  
  129. say ansi_clreol'========= TESTS GET_1_DIRECTORY FOR MULTIPLE LISTS ========='
  130. glo_var='list2.'
  131. rv= get_1_directory(glo_var, 'C:\OS2\', 'rexx* *.ini', '*****', 1, 1)
  132. do loop= 1 to rv  /* must manually skip directories... */
  133.   if loop > 2 & substr(list2.loop, wordindex(list2.loop, 4) + 1, 1) <> 'D' then do
  134.     say ansi_clreol||loop' 'list2.loop
  135.   end
  136. end
  137.  
  138. >>> Summary: set up required variables as given in LD4.CMD. -- Do whatever
  139. else your application requires. -- Pick values for the file_select() call. A
  140. limitation is that if a "current file" (fs_cur, the 6th input parameter) is
  141. given, then the file MUST exist. Use a While loop with a Quit variable, and a
  142. Select to handle returned keys, one of which sets the Quit flag. The screen
  143. is re-drawn in such loop each time a key is returned to caller even if it's
  144. only discarded, but in practice isn't noticeable -- among the other flashing
  145. due to primitive screen handling caused by sticking to basic REXX. You must,
  146. however, on each loop update the fs_cur parameter to the returned file name.
  147. [With a deal of re-arrangement of variables, one could avoid initializing
  148. upon entering file_select()...]
  149.  
  150.  
  151. See my TZ.CMD in TIME4Zxx.ZIP for details in actual application. There are
  152. some documentation errors (elsewhere) caused by changes made to ordering
  153. of returned tags (now 3rd word). What's here is correct.
  154.  
  155. There are also some differences between the LD4 example and TZ.CMD, mostly of
  156. commenting out the automatic changing of filtering when going up tree, plus
  157. changing so the <enter> key returns scan code like the rest.
  158.  
  159.  
  160. ---------------------------- Optional ranting --------------------------------
  161.  
  162. GUI file selector "dialogs" even in OS/2 strike me as mock-ups that were never
  163. refined by experience to make EASY, which is startling for a basic and
  164. frequent function. The world wide waste of time spent fumbling to find a "."
  165. dir just to go up the tree, or scrolling to go back into a directory that you
  166. just exited because the list resets to top, has to be adding up to many
  167. thousands of man-years -- and no relief is in sight, the first methods that
  168. occurred to someone are now chiseled into stone. This REXX code at least gets
  169. beyond Bill's "gee whiz" stage to making file selection so easy that browsing
  170. a drive is almost fun.
  171.  
  172. Many principles here aren't just for text-mode (could be implemented with
  173. buttons that duplicate the key functions, WHILE also allowing the keyboard),
  174. but a GUI version would obscure the main point that using only the keyboard is
  175. STILL much faster than doing EVERYTHING with the mouse. Mousing is FINE for
  176. selecting AN item already visible, but turns any paging into complex eye-hand
  177. coordination practice to locate tiny buttons with high precision, and
  178. repeating the waste of time and concentration should you need to reverse even
  179. by one line. -- Well, that's another struggle that reasonable people seem to
  180. have lost, and the rest don't even know that there IS an alternative.
  181.  
  182. Even where the keyboard is allowed, it's done badly, such as letter keys jump
  183. to the first directory that starts with that letter. My testing shows that
  184. page-up and page-down are never worse and nearly always much better: with
  185. numerous directories starting with same letter, one must still scroll.
  186.  
  187. You may find drive selection with lower-case disconcerting... I do, now and
  188. then. Can be changed to upper-case fairly easily, with lower-case becoming
  189. commands. I'm leaving it as is for now because also can be convenient.
  190.