Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't do a simple REPLACE command
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00305973
Message ID:
00305976
Vues:
28
Elgin,

First your code will fail if there is an index controlling the records because as soon as you replace the new record moves to a different locaiton in teh index and the "next" record is no longer the same as it was before the replace.
************************
SELECT 1
  GO TOP
  DO WHILE .NOT. EOF()
    cDupeId=EVALUATE(SYS(14,1)) && Get the Value of index tag number 1
    SKIP
    IF cDupeId=EVALUATE(SYS(14,1))
	   REPLACE samplenum WITH STR(VAL(samplenum)+1)
      *BROWSE
    ENDIF
  ENDDO
*************************
To answer the rest of your question, we should know what cDupeID is, is that a field that holds the concatenated field values? If it is how are you changing the value in that field after you increment the SampleNum? Also, STR() by default returns a right justified 10 digit string of numbers with leading spaces. If your field is less than 10 characters wide you may be getting a blank value as the string is truncated to fit. You should use the secon argument of STR() to set the length of the string to match the field width. If the field is 5 use STR(VAL(SampleNum)+1,5).

>For the most part the index tag #1 is made of up of a date+tank+apparatus+samplenum. And the data always starts with the samplenum equal to 1 in every case. When the complete index tag number 1 evaluates to a duplicate, I want it to increment the samplenum by one so it will no longer be a duplicate.

What do you mean "For the most part..."? Are there cases where the index tag does not contain the concatenation of those fields?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform