Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: DEREK DODOO
  Where is DEREK DODOO?
 READING, UK
 United Kingdom
 DEREK DODOO
 Tags
Subject: range counter not working well
Thread ID: 143149 Message ID: 143149 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Saturday, August 25, 2007 10:59:35 AM         
   


Dear Expert,

I'm counting the age range of personnel, and grouping them in 5 year intervals, however I noticed that the syntax was skipping some of the age-ranges.

The syntax is as follows :

********************************************************

**************************************************************
**************************************************************

CREATE CURSOR AGE_FIVE ;
(AGE_FGRP C(8),NAME C(5), NUMB N(5))



INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('0-4','004',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('5-9','009',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('10-14','014',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('15-19','019',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('20-24','024',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('25-29','029',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('30-34','034',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('35-39','039',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('40-44','044',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('45-49','049',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('50-54','054',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('55-59','059',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('60-64','064',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('65-69','069',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('70-74','074',0)
INSERT INTO AGE_FIVE (AGE_FGRP,NAME,NUMB) VALUES ('75-79','079',0)




MYEAR=0



**initialisation

SELECT AGE_FIVE
INDEX ON NAME TAG NAME


SELECT VPAYMAST




SCAN

MYEAR=YEAR(DATE())-YEAR(VPAYMAST.DATEBTH)
*MYEAR=ALLTRIM(STR(MYEAR))



SELECT AGE_FIVE
DO CASE

CASE MYEAR>=0 AND MYEAR<4
SELECT AGE_FIVE
MSEEK='004'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=5 AND MYEAR<9
SELECT AGE_FIVE
MSEEK='009'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=10 AND MYEAR<14
SELECT AGE_FIVE
MSEEK='014'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=15 AND MYEAR<19
MSEEK='019'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=20 AND MYEAR<24
SELECT AGE_FIVE
MSEEK='024'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=25 AND MYEAR<29
SELECT AGE_FIVE
MSEEK='029'
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=30 AND MYEAR<34
SELECT AGE_FIVE
MSEEK='034'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=35 AND MYEAR<39
SELECT AGE_FIVE
MSEEK='039'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=40 AND MYEAR<44
SELECT AGE_FIVE
MSEEK='044'
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=45 AND MYEAR<49
SELECT AGE_FIVE
MSEEK='049'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=50 AND MYEAR<54
SELECT AGE_FIVE
MSEEK='054'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=55 AND MYEAR<4
MSEEK='055'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=60 AND MYEAR<64
SELECT AGE_FIVE
MSEEK='064'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=65 AND MYEAR<69
SELECT AGE_FIVE
MSEEK='069'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=70 AND MYEAR<74
SELECT AGE_FIVE
MSEEK='074'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

CASE MYEAR>=75 AND MYEAR<79
SELECT AGE_FIVE
MSEEK='079'
SEEK(MSEEK)
REPLACE NUMB WITH NUMB+1

ENDCASE

MYEAR=0
MSEEK=' '
SELECT VPAYMAST
ENDSCAN
*****************************************************
*****************************************************

The counter for each age group is not correct.

The age_five is a temporary file, I'd like to use
UPDATE
instead of
REPLACE
in the counter.

Pls assist.

ENTIRE THREAD

range counter not working well Posted by DEREK DODOO @ 8/25/2007 10:59:35 AM
RE: range counter not working well Posted by Cetin Basoz @ 8/25/2007 11:46:02 AM
RE: range counter not working well Posted by Cetin Basoz @ 8/25/2007 12:00:10 PM