home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_01 / 2n01029a < prev    next >
Text File  |  1990-09-20  |  510b  |  22 lines

  1.  
  2. FUNCTION GarmentChk (a : INTEGER) : BOOLEAN;
  3. { returns TRUE if the item code is valid }
  4. VAR
  5.  total, i, workdigit : INTEGER;
  6. BEGIN
  7. total := 0;
  8. FOR i := 1 TO 7
  9. DO BEGIN
  10.    workdigit := a MOD 10;
  11. { double even digits }
  12.    IF NOT (Odd(i))  
  13.    THEN workdigit := workdigit + workdigit;
  14. { cast nines }  
  15.    total := total + ((workdigit MOD 10) + (workdigit DIV 10));
  16. { get next digit from rightmost side }
  17.    a := a DIV 10; 
  18. { return a Boolean result }
  19. GarmentChk := ((total MOD 10) = 0)
  20. END;
  21.  
  22.