home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PF.ZIP / PICKFILE.XRF < prev   
Encoding:
Text File  |  1987-12-20  |  41.2 KB  |  1,276 lines

  1.  
  2.  
  3.  
  4. =================================================================
  5. QXREF:  The Telemacus Cross Reference Utility for Turbo C 
  6. QXREF:  Line numbers are enclosed in brackets, [ ]
  7. QXREF:  Logic levels are enclosed in arrows, < >
  8. QXREF:  Hold the <ALT> key down to freeze the screen.
  9. QXREF:  Use redirection in the command tail for file capture.
  10. QXREF:  Processing pickfile.c
  11.  
  12.  
  13.  
  14.  
  15. [    1] <  0> /* 
  16. [    2] <  0> DEVELOPING A FILE SELECTION WINDOW IN TURBO C 
  17. [    3] <  0> ---------------------------------------------- 
  18. [    4] <  0> Garry J. Vass   [72307,3311] 
  19. [    5] <  0> Copyright (c), 1987, Telemacus Software Associates 
  20. [    6] <  0> This file contains the nucleus routines for developing 
  21. [    7] <  0> a file selection window using Turbo C and QLIB (release 
  22. [    8] <  0> 4 or above).  File selection windows have the following 
  23. [    9] <  0> advantages: 
  24. [   10] <  0> -  As can be seen here, they are VERY easy to develop. 
  25. [   11] <  0> -  The user is not burdened with having to remember 
  26. [   12] <  0> file names; 
  27. [   13] <  0> -  The programmer has more control over the selection 
  28. [   14] <  0> and processing of files; and 
  29. [   15] <  0> -  The overall presentation of the program is improved. 
  30. [   16] <  0> GENERAL NOTES, CAVEATS, AND DRUNKEN RAMBLINGS 
  31. [   17] <  0> --------------------------------------------- 
  32. [   18] <  0> Use the LARGE memory model for compiling this program. 
  33. [   19] <  0> Where possible, I tried to use the keyboard conventions (arrows, 
  34. [   20] <  0> home, end, etc) in the file selection routines found in NU.EXE 
  35. [   21] <  0> (viz., Norton Utility).  The program does not have the feature 
  36. [   22] <  0> of scrolling the entire screen display to accomodate an additional 
  37. [   23] <  0> column. 
  38. [   24] <  0> This prototype stubs in the error processing if the maximum 
  39. [   25] <  0> number of files has been exceeded.  These must be added 
  40. [   26] <  0> according to the application. 
  41. [   27] <  0> An array structure is used to store and present the file names. 
  42. [   28] <  0> Arrays are handy because the members can be easily accessed.  They 
  43. [   29] <  0> are troublesome because they must be specified to an explicit size 
  44. [   30] <  0> and must be contained within the data segment.  Production quality 
  45. [   31] <  0> and/or heavy duty directory processing routines should use 
  46. [   32] <  0> linked lists, or related dynamic structures, for storing file names. 
  47. [   33] <  0> This program was developed on an IBM AT with EGA under DOS 3.2 using 
  48. [   34] <  0> Turbo C 1.0 and QLIB-4.  The functions (modified for linked list 
  49. [   35] <  0> structures and extended error processing logic) were incorporated 
  50. [   36] <  0> into a production-level expert system - with hooks into Turbo Prolog. 
  51. [   37] <  0> The application itself deals with the optimal allocation/assignment 
  52. [   38] <  0> and PSA good delivery rules of wirable MBS pools (a Wall Street 
  53. [   39] <  0> investment banking application).  Thanks, Borland!! 
  54. [   40] <  0> As might be expected, OS/2 users must use the dos box for this 
  55. [   41] <  0> program.  QLIB for OS/2 is currently in the works... 
  56. [   42] <  0> */ 
  57. [   43] <  0> /***********************  BEGIN SOURCE FOR PICKFILE  ********************/ 
  58. [   44] <  0> /***********************  INCLUDES FOR PICKFILE  ************************/ 
  59. [   45] <  0> /* dir.h contains the directory get and file name parse functions       */ 
  60. [   46] <  0> #include <dir.h> 
  61. [   47] <  0> /* qtypes.c contains the requisite type declarations for this program   */ 
  62. [   48] <  0> #include <qtypes.c> 
  63. [   49] <  0> /* qkeys.c contains the qreadkbd translation tokens (optional)          */ 
  64. [   50] <  0> #include <qkeys.c>       /*  can be found in go bor                     */ 
  65. [   51] <  0> /* qcolors.c contains the english tokens for screen attributes (optional)*/ 
  66. [   52] <  0> #include <qcolors.c>     /*  can be found in go bor                     */ 
  67. [   53] <  0> /***********************  END OF INCLUDES FOR PICKDIR  *******************/ 
  68. [   54] <  0> /***********************  DEFINES FOR PICKFILE  **************************/ 
  69. [   55] <  0> #define filename       filefb.ff_name    /* abbreviation         */ 
  70. [   56] <  0> #define file_att       filefb.ff_attrib  /* abbreviation         */ 
  71. [   57] <  0> #define filesize       filefb.ff_fsize   /* abbreviation         */ 
  72. [   58] <  0> #define filedate       filefb.ff_fdate   /* abbreviation         */ 
  73. [   59] <  0> #define filetime       filefb.ff_ftime   /* abbreviation         */ 
  74. [   60] <  0> #define MAX_FILES       100    /* Max files before error logic   */ 
  75. [   61] <  0> #define WINDOW_UL_X     0      /* Box coordinates for PICKFILE   */ 
  76. [   62] <  0> #define WINDOW_UL_Y     0      /* window                         */ 
  77. [   63] <  0> #define WINDOW_LR_X     79     /*                                */ 
  78. [   64] <  0> #define WINDOW_LR_Y     22     /*                                */ 
  79. [   65] <  0> #define XINCREMENT      15     /* Horizontal increment           */ 
  80. [   66] <  0> #define FILE_BACK       black  /* File name display background   */ 
  81. [   67] <  0> #define FILE_FORE       white  /* File name display foreground   */ 
  82. [   68] <  0> #define WINDOW_DEPTH    WINDOW_LR_Y - WINDOW_UL_Y 
  83. [   69] <  0> /************************  END OF DEFINES FOR PICKFILE  ******************/ 
  84. [   70] <  0> /************************  STRUCTS AND TYPEDEFS FOR PICKFILE  ************/ 
  85. [   71] <  0> struct   ffblk filefb;
  86. [   72] <  0> /* see dir.h  */ 
  87. [   73] <  0> typedef  struct 
  88. [   74] <  1>   {
  89. [   75] <  1>   qint sx;
  90. [   76] <  1>   /* screen column for this file  */ 
  91. [   77] <  1>   qint sy;
  92. [   78] <  1>   /* screen row for this file     */ 
  93. [   79] <  1>   struct ffblk file_info;
  94. [   80] <  1>   /* nested structure             */ 
  95. [   81] <  1>   }
  96. [   82] <  0> full_file_record; 
  97. [   83] <  0> /******************** END OF STRUCTS AND TYPES FOR PICKFILE  ***************/ 
  98. [   84] <  0> /*******************  GLOBAL VARIABLES FOR PICKFILE  ***********************/ 
  99. [   85] <  0> full_file_record 
  100. [   86] <  0> ffr[MAX_FILES];
  101. [   87] <  0> /*  Array for found files      */ 
  102. [   88] <  0> int      filesfound  = 0;
  103. [   89] <  0> /*  Count for found files      */ 
  104. [   90] <  0> qint     currentsx   = 0;
  105. [   91] <  0> /*  For screen save/restore    */ 
  106. [   92] <  0> qint     currentsy   = 0;
  107. [   93] <  0> /*  For screen save/restore    */ 
  108. [   94] <  0> qint     maincounter = 0;
  109. [   95] <  0> /*  General index              */ 
  110. [   96] <  0> qint     originalx   = 0;
  111. [   97] <  0> /*  For screen save/restore    */ 
  112. [   98] <  0> qint     originaly   = 0;
  113. [   99] <  0> /*  For screen save/restore    */ 
  114. [  100] <  0> qstring  mainstring  = "";
  115. [  101] <  0> /*  For return value           */ 
  116. [  102] <  0> prompt_record filespecification = 
  117. [  103] <  1>   {
  118. [  104] <  1>   "PLEASE ENTER A DIRECTORY SEARCH SPECIFICATION:  ",/* tag qstring */ 
  119. [  105] <  1>   "*.exe",                         /* tag value */ 
  120. [  106] <  1>   0,                               /* tag x*/ 
  121. [  107] <  1>   12,                              /* tag y*/ 
  122. [  108] <  1>   50,                              /* val x */ 
  123. [  109] <  1>   12,                              /* val y */ 
  124. [  110] <  1>   13,                              /* max chars */ 
  125. [  111] <  1>   bright_white,                    /* tag fore */ 
  126. [  112] <  1>   black,                           /* tag back */ 
  127. [  113] <  1>   white,                           /* val fore */ 
  128. [  114] <  1>   dark_blue,                       /* val back */ 
  129. [  115] <  1>   0,                               /* case conversion */ 
  130. [  116] <  1>   " ",                             /* edit mask       */ 
  131. [  117] <  1>   " ", 0, " ", " ", " ", 0
  132. [  118] <  1>   }
  133. [  119] <  0> ; 
  134. [  120] <  0> /************************* END OF GLOBAL VARIABLES FOR PICKFILE ***********/ 
  135. [  121] <  0> /**************************************************************************/ 
  136. [  122] <  0> /************************* PICKFILE SUPPORT FUNCTIONS  ********************/ 
  137. [  123] <  0> void initialize_coordinates() 
  138. [  124] <  1>   {
  139. [  125] <  1>   /* 
  140. [  126] <  1>   This function simply initializes the screen coordinates to where 
  141. [  127] <  1>   the display of file names should begin. 
  142. [  128] <  1>   */ 
  143. [  129] <  1>   currentsx = WINDOW_UL_X + 2; 
  144. [  130] <  1>   currentsy = WINDOW_UL_Y + 1; 
  145. [  131] <  1>   }
  146. [  132] <  0> /*************************************************************************/ 
  147. [  133] <  0> void update_current_coordinates() 
  148. [  134] <  1>   {
  149. [  135] <  1>   /* 
  150. [  136] <  1>   This service function increments the screen coordinates 
  151. [  137] <  1>   in a verticle manner.  As each column is filled, the next 
  152. [  138] <  1>   column is calculated using the XINCREMENT variable. 
  153. [  139] <  1>   */ 
  154. [  140] <  1>   ++currentsy; 
  155. [  141] <  1>   if (currentsy >= WINDOW_LR_Y) 
  156. [  142] <  2>     {
  157. [  143] <  2>     currentsy = WINDOW_UL_Y + 1; 
  158. [  144] <  2>     currentsx = currentsx + XINCREMENT; 
  159. [  145] <  2>     if (currentsx + XINCREMENT > WINDOW_LR_X) 
  160. [  146] <  3>       {
  161. [  147] <  3>       printf("program limits exceeded\n"); 
  162. [  148] <  3>       /*  calls to error logic go here  */ 
  163. [  149] <  3>       abort(); 
  164. [  150] <  3>       }
  165. [  151] <  2>     }
  166. [  152] <  1>   }
  167. [  153] <  0> /*************************************************************************/ 
  168. [  154] <  0> qint get_files 
  169. [  155] <  0> ( 
  170. [  156] <  0> qstring search_specification 
  171. [  157] <  0> ) 
  172. [  158] <  1>   {
  173. [  159] <  1>   /* 
  174. [  160] <  1>   This function accepts a search specification (such as *.*) and loops 
  175. [  161] <  1>   through the current directory, storing each match into an array. 
  176. [  162] <  1>   */ 
  177. [  163] <  1>   int filerc = 0; 
  178. [  164] <  1>   filesfound = 0; 
  179. [  165] <  1>   filerc = findfirst(search_specification, &filefb, 0xff); 
  180. [  166] <  1>   while (!filerc) 
  181. [  167] <  2>     {
  182. [  168] <  2>     if ((filename[0] != 46)  &&     /*  exclude those pesky periods... */ 
  183. [  169] <  2>     (file_att    != 0x10))      /*  and subdirectories             */ 
  184. [  170] <  3>       {
  185. [  171] <  3>       ffr[filesfound].sx = currentsx; 
  186. [  172] <  3>       ffr[filesfound].sy = currentsy; 
  187. [  173] <  3>       ffr[filesfound].file_info = filefb; 
  188. [  174] <  3>       update_current_coordinates(); 
  189. [  175] <  3>       ++filesfound; 
  190. [  176] <  3>       }
  191. [  177] <  2>     if (filesfound >= MAX_FILES) 
  192. [  178] <  3>       {
  193. [  179] <  3>       printf("program limits exceeded\n"); 
  194. [  180] <  3>       /*  calls to error logic go here  */ 
  195. [  181] <  3>       abort(); 
  196. [  182] <  3>       }
  197. [  183] <  2>     filerc = findnext(&filefb); 
  198. [  184] <  2>     }
  199. [  185] <  1>   return(filesfound - 1); 
  200. [  186] <  1>   }
  201. [  187] <  0> /*************************************************************************/ 
  202. [  188] <  0> void display_file_box() 
  203. [  189] <  1>   {
  204. [  190] <  1>   /* 
  205. [  191] <  1>   This is the engine presentation routine.  It draws a box then 
  206. [  192] <  1>   displays all the matched file names at the screen coordinates. 
  207. [  193] <  1>   */ 
  208. [  194] <  1>   qint displaycounter; 
  209. [  195] <  1>   qdrawbox 
  210. [  196] <  1>   (WINDOW_UL_X, 
  211. [  197] <  1>   WINDOW_UL_Y, 
  212. [  198] <  1>   WINDOW_LR_X, 
  213. [  199] <  1>   WINDOW_LR_Y, 
  214. [  200] <  1>   "", 
  215. [  201] <  1>   "[ PRESS F1 FOR HELP ]", 
  216. [  202] <  1>   (dark_blue<<4) | white, 
  217. [  203] <  1>   bright_white, 
  218. [  204] <  1>   bright_white); 
  219. [  205] <  1>   for (displaycounter=0;displaycounter<=filesfound;++displaycounter) 
  220. [  206] <  2>     {
  221. [  207] <  2>     qsnap 
  222. [  208] <  2>     (ffr[displaycounter].file_info.ff_name, 
  223. [  209] <  2>     ffr[displaycounter].sx, 
  224. [  210] <  2>     ffr[displaycounter].sy, 
  225. [  211] <  2>     bright_white); 
  226. [  212] <  2>     }
  227. [  213] <  1>   }
  228. [  214] <  0> /*************************************************************************/ 
  229. [  215] <  0> void unhighlight_area 
  230. [  216] <  0> ( 
  231. [  217] <  0> qint  startx, 
  232. [  218] <  0> qint  starty, 
  233. [  219] <  0> qint  length 
  234. [  220] <  0> ) 
  235. [  221] <  1>   {
  236. [  222] <  1>   qreset_box_attribute 
  237. [  223] <  1>   (startx, 
  238. [  224] <  1>   starty, 
  239. [  225] <  1>   startx + length, 
  240. [  226] <  1>   starty, 
  241. [  227] <  1>   (FILE_BACK<<4) | FILE_FORE); 
  242. [  228] <  1>   }
  243. [  229] <  0> /*************************************************************************/ 
  244. [  230] <  0> void highlight_area 
  245. [  231] <  0> ( 
  246. [  232] <  0> qint  startx, 
  247. [  233] <  0> qint  starty, 
  248. [  234] <  0> qint  length 
  249. [  235] <  0> ) 
  250. [  236] <  1>   {
  251. [  237] <  1>   qreset_box_attribute 
  252. [  238] <  1>   (startx, 
  253. [  239] <  1>   starty, 
  254. [  240] <  1>   startx + length, 
  255. [  241] <  1>   starty, 
  256. [  242] <  1>   (FILE_FORE<<4) | FILE_BACK); 
  257. [  243] <  1>   }
  258. [  244] <  0> /*************************************************************************/ 
  259. [  245] <  0> void give_file_help() 
  260. [  246] <  1>   {
  261. [  247] <  1>   /* 
  262. [  248] <  1>   This function displays the help window when the F1 key is hit. 
  263. [  249] <  1>   */ 
  264. [  250] <  1>   qscreen file_help_screen; 
  265. [  251] <  1>   qint    file_help_ul_x = 20; 
  266. [  252] <  1>   qint    file_help_ul_y = 5; 
  267. [  253] <  1>   qint    file_help_lr_x = 60; 
  268. [  254] <  1>   qint    file_help_lr_y = 15; 
  269. [  255] <  1>   qint    file_help_index; 
  270. [  256] <  1>   qstring file_help_text[9] = 
  271. [  257] <  2>     {
  272. [  258] <  2>     "Use the arrow keys (Up, Down, Home,  ", 
  273. [  259] <  2>     "and End, to orient the highlighted   ", 
  274. [  260] <  2>     "area on the file you wish to select. ", 
  275. [  261] <  2>     "Press the Enter (Return, Advance,    ", 
  276. [  262] <  2>     "etc) key to exit with your selection.", 
  277. [  263] <  2>     "                                     ", 
  278. [  264] <  2>     "To exit without making a selection,  ", 
  279. [  265] <  2>     "press the Escape key.                ", 
  280. [  266] <  2>     "                                     " 
  281. [  267] <  2>     }
  282. [  268] <  1>   ; 
  283. [  269] <  1>   qwindow_save             /*  save the screen area */ 
  284. [  270] <  1>   (file_help_ul_x, 
  285. [  271] <  1>   file_help_ul_y, 
  286. [  272] <  1>   file_help_lr_x, 
  287. [  273] <  1>   file_help_lr_y, 
  288. [  274] <  1>   file_help_screen); 
  289. [  275] <  1>   qdrawbox                 /*  draw a box for the help window  */ 
  290. [  276] <  1>   (file_help_ul_x, 
  291. [  277] <  1>   file_help_ul_y, 
  292. [  278] <  1>   file_help_lr_x, 
  293. [  279] <  1>   file_help_lr_y, 
  294. [  280] <  1>   "", 
  295. [  281] <  1>   "[ hit any key to continue ]", 
  296. [  282] <  1>   bright_white, 
  297. [  283] <  1>   bright_white, 
  298. [  284] <  1>   bright_white | blink); 
  299. [  285] <  1>   for (file_help_index=0;file_help_index<9;++file_help_index) 
  300. [  286] <  2>     {
  301. [  287] <  2>     qsnap                /*  display the help text  */ 
  302. [  288] <  2>     (file_help_text[file_help_index], 
  303. [  289] <  2>     file_help_ul_x + 2, 
  304. [  290] <  2>     file_help_ul_y + file_help_index + 1, 
  305. [  291] <  2>     bright_white); 
  306. [  292] <  2>     }
  307. [  293] <  1>   file_help_index = qreadkbd();
  308. [  294] <  1>   /*  wait for a key  */ 
  309. [  295] <  1>   qwindow_restore                 /*  restore the screen area  */ 
  310. [  296] <  1>   (file_help_ul_x, 
  311. [  297] <  1>   file_help_ul_y, 
  312. [  298] <  1>   file_help_lr_x, 
  313. [  299] <  1>   file_help_lr_y, 
  314. [  300] <  1>   file_help_screen); 
  315. [  301] <  1>   }
  316. [  302] <  0> /*************************************************************************/ 
  317. [  303] <  0> qint pick_file_menu() 
  318. [  304] <  1>   {
  319. [  305] <  1>   /* 
  320. [  306] <  1>   This is the driver function for the PICKFILE presentation.  It is 
  321. [  307] <  1>   similar in form and structure to the qbounce(~~~) function (available 
  322. [  308] <  1>   at go bor). 
  323. [  309] <  1>   */ 
  324. [  310] <  1>   qint menucounter; 
  325. [  311] <  1>   qint keypressed; 
  326. [  312] <  1>   keypressed = 0; 
  327. [  313] <  1>   menucounter = 0; 
  328. [  314] <  1>   qgotoxy(0, 25); 
  329. [  315] <  1>   highlight_area                 /* highlight the first file  */ 
  330. [  316] <  1>   (ffr[menucounter].sx, 
  331. [  317] <  1>   ffr[menucounter].sy, 
  332. [  318] <  1>   XINCREMENT - 1); 
  333. [  319] <  1>   while (keypressed != return_pressed) 
  334. [  320] <  2>     {
  335. [  321] <  2>     keypressed = qreadkbd();
  336. [  322] <  2>     /*  get a keystroke  */ 
  337. [  323] <  2>     if (keypressed != return_pressed) 
  338. [  324] <  3>       {
  339. [  325] <  3>       unhighlight_area 
  340. [  326] <  3>       (ffr[menucounter].sx, 
  341. [  327] <  3>       ffr[menucounter].sy, 
  342. [  328] <  3>       XINCREMENT - 1); 
  343. [  329] <  3>       switch (keypressed) 
  344. [  330] <  4>         {
  345. [  331] <  4>         case escape_pressed: 
  346. [  332] <  5>           {
  347. [  333] <  5>           /* escape means exit with no file selection */ 
  348. [  334] <  5>           return (filesfound + 1); 
  349. [  335] <  5>           }
  350. [  336] <  4>         case f01pressed: 
  351. [  337] <  5>           {
  352. [  338] <  5>           /* F1 means give help  */ 
  353. [  339] <  5>           give_file_help(); 
  354. [  340] <  5>           break; 
  355. [  341] <  5>           }
  356. [  342] <  4>         case home_pressed: 
  357. [  343] <  5>           {
  358. [  344] <  5>           /* HOME means reset the pointer */ 
  359. [  345] <  5>           menucounter = 0; 
  360. [  346] <  5>           }
  361. [  347] <  4>         case up_arrow_pressed: 
  362. [  348] <  5>           {
  363. [  349] <  5>           /*  UP ARROW means go to previous file */ 
  364. [  350] <  5>           menucounter =  qmax(menucounter - 1, 0); 
  365. [  351] <  5>           break; 
  366. [  352] <  5>           }
  367. [  353] <  4>         case end_pressed: 
  368. [  354] <  5>           {
  369. [  355] <  5>           /*  END means go to last file  */ 
  370. [  356] <  5>           menucounter = filesfound; 
  371. [  357] <  5>           break; 
  372. [  358] <  5>           }
  373. [  359] <  4>         case down_arrow_pressed: 
  374. [  360] <  5>           {
  375. [  361] <  5>           /* DOWN ARROW means go to next file  */ 
  376. [  362] <  5>           ++menucounter; 
  377. [  363] <  5>           if (menucounter > filesfound) 
  378. [  364] <  6>             {
  379. [  365] <  6>             menucounter = 0; 
  380. [  366] <  6>             }
  381. [  367] <  5>           break; 
  382. [  368] <  5>           }
  383. [  369] <  4>         case right_arrow_pressed: 
  384. [  370] <  5>           {
  385. [  371] <  5>           /* RIGHT ARROW means "move over one column"  */ 
  386. [  372] <  5>           menucounter = menucounter + WINDOW_DEPTH - 1; 
  387. [  373] <  5>           if (menucounter > filesfound) 
  388. [  374] <  6>             {
  389. [  375] <  6>             menucounter = filesfound; 
  390. [  376] <  6>             }
  391. [  377] <  5>           break; 
  392. [  378] <  5>           }
  393. [  379] <  4>         case left_arrow_pressed: 
  394. [  380] <  5>           {
  395. [  381] <  5>           /* LEFT ARROW means "move back one column"   */ 
  396. [  382] <  5>           menucounter = qmax(menucounter - WINDOW_DEPTH + 1, 0); 
  397. [  383] <  5>           break; 
  398. [  384] <  5>           }
  399. [  385] <  4>         }
  400. [  386] <  3>       highlight_area 
  401. [  387] <  3>       (ffr[menucounter].sx, 
  402. [  388] <  3>       ffr[menucounter].sy, 
  403. [  389] <  3>       XINCREMENT - 1); 
  404. [  390] <  3>       }
  405. [  391] <  2>     }
  406. [  392] <  1>   return(menucounter); 
  407. [  393] <  1>   }
  408. [  394] <  0> /*************************************************************************/ 
  409. [  395] <  0> void select_a_file 
  410. [  396] <  0> ( 
  411. [  397] <  0> qstring search_specification, 
  412. [  398] <  0> qstring file_that_was_selected 
  413. [  399] <  0> ) 
  414. [  400] <  1>   {
  415. [  401] <  1>   /* 
  416. [  402] <  1>   This is the driver function for PICKFILE engine and presentation. 
  417. [  403] <  1>   */ 
  418. [  404] <  1>   /* 
  419. [  405] <  1>   Set the screen coordinates to the upper left corner of the 
  420. [  406] <  1>   presentation box.*/ 
  421. [  407] <  1>   initialize_coordinates(); 
  422. [  408] <  1>   /* Initialize the parameter to be returned. */ 
  423. [  409] <  1>   strcpy(file_that_was_selected, ""); 
  424. [  410] <  1>   /* Load the file array with those that matched the specification */ 
  425. [  411] <  1>   filesfound = get_files(search_specification); 
  426. [  412] <  1>   /* If anything was found, present the file selection window */ 
  427. [  413] <  1>   if (filesfound >= 0) 
  428. [  414] <  2>     {
  429. [  415] <  2>     /*  file sort function goes here  */ 
  430. [  416] <  2>     display_file_box(); 
  431. [  417] <  2>     initialize_coordinates(); 
  432. [  418] <  2>     maincounter = 0; 
  433. [  419] <  2>     maincounter = pick_file_menu(); 
  434. [  420] <  2>     if (maincounter <= filesfound) 
  435. [  421] <  3>       {
  436. [  422] <  3>       strcpy(file_that_was_selected, ffr[maincounter].file_info.ff_name); 
  437. [  423] <  3>       }
  438. [  424] <  2>     }
  439. [  425] <  1>   qclrscr(bright_white); 
  440. [  426] <  1>   }
  441. [  427] <  0> /*************************  BECIN MAINLINE  *****************************/ 
  442. [  428] <  0> main() 
  443. [  429] <  1>   {
  444. [  430] <  1>   qint anyint; 
  445. [  431] <  1>   qscreen mainscreen; 
  446. [  432] <  1>   qint mainx; 
  447. [  433] <  1>   qint mainy; 
  448. [  434] <  1>   /* 
  449. [  435] <  1>   Start off by saving the screen at invocation time 
  450. [  436] <  1>   */ 
  451. [  437] <  1>   mainx = qwherex(); 
  452. [  438] <  1>   mainy = qwherey(); 
  453. [  439] <  1>   qwindow_save(0, 0, 79, 24, mainscreen); 
  454. [  440] <  1>   /* 
  455. [  441] <  1>   Clear the screen 
  456. [  442] <  1>   */ 
  457. [  443] <  1>   qclrscr(bright_white); 
  458. [  444] <  1>   /* 
  459. [  445] <  1>   Get a file search specification from 
  460. [  446] <  1>   the user. 
  461. [  447] <  1>   */ 
  462. [  448] <  1>   qprompt(&filespecification); 
  463. [  449] <  1>   /* 
  464. [  450] <  1>   If the user simply hit carraige return, 
  465. [  451] <  1>   then exit, otherwise process the specification. 
  466. [  452] <  1>   */ 
  467. [  453] <  1>   while (filespecification.value[0] > 0) 
  468. [  454] <  2>     {
  469. [  455] <  2>     qclrscr(bright_white); 
  470. [  456] <  2>     select_a_file(filespecification.value, mainstring); 
  471. [  457] <  2>     qgotoxy(0,25);
  472. [  458] <  2>     /*  hide the cursor  */ 
  473. [  459] <  2>     if (mainstring[0] > 0) 
  474. [  460] <  3>       {
  475. [  461] <  3>       /* 
  476. [  462] <  3>       If the variable "mainstring" contains something, 
  477. [  463] <  3>       then a file was selected.  Here it is simply 
  478. [  464] <  3>       printed out. 
  479. [  465] <  3>       */ 
  480. [  466] <  3>       qsnap("You selected ", 29, 23, bright_white); 
  481. [  467] <  3>       qsnap(mainstring, 44, 23, bright_white); 
  482. [  468] <  3>       }
  483. [  469] <  2>     else 
  484. [  470] <  3>       {
  485. [  471] <  3>       /* 
  486. [  472] <  3>       if the variable "mainstring" contains nothing, 
  487. [  473] <  3>       one of two conditions occured: 
  488. [  474] <  3>       1.  Nothing matched the file specification; or 
  489. [  475] <  3>       2.  The user hit <Escape> in the selection process. 
  490. [  476] <  3>       */ 
  491. [  477] <  3>       qcenter_line("Nothing found or selected", 23, bright_white); 
  492. [  478] <  3>       }
  493. [  479] <  2>     /* 
  494. [  480] <  2>     Pause here to demonstrate result. 
  495. [  481] <  2>     */ 
  496. [  482] <  2>     qcenter_line("Hit a key to continue", 24, bright_white); 
  497. [  483] <  2>     anyint = qreadkbd(); 
  498. [  484] <  2>     /* 
  499. [  485] <  2>     Clear the screen, initialize the prompt, and start over. 
  500. [  486] <  2>     */ 
  501. [  487] <  2>     qclrscr(bright_white); 
  502. [  488] <  2>     filespecification.value[0] = 0; 
  503. [  489] <  2>     qprompt(&filespecification); 
  504. [  490] <  2>     }
  505. [  491] <  1>   /* 
  506. [  492] <  1>   Upon exiting, restore the invocation screen and 
  507. [  493] <  1>   cursor position. 
  508. [  494] <  1>   */ 
  509. [  495] <  1>   qwindow_restore(0, 0, 79, 24, mainscreen); 
  510. [  496] <  1>   qgotoxy(mainx, mainy - 1); 
  511. [  497] <  1>   }
  512. [  498] <  0> /***********************  END OF PICKFILE  ******************************/ 
  513. [  499] <  0> /* 
  514. [  500] <  0> Misc files follow... 
  515. [  501] <  0> */ 
  516. [  502] <  0> /***********************************************/ 
  517. [  503] <  0> /*    This is the PROJECT file for PICKFILE.   */ 
  518. [  504] <  0> /*    Modify this in the IDE and use the       */ 
  519. [  505] <  0> /*    CONTROL KW sequence to save.             */ 
  520. [  506] <  0> /* 
  521. [  507] <  0> /* 
  522. [  508] <  0> d:\qlib.lib 
  523. [  509] <  0> pickfile.c 
  524. [  510] <  0> */ 
  525. [  511] <  0> /*    End of the PROJECT file for PICKFILE.    */ 
  526. [  512] <  0> /***********************************************/ 
  527. [  513] <  0> /**********************************************************************/ 
  528. [  514] <  0> /*  This is the QTYPES.C file for PICKFILE.C.  Use this CONTROL KW    */ 
  529. [  515] <  0> /*  sequence to save this file into your include subdirectory.        */ 
  530. [  516] <  0> /*  The structures are documented elsewhere, and, in fact, this file  */ 
  531. [  517] <  0> /*  is optional if the typedefs are included in the 'main' program    */ 
  532. [  518] <  0> /********************* begin type declarations ************************/ 
  533. [  519] <  0> /* 
  534. [  520] <  0> typedef unsigned char qstring[79]; 
  535. [  521] <  0> typedef unsigned char qstring05[5]; 
  536. [  522] <  0> typedef unsigned char qstring20[20]; 
  537. [  523] <  0> typedef unsigned char qstring40[40]; 
  538. [  524] <  0> typedef unsigned char qstring60[60]; 
  539. [  525] <  0> typedef unsigned int  qint; 
  540. [  526] <  0> typedef unsigned long qlong; 
  541. [  527] <  0> typedef unsigned char qbyte; 
  542. [  528] <  0> typedef unsigned char qscreen[4096]; 
  543. [  529] <  0> typedef struct  
  544. [  530] <  0> { 
  545. [  531] <  0> qstring tag; 
  546. [  532] <  0> qstring value; 
  547. [  533] <  0> qint    tagx; 
  548. [  534] <  0> qint    tagy; 
  549. [  535] <  0> qint    valx; 
  550. [  536] <  0> qint    valy; 
  551. [  537] <  0> qint    vall; 
  552. [  538] <  0> qbyte   tagf; 
  553. [  539] <  0> qbyte   tagb; 
  554. [  540] <  0> qbyte   valf; 
  555. [  541] <  0> qbyte   valb; 
  556. [  542] <  0> qint    valr; 
  557. [  543] <  0> qstring valt; 
  558. [  544] <  0> qstring vale; 
  559. [  545] <  0> qbyte   prmx; 
  560. [  546] <  0> qstring mhea; 
  561. [  547] <  0> qstring mtra; 
  562. [  548] <  0> qstring stid; 
  563. [  549] <  0> qint    poid; 
  564. [  550] <  0> } 
  565. [  551] <  0> prompt_record; 
  566. [  552] <  0> typedef struct qmenustructure 
  567. [  553] <  0> { 
  568. [  554] <  0> qint     screen_x; 
  569. [  555] <  0> qint     screen_y; 
  570. [  556] <  0> qint     menu_width; 
  571. [  557] <  0> qint     foreground; 
  572. [  558] <  0> qint     background; 
  573. [  559] <  0> int      option_count; 
  574. [  560] <  0> qint     prior_choice; 
  575. [  561] <  0> qstring title; 
  576. [  562] <  0> qstring option_text[10]; 
  577. [  563] <  0> } 
  578. [  564] <  0> qmenurecord; 
  579. [  565] <  0> */ 
  580. [  566] <  0> /********************* end of type declarations ***********************/ 
  581. [  567] <  0> /*                                                                    */ 
  582. [  568] <  0> /*       End of the QTYPES.C file for PICKFILE                        */ 
  583. [  569] <  0> /**********************************************************************/
  584. ===================================================================
  585.  
  586. QXREF:  End of program listing
  587.  
  588. QXREF:  Cross references follow...
  589.  
  590.  
  591.  
  592. ==========  QLIB FAMILY MEMBERS  ==========
  593.  
  594. -----> qcenter_line
  595.                    477
  596.                    482
  597. -----> qclrscr
  598.                    425
  599.                    443
  600.                    455
  601.                    487
  602. -----> qdrawbox
  603.                    195
  604.                    275
  605. -----> qgotoxy
  606.                    314
  607.                    458
  608.                    496
  609. -----> qint
  610.                    76
  611.                    78
  612.                    91
  613.                    93
  614.                    95
  615.                    97
  616.                    99
  617.                    154
  618.                    194
  619.                    217
  620.                    218
  621.                    219
  622.                    232
  623.                    233
  624.                    234
  625.                    251
  626.                    252
  627.                    253
  628.                    254
  629.                    255
  630.                    303
  631.                    310
  632.                    311
  633.                    430
  634.                    432
  635.                    433
  636. -----> qmax
  637.                    350
  638.                    382
  639. -----> qprompt
  640.                    448
  641.                    489
  642. -----> qreadkbd
  643.                    294
  644.                    322
  645.                    483
  646. -----> qreset_box_attribute
  647.                    222
  648.                    237
  649. -----> qscreen
  650.                    250
  651.                    431
  652. -----> qsnap
  653.                    207
  654.                    287
  655.                    466
  656.                    467
  657. -----> qstring
  658.                    101
  659.                    156
  660.                    256
  661.                    397
  662.                    398
  663. -----> qwherex
  664.                    437
  665. -----> qwherey
  666.                    438
  667. -----> qwindow_restore
  668.                    295
  669.                    495
  670. -----> qwindow_save
  671.                    269
  672.                    439
  673.  
  674.  
  675. ==========  TURBO C COMPILER DIRECTIVES  ==========
  676.  
  677. -----> #define
  678.                    55
  679.                    56
  680.                    57
  681.                    58
  682.                    59
  683.                    60
  684.                    61
  685.                    62
  686.                    63
  687.                    64
  688.                    65
  689.                    66
  690.                    67
  691.                    68
  692. -----> #include
  693.                    46
  694.                    48
  695.                    50
  696.                    52
  697.  
  698.  
  699. ==========  TURBO C KEY WORDS  ==========
  700.  
  701. -----> break
  702.                    340
  703.                    351
  704.                    357
  705.                    367
  706.                    377
  707.                    383
  708. -----> case
  709.                    331
  710.                    336
  711.                    342
  712.                    347
  713.                    353
  714.                    359
  715.                    369
  716.                    379
  717. -----> else
  718.                    469
  719. -----> for
  720.                    205
  721.                    285
  722. -----> if
  723.                    141
  724.                    145
  725.                    168
  726.                    177
  727.                    323
  728.                    363
  729.                    373
  730.                    413
  731.                    420
  732.                    459
  733. -----> int
  734.                    89
  735.                    163
  736. -----> return
  737.                    185
  738.                    334
  739.                    392
  740. -----> struct
  741.                    72
  742.                    73
  743.                    80
  744. -----> switch
  745.                    329
  746. -----> typedef
  747.                    73
  748. -----> void
  749.                    123
  750.                    133
  751.                    188
  752.                    215
  753.                    230
  754.                    245
  755.                    395
  756. -----> while
  757.                    166
  758.                    319
  759.                    453
  760.  
  761.  
  762. ==========  TURBO C DIR FAMILY  ==========
  763.  
  764. -----> ffblk
  765.                    72
  766.                    80
  767. -----> findfirst
  768.                    165
  769. -----> findnext
  770.                    183
  771.  
  772.  
  773. ==========  TURBO C STDIO FAMILY  ==========
  774.  
  775. -----> printf
  776.                    147
  777.                    179
  778.  
  779.  
  780. ==========  TURBO C STANDARD LIBRARY  ==========
  781.  
  782. -----> abort
  783.                    149
  784.                    181
  785.  
  786.  
  787. ==========  TURBO C STRING FAMILY  ==========
  788.  
  789. -----> strcpy
  790.                    409
  791.                    422
  792.  
  793.  
  794. ==========  TURBO C MISC  ==========
  795.  
  796. -----> main
  797.                    428
  798.  
  799.  
  800. ==========  ALL OTHER CROSS REFERENCE  ==========
  801.  
  802. -----> .file_info
  803.                    173
  804. -----> .file_info.ff_name
  805.                    208
  806.                    422
  807. -----> .sx
  808.                    171
  809.                    209
  810.                    316
  811.                    326
  812.                    387
  813. -----> .sy
  814.                    172
  815.                    210
  816.                    317
  817.                    327
  818.                    388
  819. -----> anyint
  820.                    430
  821.                    483
  822. -----> black
  823.                    66
  824.                    112
  825. -----> blink
  826.                    284
  827. -----> bright_white
  828.                    111
  829.                    203
  830.                    204
  831.                    211
  832.                    282
  833.                    283
  834.                    284
  835.                    291
  836.                    425
  837.                    443
  838.                    455
  839.                    466
  840.                    467
  841.                    477
  842.                    482
  843.                    487
  844. -----> currentsx
  845.                    91
  846.                    129
  847.                    144
  848.                    145
  849.                    171
  850. -----> currentsy
  851.                    93
  852.                    130
  853.                    140
  854.                    141
  855.                    143
  856.                    172
  857. -----> dark_blue
  858.                    114
  859.                    202
  860. -----> dir.h
  861.                    46
  862. -----> display_file_box
  863.                    188
  864.                    416
  865. -----> displaycounter
  866.                    194
  867.                    205
  868.                    208
  869.                    209
  870.                    210
  871. -----> down_arrow_pressed
  872.                    359
  873. -----> end_pressed
  874.                    353
  875. -----> escape_pressed
  876.                    331
  877. -----> f01pressed
  878.                    336
  879. -----> ffr
  880.                    87
  881.                    171
  882.                    172
  883.                    173
  884.                    208
  885.                    209
  886.                    210
  887.                    316
  888.                    317
  889.                    326
  890.                    327
  891.                    387
  892.                    388
  893.                    422
  894. -----> file_att
  895.                    56
  896.                    169
  897. -----> file_back
  898.                    66
  899.                    227
  900.                    242
  901. -----> file_fore
  902.                    67
  903.                    227
  904.                    242
  905. -----> file_help_index
  906.                    255
  907.                    285
  908.                    288
  909.                    290
  910.                    294
  911. -----> file_help_lr_x
  912.                    253
  913.                    272
  914.                    278
  915.                    298
  916. -----> file_help_lr_y
  917.                    254
  918.                    273
  919.                    279
  920.                    299
  921. -----> file_help_screen
  922.                    250
  923.                    274
  924.                    300
  925. -----> file_help_text
  926.                    256
  927.                    288
  928. -----> file_help_ul_x
  929.                    251
  930.                    270
  931.                    276
  932.                    289
  933.                    296
  934. -----> file_help_ul_y
  935.                    252
  936.                    271
  937.                    277
  938.                    290
  939.                    297
  940. -----> file_info
  941.                    80
  942. -----> file_that_was_selected
  943.                    398
  944.                    409
  945.                    422
  946. -----> filedate
  947.                    58
  948. -----> filefb
  949.                    72
  950.                    165
  951.                    173
  952.                    183
  953. -----> filefb.ff_attrib
  954.                    56
  955. -----> filefb.ff_fdate
  956.                    58
  957. -----> filefb.ff_fsize
  958.                    57
  959. -----> filefb.ff_ftime
  960.                    59
  961. -----> filefb.ff_name
  962.                    55
  963. -----> filename
  964.                    55
  965.                    168
  966. -----> filerc
  967.                    163
  968.                    165
  969.                    166
  970.                    183
  971. -----> filesfound
  972.                    89
  973.                    164
  974.                    171
  975.                    172
  976.                    173
  977.                    175
  978.                    177
  979.                    185
  980.                    205
  981.                    334
  982.                    356
  983.                    363
  984.                    373
  985.                    375
  986.                    411
  987.                    413
  988.                    420
  989. -----> filesize
  990.                    57
  991. -----> filespecification
  992.                    102
  993.                    448
  994.                    489
  995. -----> filespecification.value
  996.                    453
  997.                    456
  998.                    488
  999. -----> filetime
  1000.                    59
  1001. -----> full_file_record
  1002.                    82
  1003.                    85
  1004. -----> get_files
  1005.                    154
  1006.                    411
  1007. -----> give_file_help
  1008.                    245
  1009.                    339
  1010. -----> highlight_area
  1011.                    230
  1012.                    315
  1013.                    386
  1014. -----> home_pressed
  1015.                    342
  1016. -----> initialize_coordinates
  1017.                    123
  1018.                    407
  1019.                    417
  1020. -----> keypressed
  1021.                    311
  1022.                    312
  1023.                    319
  1024.                    322
  1025.                    323
  1026.                    329
  1027. -----> left_arrow_pressed
  1028.                    379
  1029. -----> length
  1030.                    219
  1031.                    225
  1032.                    234
  1033.                    240
  1034. -----> maincounter
  1035.                    95
  1036.                    418
  1037.                    419
  1038.                    420
  1039.                    422
  1040. -----> mainscreen
  1041.                    431
  1042.                    439
  1043.                    495
  1044. -----> mainstring
  1045.                    101
  1046.                    456
  1047.                    459
  1048.                    467
  1049. -----> mainx
  1050.                    432
  1051.                    437
  1052.                    496
  1053. -----> mainy
  1054.                    433
  1055.                    438
  1056.                    496
  1057. -----> max_files
  1058.                    60
  1059.                    87
  1060.                    177
  1061. -----> menucounter
  1062.                    310
  1063.                    313
  1064.                    316
  1065.                    317
  1066.                    326
  1067.                    327
  1068.                    345
  1069.                    350
  1070.                    356
  1071.                    362
  1072.                    363
  1073.                    365
  1074.                    372
  1075.                    373
  1076.                    375
  1077.                    382
  1078.                    387
  1079.                    388
  1080.                    392
  1081. -----> originalx
  1082.                    97
  1083. -----> originaly
  1084.                    99
  1085. -----> pick_file_menu
  1086.                    303
  1087.                    419
  1088. -----> prompt_record
  1089.                    102
  1090. -----> qcolors.c
  1091.                    52
  1092. -----> qkeys.c
  1093.                    50
  1094. -----> qtypes.c
  1095.                    48
  1096. -----> return_pressed
  1097.                    319
  1098.                    323
  1099. -----> right_arrow_pressed
  1100.                    369
  1101. -----> search_specification
  1102.                    156
  1103.                    165
  1104.                    397
  1105.                    411
  1106. -----> select_a_file
  1107.                    395
  1108.                    456
  1109. -----> startx
  1110.                    217
  1111.                    223
  1112.                    225
  1113.                    232
  1114.                    238
  1115.                    240
  1116. -----> starty
  1117.                    218
  1118.                    224
  1119.                    226
  1120.                    233
  1121.                    239
  1122.                    241
  1123. -----> sx
  1124.                    76
  1125. -----> sy
  1126.                    78
  1127. -----> unhighlight_area
  1128.                    215
  1129.                    325
  1130. -----> up_arrow_pressed
  1131.                    347
  1132. -----> update_current_coordinates
  1133.                    133
  1134.                    174
  1135. -----> white
  1136.                    67
  1137.                    113
  1138.                    202
  1139. -----> window_depth
  1140.                    68
  1141.                    372
  1142.                    382
  1143. -----> window_lr_x
  1144.                    63
  1145.                    145
  1146.                    198
  1147. -----> window_lr_y
  1148.                    64
  1149.                    68
  1150.                    141
  1151.                    199
  1152. -----> window_ul_x
  1153.                    61
  1154.                    129
  1155.                    196
  1156. -----> window_ul_y
  1157.                    62
  1158.                    68
  1159.                    130
  1160.                    143
  1161.                    197
  1162. -----> xincrement
  1163.                    65
  1164.                    144
  1165.                    145
  1166.                    318
  1167.                    328
  1168.                    389
  1169.  
  1170.  
  1171. ==========  PROGRAM CONSTANTS  ==========
  1172.  
  1173. ----->    0
  1174.                    61
  1175.                    62
  1176.                    89
  1177.                    91
  1178.                    93
  1179.                    95
  1180.                    97
  1181.                    99
  1182.                    106
  1183.                    115
  1184.                    119
  1185.                    163
  1186.                    164
  1187.                    168
  1188.                    205
  1189.                    285
  1190.                    312
  1191.                    313
  1192.                    314
  1193.                    345
  1194.                    350
  1195.                    365
  1196.                    382
  1197.                    413
  1198.                    418
  1199.                    439
  1200.                    453
  1201.                    458
  1202.                    459
  1203.                    488
  1204.                    495
  1205. ----->    1
  1206.                    130
  1207.                    143
  1208.                    185
  1209.                    290
  1210.                    318
  1211.                    328
  1212.                    334
  1213.                    350
  1214.                    372
  1215.                    382
  1216.                    389
  1217.                    496
  1218. ----->    2
  1219.                    129
  1220.                    289
  1221. ----->    4
  1222.                    202
  1223.                    227
  1224.                    242
  1225. ----->    5
  1226.                    252
  1227. ----->    9
  1228.                    256
  1229.                    285
  1230. ----->   12
  1231.                    107
  1232.                    109
  1233. ----->   13
  1234.                    110
  1235. ----->   15
  1236.                    65
  1237.                    254
  1238. ----->   20
  1239.                    251
  1240. ----->   22
  1241.                    64
  1242. ----->   23
  1243.                    466
  1244.                    467
  1245.                    477
  1246. ----->   24
  1247.                    439
  1248.                    482
  1249.                    495
  1250. ----->   25
  1251.                    314
  1252.                    458
  1253. ----->   29
  1254.                    466
  1255. ----->   44
  1256.                    467
  1257. ----->   46
  1258.                    168
  1259. ----->   50
  1260.                    108
  1261. ----->   60
  1262.                    253
  1263. ----->   79
  1264.                    63
  1265.                    439
  1266.                    495
  1267. ----->  100
  1268.                    60
  1269. -----> 0x10
  1270.                    169
  1271. -----> 0xff
  1272.                    165
  1273.  
  1274.  
  1275. QXREF:  Processing complete for pickfile.c
  1276.