Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do_while?
Message
De
11/06/2004 13:02:09
 
 
À
11/06/2004 12:52:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00912788
Message ID:
00912794
Vues:
12
INSERT place the pointer to the new inserted record after it have inserted the record, hence your pointer movement.

The first record is duplicated because RECNO () return 1 on an empty cursor and because RECNO () is evaluated before the insert take place.

A better approach might be:
FOR I = 1 TO 10
    INSERT INTO Temp (Int1, Num1) VALUES (I, I * 10)
ENDFOR
HTH

>I tried using "do while" command and it seems to be a bit strange for me but I would like to understand how it works. I used this code:
>Create Cursor temp (int1 i, num1 n(4,0))
>DO WHILE recno() < 10
>  Insert Into temp (int1, num1) Values (RECNO(),RecNo()*10)
>ENDDO
>My questions are:
>- How can this command skip on to the next record of the cursor,I mean, what makes it skip? The same recno should fill up the cursor.
>- In the cursor the first record is duplicated. why? (if I put "skip" just before "enddo" the first record is not duplicated - it works as it should)
>- I looked up all the helps(Hentzen's book, VFP help, MSDN, UT) but I've not found any source for that. Any help?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform