07312021, 01:01 PM
Hello, playing with the new string functions in free42 I notice that it seems SUBSTR uses an Y index starting from 0, while the X index starts from 1.
So to get the Nth character of a string or element of a list, you have N1 in Y and N in X
Is it the expected behaviour?
Or maybe the intepretation is different: SUBSTR takes element from Y included to X excluded?
As a simple exercise, this is a reusable routine to get the nth string character or list element:
LBL "NTH"
FUNC 21
RCL ST X
1

X<>Y
SUBSTR
RTN
thank you
Mark
So to get the Nth character of a string or element of a list, you have N1 in Y and N in X
Is it the expected behaviour?
Or maybe the intepretation is different: SUBSTR takes element from Y included to X excluded?
As a simple exercise, this is a reusable routine to get the nth string character or list element:
LBL "NTH"
FUNC 21
RCL ST X
1

X<>Y
SUBSTR
RTN
thank you
Mark