Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get all employee
Message
From
10/02/2005 12:28:51
 
 
To
10/02/2005 09:22:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 5
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00985090
Message ID:
00985630
Views:
30
I was attempting to tidy your code when I noticed it does some things that I can't be sure are errors or correct, so I can't touch it really.

I'd suggest:

1) as you've been told many times, don't select specific numbers to USE your tables in, because i) you may sometime later use the same work area for another table, ii) It's easier to remember your table's alias rather than the number of its work area.
e.g. select 22         && wrong
     use MyTable 

     Use MyTable in 0  && right 
2) After a Set Filter, you must move the file pointer, e.g. Go Top, before the filter takes effect. I see you set filter then do a COUNT, which will give you a pre-filter result.

3) As I said earlier, do a scan ... endscan for scanning throuigh tables, rather than

Do while .T.
If EOF()
EXIT
Endif
Enddo

you don't need to SKIP (automatically done at the end of the loop)

4) Try some sensible indenting, to help you follow the code, e.g.
SCAN
  If MyCondition
    Code
    Code
    If condition2
        Do while x = y
        Enddo
    Endif
  Endif
EndSCAN
5) You do things like :
>select 1
>use mstr
every time through the loop. This means you're continually opening the same table over and over again. All you need to do is:

Use Mstr in 0

at the top of the prog then, in the loop:

Select Mstr

I must get on with my own work. And this isn't the problem you started with but soomething entirely different, and you have not said if the code IS a problem. So I don't know what else I can say.

HTH


>hi,
>thanks for evry thing,
>i don't mean any thing when i send the code to Mr.Alex,
>he sugest new thing i must do to fix this code,and i send it at the same THRED.
>and "Too many cooks spoil the soup", not all the time, maybe in the bast :)
>
>BTW,this is my code if you have time to see it,
>
>close all
>set talk off
>set echo off
>set safety off
>
>   select 22
>     use newtax excl
>     zap
>
>     select 4
>     use tax1
>     index on no to kkk
>
>     m.no=no
>     m.nettot=nettot
>     m.nam=nam
>     m.nam2=nam2
>     m.nam3=nam3
>     m.nam4=nam4
>     m.month1=monthnam
>
>     select 4
>     do while .t.
>
>     scatter memvar
>     m.aa=nettot
>    select 5
>    use tax2
>    append blank
>    gather memvar
>
>select 1
>use mstr
>locate for no=m.no
>m.dat=dat
>M.NATI=NATI
>M.CHILD=CHILD
>M.STAT1=STAT1
>M.RNTPLAC=RNTPLAC
>M.AS1=0
>M.UNV=UNV
>M.UNV1=UNV1
>M.UNV2=UNV2
>M.UNV3=UNV3
>M.UNV4=UNV4
>
>
>       IF M.UNV<>SPACE(10)
>          M.AS1=M.AS1+1
>       ENDIF
>
>       IF M.UNV1<>SPACE(10)
>          M.AS1=M.AS1+1
>       ENDIF
>
>
>       IF M.UNV2<>SPACE(10)
>          M.AS1=M.AS1+1
>       ENDIF
>
>       IF M.UNV3<>SPACE(10)
>          M.AS1=M.AS1+1
>        ENDIF
>
>       IF M.UNV4<>SPACE(10)
>          M.AS1=M.AS1+1
>       ENDIF
>
>       replace dat with m.dat
>       replace NATI with m.NATI
>       replace CHILD with m.CHILD
>       REPLACE RNTPLAC WITH M.RNTPLAC
>
>   IF M.STAT1="&#1605;&#1578;&#1586;&#1608;&#1580;     "
>      REPLACE STAT1 WITH "&#1605;&#1578;&#1586;&#1608;&#1580; "
>   ELSE
>      REPLACE STAT1 WITH "&#1575;&#1593;&#1586;&#1576;"
>   ENDIF
>
>
>
>select 4
>skip
>if m.no<>no
>  select 5
>  use tax2 excl
>  index on no to kk
>  go top
>  set filter to no=m.no
>  count to df
>  sum nettot to kk for m.no=no
>  sum totcut to ll for m.no=no
>  sum cut5 to ee for m.no=no
>  sum cut4 to tt for m.no=no
>  sum MSAL to ff for m.no=no
>  sum cut1 to cx for m.no=no
>  sum cut2 to ew for m.no=no
>  sum cut3 to ty for m.no=no
>  sum allad to qty for m.no=no
>  sum vdisc to tareq for m.no=no
>  SUM TOTALADD TO ERT for m.no=no
>  M.ERT1=ERT-tareq
>
>  select 22
>  use newtax
>  append blank
>  gather memvar
>   replace no with m.no
>   replace totalsal with kk
>   replace totcut with ll
>   replace cut5 with ee
>   replace cut4 with tt
>   replace MSAL with ff
>   replace cut1 with cx
>   replace cut2 with ew
>   replace cut3 with ty
>   replace allad with qty
>   replace countt with df
>   replace total with (kk+ll)-(cx+ew+ty)
>   replace AS1 with m.AS1
>   replace vdisc with tareq
>   replace TOTALADD with M.ERT1
>
>    select 5
>      use tax2 excl
>      index on no to kk
>      report form COPtax1
>      zap
>endif
>
>   select 4
>     m.no=no
>     m.nam=nam
>     m.nam2=nam2
>     m.nam3=nam3
>     m.nam4=nam4
>     m.month1=monthnam
>  if eof()
>      exit
>     else
>  endif
>
>enddo
>
>
>
>BEST REGARDS
>>Well I guess Alex will be sorting it out then. We have saying: "Too many cooks spoil the soup", so I'll leave you two to it. However, you DO HAVE a table called EMPLOYEE as that is the name of the cursor that you SELECTed your data into.
>>
>>>hi,
>>>thank so much, i want to explain what i need to do exactly,
>>>and i sent my code to Mr.Alex this code make all this things,it works,
>>>but i write much code to do that .
>>>
>>>WAHT I WANT TO DO
>>>*********************
>>>i dont have any table name is emplyee,
>>>i have mstr with many fields one of them is NO as employee number or customer number and a nother field DAT as the date when he start working in the company,
>>>mytable tax1 have the same NO, I need to get the date form mstr for every employee with fields from tax1,
>>>and print all employees ,evry one at one paper ,without stoping, stop at the end
>>>thanks again.
>>>
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform