Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The other way - John's procecure
Message
From
28/06/2000 09:17:40
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00385643
Message ID:
00385669
Views:
7
>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.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform