home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / DMSUDF.ZIP / DMSUDF.PRG < prev   
Encoding:
Text File  |  1987-07-28  |  9.7 KB  |  325 lines

  1. **||DMS.PRG updated on- Tuesday, July 28, 1987 at- 1:36 am
  2. **||(c)1987, D M Sampson Consulting
  3.  
  4. function approx
  5. parameter record,fldno
  6. ndxfld = field(fldno)
  7. seek record
  8. if .not. found()
  9.      goto 1
  10.      replace &ndxfld with record
  11.      skip 
  12.      if  eof()
  13.          go top 
  14.      endif
  15.      store recno() to currec
  16.      goto 1
  17.      do case
  18.      case type('&ndxfld') = 'C'
  19.           replace &ndxfld with space(len(&ndxfld))
  20.  
  21.      case type('&ndxfld') = 'N'
  22.           replace &ndxfld with 0
  23.  
  24.      case type('&ndxfld') = 'D'
  25.           replace &ndxfld with ctod('  /  /  ')
  26.  
  27.      otherwise
  28.           ?? chr(07)+chr(07)
  29.           @ 23,00
  30.           @ 23,00 say 'Run Time Error:  Function Approx() can only use'
  31.           @ 24,00
  32.           @ 24,00 say '                 field types C,N,D'
  33.           close databases
  34.           quit
  35.      endcase
  36.      goto currec
  37. endif
  38. return recno()
  39.  
  40.  
  41.  
  42.  
  43. function filehere
  44. parameter _chr1,_chr2,_chr3,_fname
  45. store .t. to ok
  46. if .not. file(_fname)
  47.      ?? chr(07)+chr(07)
  48.      save screen to _temp
  49.      @ 09,10 clear to 16,68
  50.      @ 09,10 to 16,68 double
  51.      @ 11,20 say 'YOU ARE MISSING YOUR '+upper(fname)+' FILE'
  52.      center(12,trim(substr(_chr1,1,50)))
  53.      center(13,trim(substr(_chr2,1,50)))
  54.      center(14,trim(substr(_chr3,1,50)))
  55.      set console off
  56.      wait
  57.      set console on
  58.      restore screen from _temp
  59.      store .f. to ok
  60. endif
  61. return ok
  62.  
  63.  
  64. function prntoff
  65. set print off
  66. set device to screen
  67. set console on
  68. return .t.
  69.  
  70.  
  71. function prnton
  72. set print on
  73. set device to print
  74. set console off
  75. return .t.
  76.  
  77.  
  78.  
  79. ** File Name..: ARRAYS.PRG
  80. ** Author.....: David M Sampson
  81. ** Date.......: February 19, 1987
  82. ** Notice.....: (c) 1987 David M Sampson, All Rights Reserved.
  83. ** Notes......: This file contains the functions for 2, 3 and 4
  84. **              Dimensional arrays to be used with Clipper arrays.
  85. **
  86. ** This Function Controls the Element Pointer for a 2 Dimensional Array
  87. ** The array would be Declared in this manner: Declare array[xe * ye]
  88. **     where xe and ye carry the total number of elements for the
  89. **     x and y axis.
  90. **
  91. **     EXAMPLE: store 3  to x,xe    && first level
  92. **              store 30 to y,ye    && lowest level
  93. **              declare arrayname[xe * ye]
  94. **              ? arrayname[r2(2,25,xe)] displays the value of the
  95. **                                       25th position in the 2nd element
  96. function r2
  97. parameter x,y,ye
  98. return (((x-1) * ye) + y)
  99.  
  100. ** This Function Controls the element pointer for a 3 dimensional array
  101. ** This array would be declared in a similar manner as the 2 dimensional
  102. ** array, in this manner: Declare arrayname[xe * ye * ze]
  103. ** where xe, ye, and ze carry the total number of positions for the
  104. ** x, y and z elements respectively.
  105. **
  106. **     EXAMPLE: store 4  to x,xe
  107. **              store 10 to y,ye
  108. **              store 8  to z,ze
  109. **              declare arrayname[xe * ye * ze]
  110. **              ? arrayname[r3(3,9,6,ye,ze)] displays the value in the
  111. **                                           6th position of the 
  112. **                                           9th Y element of the
  113. **                                           3rd X element.
  114.                 
  115. function r3
  116. parameter x,y,z,ye,ze
  117. return (((x-1) * ye * ze) + ((y-1) * ze) + z)
  118.  
  119.  
  120. function r4
  121. parameter w,x,y,z,xe,ye,ze
  122. return (((w-1) * xe * ye * ze) + ((x-1) * ye * ze) + ((y-1) * ze) + z)
  123.  
  124.  
  125. ** RETURNS COLUMN NUMBER TO RIGHT JUSTIFY MESSAGE AT COLUMN NUMBER '_COL' 
  126. function rjust
  127. parameter _row,_col,_mess
  128. @ _row,_col-len(mess) say mess
  129. return .t.
  130.  
  131.  
  132. ** RETURNS COLUMN NUMBER TO CENTER MESSAGE IN 'COL' COLUMNS
  133. function center
  134. parameter _row,mess
  135. @ _row,(80-len(mess))/2 say mess
  136. return .t.
  137.  
  138.  
  139.  
  140.  
  141. **  THIS IS THE BASIC, GENERIC VERSION.
  142. **  PLEASE DO NOT MODIFY THIS FOR A SPECIFIC APPLICATION.
  143. **  COPY THIS AND MAKE MODIFICATIONS TO THE COPY ONLY.
  144. **
  145. **
  146. ** Function Name...: LOOKUP()
  147. ** Author..........: David M. Sampson
  148. ** Initial Date....: 01/28/87
  149. ** Notice..........: (no copyright)
  150. ** Last Update.....: (see first line above)
  151. ** Comments........:
  152. **
  153. **  This function moves to the work area indicated by the parameter 'area'
  154. **  performs a search (the .dbf file must be indexed on 'code') for 'code'
  155. **  then, if found, returns the value of the field 'fldno'
  156. **  if not found it returns an appropriate error message.
  157. **  (Just incase it is not obvious,   THIS WORKS ONLY COMPILED UNDER CLIPPER)
  158. **
  159. **  EXAMPLE:
  160. **          lookup() was originally designed to be used with the clipper
  161. **          VALID parameter with its @ say... get... verb 
  162. **          (i.e.@ row,col say <string> get <varC> VALID lookup(<varC>,'G',2))
  163. **          but I could think of applications to use it with the  IF,
  164. **          DO WHILE -OR- THE DO CASE syntax.
  165. **
  166. **          if you want to make sure input is being made accurately,
  167. **          especially when data is changing frequently, you could 
  168. **          index a database in the valid entries (Account code in 
  169. **          Accounting, State Abbreviations (CA, Calif....) etc...)
  170. **          then attach this function after the VALID command and you
  171. **          will not beable to leave that field without a valid entry.
  172. **          This is even greater when you consider that it works in the
  173. **          middle of an @ say... get... read construct.
  174. **
  175. **          Give me some feed back if you are interested at (619) 236-1182
  176. **          -or-  on the Source (DBFSIG, NANSIG)
  177. **          
  178. Function lookup
  179. parameter code,area,fldno  
  180. public ok                             
  181. *** THESE 3 LINES MUST BE IN THIS ORDER!!!
  182. ***
  183. store alias()            to currarea  && TAG CURRENT AREA TO RETURN TO
  184. select &area                          && MOVE TO LOOKUP FILE WORK AREA
  185. store field(fldno)       to fldname   && PASS FIELD NAME TO RETURN INFO FROM
  186. ***
  187. store upper(trim(code))  to code      
  188. set exact on
  189. seek code                                   
  190. if found() 
  191.    store &fldname to string                 
  192.    @ row(),col()+2               && THESE TWO LINES ASSUME YOU WANT TO PRINT
  193.    @ row(),col()+2 say string    && THE 'STRING' TO THE RIGHT OF THE INPUT
  194.    @ 15,00 clear                            
  195.       store .t.             to ok,kontinue     
  196. else
  197.    ?? chr(07)                               
  198.    if len(code)>0
  199.      string = code+' IS NOT VALID'
  200.    else
  201.      string = 'BLANK ENTRY IS NOT VALID'
  202.    endif
  203.    @ row(),col()+2               && THESE TWO LINES ASSUME YOU WANT TO PRINT
  204.    @ row(),col()+2 say string    && THE 'STRING' TO THE RIGHT OF THE INPUT
  205.    @ 15,00,24,79 box chr(201)+chr(205)+;
  206.                      chr(187)+chr(186)+;
  207.                      chr(188)+chr(205)+;
  208.                      chr(200)+chr(186)
  209.    go top
  210.    store 16        to row
  211.    store 02        to col
  212.    store field(1)  to field1
  213.    store field(2)  to field2
  214.    do while .not. eof()
  215.      do while .not. eof() .and. row<24
  216.        @ row,col say upper(&field1)+' : '+substr(&field2,1,10)
  217.        skip
  218.        row = row+1
  219.      enddo
  220.      col = col + 15
  221.      row = 16
  222.    enddo
  223.       store .f.   to ok,kontinue     
  224. endif
  225. set exact off
  226. select &currarea                      && SWITCH BACK TO ORIGINAL WORK AREA
  227. return ok
  228.  
  229.  
  230.  
  231. function implode
  232. parameters r1,c1,r2,c2,incr
  233. store r1               to r_pos1         
  234. store r2               to r_pos2         
  235. store c1               to c_pos1         
  236. store c2               to c_pos2         
  237. store ((r2-r1)/2)/iif(incr<1,1,incr) to r_inc1,r_inc2  
  238. store ((c2-c1)/2)/iif(incr<1,1,incr) to c_inc1,c_inc2  
  239. rest screen
  240. save screen
  241. do while (r_pos1<r_pos2) .and. (c_pos1<c_pos2)
  242.      @ r_pos1,c_pos1 to r_pos2,c_pos2 double     
  243.      r_pos1 = r_pos1+r_inc1                      
  244.      r_pos2 = r_pos2-r_inc2
  245.      c_pos1 = c_pos1+c_inc1
  246.      c_pos2 = c_pos2-c_inc2
  247.      rest screen                                 
  248.      save screen
  249. enddo
  250. return .t.
  251.  
  252.  
  253.  
  254. function explode
  255. parameters r1,c1,r2,c2,incr
  256. store ((r2-r1)/2)+r1   to r_pos1,r_pos2
  257. store ((c2-c1)/2)+c1   to c_pos1,c_pos2
  258. store (r_pos1-r1)/iif(incr<1,1,incr) to r_inc1,r_inc2
  259. store (c_pos1-c1)/iif(incr<1,1,incr) to c_inc1,c_inc2
  260. save screen
  261. do while (r_pos1>r1) .and. (c_pos1>c1)
  262.      @ r_pos1,c_pos1 to r_pos2,c_pos2 double
  263.      r_pos1 = r_pos1-r_inc1
  264.      r_pos2 = r_pos2+r_inc2
  265.      c_pos1 = c_pos1-c_inc1
  266.      c_pos2 = c_pos2+c_inc2
  267.      REST screen
  268.      save screen
  269. enddo  
  270. @ r1,c1 clear to  r2,c2
  271. @ r1,c1 to        r2,c2 double
  272. return .t.
  273.  
  274.  
  275.  
  276. * Function...: response function
  277. * Author.....: David M Sampson
  278. * Date.......: 1985
  279. * Last Update: (see line one above)
  280. * Notice.....: Copyright 1985,1986,1987 David M Sampson. All rights reserved
  281. * Version....: dBASE III, Version 1.00
  282. * Notes......: module to permit automatic display of user requests.
  283. *              an enhancment of dbases 'wait' command. (get it?)
  284. *
  285. *            : Converted to a function on 03/18/87  
  286. *            : parameters are chr1,chr2,time,vald
  287. *            :      chr1 = message to be displayed on line 23
  288. *            :      chr2 = message to be displayed on line 24
  289. *            :      time = delay value for temporary messages
  290. *            :      vald = string of valid keyboard responses
  291. *              
  292. function response
  293. parameter chr1,chr2,time,vald
  294. @ 23,00
  295. @ 24,00
  296. set color to &nvrs
  297. @ 23,(80 - len(chr1))/2 say upper(chr1)
  298. @ 24,(80 - len(chr2))/2 say upper(chr2)
  299. if time > 0
  300.     do while time > 0
  301.         time = time - 1
  302.     enddo
  303. else
  304.  set console off
  305.     wait '' to answr
  306.  set console on
  307. endif
  308. set color to &stnd
  309. @ 23,00
  310. @ 24,00
  311. chr1 = ''
  312. chr2 = ''
  313. answr = upper(answr)
  314. return iif(upper(vald) = 'ALL',.t.,(answr$upper(vald)))
  315.  
  316.  
  317.  
  318. Function ndexdisp
  319. parameter _row, _mess
  320. _expr = _mess+str(recno(),4)+' of '+str(lastrec(),4)
  321. @ row,10 say _expr
  322. return ('')
  323.  
  324. **||End of File-> DMS.PRG
  325.