Additon in character type data  
Author Message
Tariq Mehmood





PostPosted: Visual FoxPro General, Additon in character type data Top

Dear Experts

Field1 of Table1 has character type data, but digits.
In Field2, I want to replace data as under
801--------801
803--------802
807--------803
809--------804
902--------901
905--------902
906--------903
908--------904
Please help



Visual FoxPro2  
 
 
yanyee





PostPosted: Visual FoxPro General, Additon in character type data Top

 
Dear Experts

Field1 of Table1 has character type data, but digits.
In Field2, I want to replace data as under
801--------801
803--------802
807--------803
809--------804
902--------901
905--------902
906--------903
908--------904

Please help

sele Table1

go top

i = 1

do while !eof()

    if i = 4

       i = 1

    endi

    mfield2 = substr(alltrim(field1),1,2)

   LcField2 = RIGHT("mField2"+ALLTRIM(STR(i)),3)

     i = i + 1

     skip

     repl field2 with Lcfield2

enddo

HTH



 
 
Tariq Mehmood





PostPosted: Visual FoxPro General, Additon in character type data Top

Dear Sir,

Following line needs to edit

if i = 4

i = 1

endi

Becuase codes of every group my vary in quantity.

such as

501------------501

508-----------502

801--------801
803--------802
807--------803
902--------901
905--------902
906--------903
908--------904

Please help again



 
 
Tamar E. Granor





PostPosted: Visual FoxPro General, Additon in character type data Top

For us to help you, you have to tell us what the rules are for making the change.

Is the idea that you want to take all the values with the same first digit and renumber them in order

Tamar

 
 
Tariq Mehmood





PostPosted: Visual FoxPro General, Additon in character type data Top

But I need following results


column2=alltrim(substr(column1,1,2))+auto increment number starts from 1 as below

801--------801
803--------802
807--------803
809--------804
902--------901
905--------902
906--------903
908--------904

Please help again



 
 
yanyee





PostPosted: Visual FoxPro General, Additon in character type data Top

 
 
Dear Experts

Field1 of Table1 has character type data, but digits.
In Field2, I want to replace data as under
801--------801
803--------802
807--------803
809--------804
902--------901
905--------902
906--------903
908--------904

Please help

changed this to

mfield2 = ""

if substr(field1,1,2)<>mfield2

    i = 1

endi

 

if i = 4

    i = 1

endi

sele Table1

go top

i = 1

do while !eof()

    if i = 4

       i = 1

    endi

    mfield2 = substr(alltrim(field1),1,2)

   LcField2 = RIGHT("mField2"+ALLTRIM(STR(i)),3)

     i = i + 1

     skip

     repl field2 with Lcfield2

enddo

HTH



 
 
CetinBasoz





PostPosted: Visual FoxPro General, Additon in character type data Top


Tariq,
This is one way.