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:
00306001
Vues:
35
Jim,

Thanks for the information on the STR() command. As I was telling David, that was the problem, I didn't specify a field length parameter.

Regarding the controlling index - yes it is controlled by an index made of the fields: equipnum+tank+sampledate+samplenum, but I think it's OK that I use the REPLACE command because the only element of the index that is changing is the "samplenum". It will increase by one, thereby leaving the record in position. I know this will only work for two duplicate records in a row, I have to add some additional code to handle an occasion where the duplication exceeds two records.

--Regarding: "For the most part" -- I didn't really mean that, the index will always contain all of those fields mentioned above.

The "cDupeId" is just a variable I use to identify the value of the index.

Thanks again for the information. You guys are really helpful.

P.S.
I have been enjoying your videos from AppDev. They have really given me a boost along the road to becoming more proficient with VFP. I have been through all of them already, but I know I have to sit down and go through them again more slowly this time.

Elgin


>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?
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform