It is possible to extract the initials from a name field. It requires the repeated search for blanks in the field NAME and then adding the next letter to the string of initials. Here is my solution, which checks for up to six initials and will not allow a leading blank nor double blanks within name (as either would put a blank into the initials). Of course, this does not help you if the initials are not correct (e.g. if someone entered your name as PEDROE MMANUEL AMERICANO DO BRASIL ).
The SOUNDEX function might be more useful if spelling is likely to be a problem.
Jamie
For the simple .QES file:
name <A > inits <A > Up to six initials nextvar #
here is the .CHK file:
before file define initpos ## global define tempname _________________________ global end
NAME AFTER ENTRY tempname = name inits = copy(tempname,1,1) if inits = . then help "Cannot have name starting with blank" goto name exit endif initpos = pos(" ",tempname) if initpos > 0 then help "Cannot have name with double blanks" goto name exit endif
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
END END
Pedro wrote:
Therefore I ask to you guys if there is a way in the chk file to retrieve from the name the initials of the full name.
v1 number #########
v2 name:
<A >
v3 initials: <A >
The objective is:
v2 name: JENS LAURISTEN
v3 initials: JL
v2 name: PEDRO EMMANUEL AMERICANO DO BRASIL
v3 initials PEADB