anomaly of length function for varchar

Iwan AB <[email protected]> Sun, 19 Feb 2023 08:55:01 +0700
Newsgroups gmane.comp.lang.4gl.aubit.general
Message-ID <CAHJCSmJaGjfwR_=cHC-8=ZwAaCjuXFcF93h20e8LJa41Y3KJ4w@mail.gmail.com>
--===============6663041892781500402==
Content-Type: multipart/alternative; boundary="000000000000476ed405f503d6b7"

--000000000000476ed405f503d6b7
Content-Type: text/plain; charset="UTF-8"

Dear Aubit4GL team,

I found anomaly of length function for varchar variable.

Consider the following program

MAIN
    DEFINE  w_str VARCHAR(5)
    DEFINE  n SMALLINT

    LET w_str = "x  "
    LET n = LENGTH(w_str)
    DISPLAY "1. w_str=", w_str, "; => n=", n

CODE
    n = strlen(w_str);
ENDCODE
    DISPLAY "2. w_str=", w_str, "; => n=", n

END MAIN
it returns:
1. w_str=x  ; => n=     1
2. w_str=x  ; => n=     3

Best regards,

Iwan

--000000000000476ed405f503d6b7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><font face=3D"monospace"=
 size=3D"4">Dear Aubit4GL team,</font><div><font face=3D"monospace" size=3D=
"4"><br></font></div><div><font face=3D"monospace" size=3D"4">I found anoma=
ly of length function for varchar variable.</font></div><div><font face=3D"=
monospace" size=3D"4"><br></font></div><div><font face=3D"monospace" size=
=3D"4">Consider the following program</font></div><div><font size=3D"4"><br=
></font></div><div><div><font face=3D"monospace" size=3D"4">MAIN</font></di=
v><div><font face=3D"monospace" size=3D"4">=C2=A0 =C2=A0 DEFINE=C2=A0 w_str=
 VARCHAR(5)</font></div><div><font face=3D"monospace" size=3D"4">=C2=A0 =C2=
=A0 DEFINE=C2=A0 n SMALLINT</font></div><div><font face=3D"monospace" size=
=3D"4"><br></font></div><div><font face=3D"monospace" size=3D"4">=C2=A0 =C2=
=A0 LET w_str =3D &quot;x=C2=A0 &quot;</font></div><div><font face=3D"monos=
pace" size=3D"4">=C2=A0 =C2=A0 LET n =3D LENGTH(w_str)</font></div><div><fo=
nt face=3D"monospace" size=3D"4">=C2=A0 =C2=A0 DISPLAY &quot;1. w_str=3D&qu=
ot;, w_str, &quot;; =3D&gt; n=3D&quot;, n</font></div><div><font face=3D"mo=
nospace" size=3D"4"><br></font></div><div><font face=3D"monospace" size=3D"=
4">CODE</font></div><div><font face=3D"monospace" size=3D"4">=C2=A0 =C2=A0 =
n =3D strlen(w_str);</font></div><div><font face=3D"monospace" size=3D"4">E=
NDCODE</font></div><div><font face=3D"monospace" size=3D"4">=C2=A0 =C2=A0 D=
ISPLAY &quot;2. w_str=3D&quot;, w_str, &quot;; =3D&gt; n=3D&quot;, n</font>=
</div><div><font face=3D"monospace" size=3D"4"><br></font></div><div><font =
face=3D"monospace" size=3D"4">END MAIN</font></div></div><div><font face=3D=
"monospace" size=3D"4">it returns:</font></div><div><div><font face=3D"mono=
space" size=3D"4">1. w_str=3Dx=C2=A0 ; =3D&gt; n=3D=C2=A0 =C2=A0 =C2=A01</f=
ont></div><div><font face=3D"monospace" size=3D"4">2. w_str=3Dx=C2=A0 ; =3D=
&gt; n=3D=C2=A0 =C2=A0 =C2=A03</font></div></div><div><font face=3D"monospa=
ce" size=3D"4"><br></font></div><div><font face=3D"monospace" size=3D"4">Be=
st=C2=A0regards,</font></div><div><font face=3D"monospace" size=3D"4"><br><=
/font></div><div><font face=3D"monospace" size=3D"4">Iwan</font></div><div>=
<br></div></div></div></div>

--000000000000476ed405f503d6b7--


--===============6663041892781500402==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============6663041892781500402==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Aubit4gl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss

--===============6663041892781500402==--