|
|
| Additon in character type data |
|
| Author |
Message |
Tariq Mehmood

|
Posted: 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 FoxPro1
|
| |
|
| |
 |
yanyee

|
Posted: Visual FoxPro General, Additon in character type data |
Top |
Tariq Mehmood wrote: | 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

|
Posted: 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

|
Posted: 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

|
Posted: 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

|
Posted: Visual FoxPro General, Additon in character type data |
Top |
yanyee wrote: |
| Tariq Mehmood wrote: |
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

|
Posted: Visual FoxPro General, Additon in character type data |
Top |
Text to m.lcVals noshow
1102
1103
1105
703
705
709
801
803
807
809
902
905
906
908
1107
1109
1123
endtext
ALines(aVals,m.lcVals)
Dimension aVals[Alen(aVals),1]
Create Cursor myTable (field1 c(5),field2 i)
Append From array aVals
Index On field1 tag field1
Browse
***********************
Select myTable
Set Order To tag field1
Local field1
field1 = 0
Scan
If !(Int(Val(myTable.Field1)/100) = m.Field1)
Field1 = Int(Val(myTable.Field1)/100)
N = 0
Replace field2 With m.field1*100 + myAutoInc(@m.n) ;
While Int(Val(myTable.Field1)/100) = m.Field1
SKIP -1
Endif
Endscan
Browse
Function myAutoInc(tnValue)
tnValue = m.tnValue + 1
Return m.tnValue
Tariq, This is one way.
|
| |
|
| |
 |
| |
|