August 11, 2009

Malkie, I don't think there is an easy way to do this, because DP does 
not allow counting subfields backwards. So you need a formula like this, 
in which the highest number equals the maximum number of words in the 
target field. Of course each extra line requires an extra "ENDIF".

If subfield[P2F3;" ";8 > "" then  subfield[P2F3;" ";8]
elseif  subfield[P2F3;" ";7] > "" then  subfield[P2F3;" ";7]
elseif  subfield[P2F3;" ";6] > "" then  subfield[P2F3;" ";6]
elseif  subfield[P2F3;" ";5] > "" then  subfield[P2F3;" ";5]
elseif  subfield[P2F3;" ";4] > "" then  subfield[P2F3;" ";4]
elseif  subfield[P2F3;" ";3] > "" then  subfield[P2F3;" ";3]
elseif  subfield[P2F3;" ";2] > "" then  subfield[P2F3;" ";2]
else P2F3
ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF

REMEMBER, you have to use the F4 selection to put in meaningful field 
names. Aside from that you can copy & paste this, as expanded for your 
need, from your word processor.

To get everything but the first word shoud be fairly easy. I have not 
tested this, though.
cat.t[subfield[P2F3;" ";2]; subfield[P2F3;" ";3]; subfield[P2F3;" ";4]; 
subfield[P2F3;" ";5]; subfield[P2F3;" ";6]; subfield[P2F3;" ";7]; ...  
subfield[P2F3;" ";17]]

To get everything but the last word is harder. I have not tested this, 
either. But try something like
cat.t[if subfield[P2F3;" ";2] = "" then "" else subfield[P2F3;" ";1] 
endif; if subfield[P2F3;" ";3] = "" then "" else subfield[P2F3;" ";2] 
endif; if subfield[P2F3;" ";4] = "" then "" else subfield[P2F3;" ";3] 
endif;   ... {To the highest number of words in your field}]

Don Codling
Windows XP home, SP3
2 GBytes RAM

[email protected] wrote:
> Hi Everyone;
>
> I desperately need your expertise. I would like to make a formula in a 
> field (not in a report) that would automatically extract the last word of 
> another field, something like with a subfield or substring function or 
> whatever. The amount of words in that field are not identical. It can 
> vary between 2 and 10 or even more.  
>
> Also, how would I extract all the words of a field besides the last
> word or besides the first word?
>
> Malkie
>
> _______________________________________________
> Dataperf mailing list
> [email protected]
> http://lists.dataperfect.nl/mailman/listinfo/dataperf
>
>   
_______________________________________________
Dataperf mailing list
[email protected]
http://lists.dataperfect.nl/mailman/listinfo/dataperf

Reply via email to