>To David, Jonh and other fridens...
>
>I've put John's code into a prg called test.prg
>and added the line Do RerversIt into the prg.
>as shown below
>
>
>DO ReverseIt
>
>
>PROCEDURE ReverseIt
> PARA cText
> cReversed="ABCDE"
> FOR I = LEN(cText) TO 1 STEP -1
> cReversed=cReversed+SUBS(cText,i,1)
> ENDFOR
> RETURN cReversed
>ENDPROC
>
This won't do what you want.
Procedure ReverseIt
LPARAMETER cText
LOCAL cReversed, nI
cReversed = ''
FOR nI = LEN(cText) TO 1 STEP -1
cReversed = cReversed + SUBST(cText,nI,1)
ENDFOR
RETURN cReversed
ENDPROC
? ReverseIt('ABCDE')
I've found that SUBSTR() requires 5 characters to clearly delineate the function. In addition, the string to reverse is passed in as the parameter, not embedded in the function. YMMV. This works.
>
>When I type: "do test.prg"
>
>It returns the error message below
>
>"Function argument type is invalid for this value"
>
Yep - you've passed no parameter, as a default, unpassed parameters are assigned a type of 'L' (Logical) and a value of .F.