From 079764b8f04f4ae69a3a014224a45a04a157edad Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 20 Oct 2026 11:03:17 +0000 Subject: feat(library): add experimental string ASC overloads Co-Authored-By: Claude Opus 5.5 --- tests/library/exp-string/expected.txt | 3 +++ tests/library/exp-string/notes.md | 2 ++ tests/library/exp-string/program.cps | 11 +++++++++++ 3 files changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/library/exp-string/expected.txt b/tests/library/exp-string/expected.txt index b7e35f6..88c9a2f 100644 --- a/tests/library/exp-string/expected.txt +++ b/tests/library/exp-string/expected.txt @@ -32,3 +32,6 @@ AbC@19 H:H:@ 0:8 ABC +65:65 +0:0:0 +255 diff --git a/tests/library/exp-string/notes.md b/tests/library/exp-string/notes.md index d365dfc..f360410 100644 --- a/tests/library/exp-string/notes.md +++ b/tests/library/exp-string/notes.md @@ -15,3 +15,5 @@ MID positions 2..4 give BCD. The minimum INTEGER start clamps to 1 and gives AB; LCASE converts AbC@19 to abc@19 without modifying the source. Its CHAR overload returns CHAR w for W or w and preserves @, as in guide section 5.5. Empty length stays zero; two leading NULs survive conversion and letters after them still become abc. UCASE converts AbC@19 to ABC@19 without modifying the source. Its CHAR overload returns CHAR H for h or H and preserves @, as in guide section 5.5. Empty length stays zero; two leading NULs survive conversion and letters after them still become ABC. + +ASC returns 65 for CHAR A and the first byte of ABCDEFGH, zero for empty strings or NUL, and 255 for a byte with all eight bits set. These byte-code functions are compiler/library extensions. diff --git a/tests/library/exp-string/program.cps b/tests/library/exp-string/program.cps index 61a915c..dfa5b47 100644 --- a/tests/library/exp-string/program.cps +++ b/tests/library/exp-string/program.cps @@ -44,6 +44,7 @@ CALL CheckRight() CALL CheckMid() CALL CheckLCase() CALL CheckUCase() +CALL CheckAsc() PROCEDURE CheckLeft() DECLARE Letters : _EXP_STRING((C_STRING)"ABCDEFGH") @@ -104,3 +105,13 @@ PROCEDURE CheckUCase() OUTPUT _EXP_STRING_LENGTH(_EXP_STRING_UCASE(Empty)), ":", _EXP_STRING_LENGTH(_EXP_STRING_UCASE(Nuls & Mixed)) CALL _EXP_STRING_OUTPUT(_EXP_STRING_MID(_EXP_STRING_UCASE(Nuls & Mixed), 3, 3)) ENDPROCEDURE + +PROCEDURE CheckAsc() + DECLARE Letters : _EXP_STRING((C_STRING)"ABCDEFGH") + DECLARE Empty : _EXP_STRING + DECLARE Nuls : _EXP_STRING(2, (C_CHAR)'\0') + DECLARE High : _EXP_STRING(1, (C_CHAR)255) + OUTPUT _EXP_STRING_ASC('A'), ":", _EXP_STRING_ASC(Letters) + OUTPUT _EXP_STRING_ASC(Empty), ":", _EXP_STRING_ASC(Nuls), ":", _EXP_STRING_ASC('\0') + OUTPUT _EXP_STRING_ASC(High) +ENDPROCEDURE -- cgit v1.3.1-4-g156e