home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / DATABASE / DB3TIP2.ZIP / DB3TIP2.TXT
Text File  |  1989-03-21  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                dBase III Subroutines  
  7.                                ----- --- ----------- 
  8.  
  9.  
  10.  
  11.       DBase III allows for many applications to be performed, yet a few
  12.       necessary tasks are unavailable using commands alone. 
  13.       For example, punctuating numbers.  The PICTURE clause allows for
  14.       formatting numbers while using @ GET's only - there is no PICTURE clause
  15.       for displaying numbers on a printout.  Because of this, I have developed
  16.       a subroutine to punctuate numbers.  DBase III also, has no command for
  17.       determining the number of month between two dates.  Therefore, I have
  18.       created a subroutine to do this, as well.   
  19.  
  20.  
  21.  
  22.       The following subroutine will place commas into numbers up to 9 digits
  23.       in length.  The number to which punctuation is desired is NUMBER,
  24.       resulting value is placed in NUMOUT.  Negative numbers will be preceeded
  25.       by a hyphen '-'. 
  26.  
  27.       For example the number 123456789 will result in 123,456,789.  
  28.  
  29.  
  30.         
  31.            IF NUMBER < 0 
  32.               SGN = '-'
  33.               NUMBER = -(NUMBER) 
  34.            ELSE
  35.               SGN = ' ' 
  36.            ENDIF 
  37.            * 
  38.            NUMC = STR(NUMBER,9) 
  39.            * 
  40.            DO CASE 
  41.               CASE NUMBER >= 1000000 
  42.                  NUMOUT = SUBSTR(NUMC,1,3)+','+SUBSTR(NUMC,4,3)+','+SUBSTR(NUMC,7,3) 
  43.               CASE NUMBER >= 1000 .AND. NUMBER < 1000000 
  44.                  NUMOUT = SUBSTR(NUMC,4,3)+','+SUBSTR(NUMC,7,3) 
  45.               CASE NUMBER < 1000 
  46.                  NUMOUT = NUMC 
  47.            ENDCASE 
  48.            * 
  49.            NUMOUT = SGN + NUMOUT 
  50.             
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.       The following subroutine will determine the number of months between two
  73.       dates - NEW_DATE (most recent date) and OLD_DATE, resulting value is
  74.       placed in NUM_MTHS.
  75.  
  76.  
  77.  
  78.            NEWMTH = MONTH(NEW_DATE) 
  79.            NEWYR  = YEAR(NEW_DATE) 
  80.            OLDMTH = MONTH(OLD_DATE) 
  81.            OLDYR  = YEAR(OLD_DATE) 
  82.            * 
  83.            IF NEWYR # OLDYR 
  84.               FIRST = 13 - OLDMTH 
  85.               SECOND = NEWMTH - 1 
  86.               THIRD = (NEWYR - OLDYR - 1) * 12 
  87.               NUM_MTHS = FIRST + SECOND + THIRD 
  88.            ELSE 
  89.               NUM_MTHS = NEWMTH - OLDMTH 
  90.            ENDIF 
  91.  
  92.  
  93.  
  94.  
  95.  
  96.       by Shawnn L.  Wilmoth 
  97.       uploaded by R. R. Richardson 
  98.       ID1272 
  99.       Gene Plantz's BBS in Chicago 
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.