Topic:   replace field method   (Read 2317 times)


0 Members and 1 Guest are viewing this topic.

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
replace field method
« on: December 26, 2011, 08:10:40 AM »

-Method name: ChangeField$

-Parameters: source$,separator$,fieldNumber,output$

-return type: string

-Method:
LET tempstr$ = ""
FOR field = 1 TO COUNTFIELDS(source$, separator$)
   IF field = fieldNumber THEN LET tempstr$+=output$ + separator$
   IF field <> fieldNumber THEN LET tempstr$+=NTHFIELD$(source$, separator$, field) + separator$
NEXT
LET tempstr$ = MID$(tempstr$, 1, LEN(tempstr$) - LEN(separator$))
RETURN tempstr$


EXAMPLE:
let string$="1,1,1,1,0,1,1,1"

//so if you wanted to change the 5th field to a "1" you would

let string$=changfield$(string$,",",5,"1")
« Last Edit: December 26, 2011, 08:12:35 AM by EqwanoX »