Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Translate from FPD26 to VP6
Message
De
23/04/2005 04:49:30
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/04/2005 02:13:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows '98
Network:
Windows 98
Divers
Thread ID:
01007750
Message ID:
01007762
Vues:
10
>Dear Experts
>
>Following codes works fine in FPD26 but when I run it in VFP6 then computer hangs then I have to power off. ALT+CTRL+DEL also does not work.
>
>What is wrong? Please enable codes to run in VFP6.
>
>F_DATE1=THISFORM.TEXT12.VALUE 	&& {27/10/2004}
>T_DATE1=THISFORM.TEXT11.VALUE	&& {23/02/2005}
>
> STORE 0 To Tb, Tl, Tw, Bw, Lw, W, Tfa, Fa, Ar
> SELECT Flow_ra
> ZAP
> Fdate1 = F_date1
> DO While Fdate1>=F_date1 .and. Fdate1<=T_date1
> STORE 0 To B, L, W, W1, W2
>
> SELECT Fixbook && reccount()=1007
> SUM For (Fix_date=Fdate1) .and. Mode='B' Fix_bag To B
> SUM For (Fix_date=Fdate1) .and. Mode='L' Fix_bag To L
> SUM For (Fix_date=Fdate1) Fix_kg To W
>
> SELECT Fixbill && reccount()=376
> SUM For (Date=Fdate1) Amount To Fa
> R1 = Fa/(W/40)
> Tfa = Tfa+Fa
> Tb = Tb+B
> Tl = Tl+L
> Tw = Tw+W
>
> IF B>0 .or. L>0 .or. W>0
> SELECT Flow_ra
> APPEND Blank
> REPLACE Date With Fdate1, Bags With B, Lose With L, Total_bags With Tb,  ;
>         Total_lose With Tl, Today With W, T_weight With Tw, Rate With R1,  ;
>         Fix_a With Fa, Total_a With Tfa, Avr_rate With Tfa/(T_weight/40)
> ENDIF
> Fdate1 = Fdate1+1
> ENDDO
>
Tariq,
Always prefix your field variables with their alias and memory variables with m. (don't listen to those who say m. is not needed). Only doing that should solve the problem.
*At least crucial at these 2 places
DO While m.Fdate1>=m.F_date1 .and. m.Fdate1<=m.T_date1
*...
Fdate1 = m.Fdate1+1
ENDDO
Otherwise it's unclear if Fdate1, F_date1 and T_date1 are memory variables or fields of current alias. If anyone of them existed in current alias then field value takes precedence.
Your code seem to be like doing this:
F_DATE1=Thisform.TEXT12.Value 	&& {27/10/2004}
T_DATE1=Thisform.TEXT11.Value	&& {23/02/2005}

Select Flow_ra
Zap

Select fbk.Fix_Date,;
  sum(Iif(fbk.Mode='B',1,0)*fbk.Fix_Bag) As B, ;
  sum(Iif(fbk.Mode='L',1,0)*fbk.Fix_Bag) As L, ;
  sum(fbk.Fix_Kg) As W, ;
  sum(Nvl(fbl.Amount,0)) As Fa ;
  from FixBook fbk ;
  left Join FixBill fbl On fbk.Fix_Date = fbl.Date ;
  where Fix_Date Between m.F_DATE1 And m.T_DATE1 ;
  group By 1 ;
  into Cursor crsFix ;
  nofilter

Store 0 To Tb, Tl, Tw, Tfa

Scan For crsFix.B + crsFix.L + crsFix.W > 0
  R1  = crsFix.Fa/(crsFix.W/40) && What if W is 0?-Data overflow possibility here
  Tfa = m.Tfa+crsFix.Fa
  Tb  = m.Tb+crsFix.B
  Tl  = m.Tl+crsFix.L
  Tw  = m.Tw+crsFix.W

  Insert Into Flow_ra ;
    (Date, Bags, Lose, Total_bags,  ;
    Total_lose, Today, T_weight, Rate,  ;
    Fix_a, Total_a, Avr_rate) ;
    values ;
    (crsFix.Fix_Date, crsFix.B, crsFix.L, m.Tb,  ;
    m.Tl, crsFix.W, m.Tw, m.R1,  ;
    crsFix.Fa, m.Tfa, m.Tfa/(m.Tw/40))
Endscan
PS: Also make sure textbox values are date and not datetime. If they're datetime your code was incrementing second not day. This is safer:
with thisform
F_DATE1=iif(type('.TEXT12.Value')='T',ttod(.TEXT12.Value),.TEXT12.Value) && {27/10/2004}
T_DATE1=iif(type('.TEXT11.Value')='T',ttod(.TEXT11.Value),.TEXT11.Value) && {23/02/2005}
endwith

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform