Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to replace a value to field(x)?

Status
Not open for further replies.

Inas

Technical User
Sep 9, 2003
20
SG
dunno how to put my question...

got this table like:

fields a a1 a2 a3
record1 a1
record2 a2
record3 a1

how can i output the result to become

fields a a1 a2 a3
record1 a1 1 0 0
record2 a2 0 1 0
record3 a1 1 0 0

meaning to say, if a="a1", then replace a1 with "1", a2 and a3 with "0"

i tried to output the field name to an array using

y=AFIELDS(p)

FOR x=1 TO y STEP 1
? field(x)
ENDFOR

then i was using something like:

if a=field(x)
repl field(x) with "1"
endif

that gave me an error ... how can i solve this?
 
if you use replace, you should do this:

replace &field(x) with blabla

put the & character

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
signify a name with ()

Code:
    if a=field(x)
       repl (field(x)) with "1"
    endif
 
replace all a1 with iif(a='a1',1,0), a2 with iif(a='a2',1,0), a3 with iif(a='a3',1,0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top