[Info-vax] String Manipulation
Arne Vajhøj
arne at vajhoej.dk
Wed Oct 13 08:35:27 EDT 2021
On 10/13/2021 6:54 AM, HCorte wrote:
> Have a string named MILLCON that contain "," as delimiter to split in two substrings have two aproches:
>
> 1º using routine ELEMENT from STR$
>
> STR$ELEMENT(MESSCON,0,",",MILLCON)
> STR$ELEMENT(IP_ADDRESS,1,",",MILLCON)
>
> 2º using routine INDEX and LEN from LIB$
>
> POS_AUX = LIB$INDEX(MILLCON,",")
> MESSCON = MILLCON(1:POS_AUX-1)
> IP_ADDRESS = MILLCON(POS_AUX+1:LIB$LEN(MILLCON)-(POS_AUX+1))
>
> is either aproach good or is there one bether and if so why?
STR$ELEMENT way seems to be the cleanest code by far.
Also note that (assuming Fortran) LIB$INDEX and LIB$LEN
could be replaced by INDEX and LEN.
Arne
More information about the Info-vax
mailing list