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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What function returns position of a character in 4GL

Status
Not open for further replies.

DTRISNA

Programmer
Nov 27, 2002
3
US
I believe there is a function in 4GL to return the position of a certain character in a string?
For example: LET firstname ='ALBERT H.'
I need to manipulate firstname to become 'ALBERT, H.' by searching the first occurence of <space>.
Thanks
David T.
 
Hi David,

I do not know about the existance of such built-in function in 4GL. You may look for a workaround as follows:

main
define idx smallint, scratch char(20)
let scratch = &quot;'ALBERT H.&quot;
let idx = at(scratch,&quot; &quot;)
if idx > 0 then
let scratch[idx]=&quot;,&quot;
end if
end main

function at(string,pattern)
define string varchar(255), pattern char(1),
i,ret smallint

let ret=0
for i=1 to length(string clipped)
if string[i,i] = pattern then
let ret=i
exit for
end if
end for
return ret
end function

Regards
Shriyan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top