[Info-vax] String Manipulation

Bob Gezelter gezelter at rlgsc.com
Wed Oct 13 09:16:40 EDT 2021


On Wednesday, October 13, 2021 at 6:54:58 AM UTC-4, 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?
HCorte,

Caution is recommended. This approach is extremely brittle in the face of text errors.

Both coding sequences presume that the input string is valid, without verifying that fact.

More information concerning the source string would be helpful.

- Bob Gezelter, http://www.rlgsc.com



More information about the Info-vax mailing list