CSTR$
=====
Fetch a C-type string from memory and return it as a Q-type string
Occasionally one encounters the type of strings as used in C and certain
other programming languages. They differ from Q-type strings (as I call
the way strings are styled unde Qdos/SMSQ) in that they dont have a length
word at the beginning, instead they are null-terminated.
I wont go into the advantages and disadvantages here, suffice it to say
that if you encounter such strings in memory, CSTR$ can deal with them.
Usage
=====
qstr$ = CSTR$(adr [, skip%])
where
qstr$ is the resulting Q-string
adr is the location of start of the c-string in memory. Addresses
can be either odd or even.
On return this contains the address just past the terminating
zero.
Or it may contain the error code err.bffl, ie Buffer Full
(= -5) if the count has passed 32764 bytes without hitting
a zero.
skip% is an optional skip counter: The number of previous stings
to skip to reach the one we want
Example 1
=========
100 REMark Test CSTR$
110 :
120 CLCHP: CLS
130 adr = ALCHP(100)
140 POKE adr, 'this', 0, 'is', 0, 'a test of CSTR$', 0, 0
150 a = adr
160 REPeat loop
170 qstr$ = CSTR$(a)
180 IF a < 0 OR LEN(qstr$) = 0: EXIT loop
190 PRINT LEN(qstr$)! qstr$
200 END REPeat loop
210 RECHP adr
220 REPORT a
Example 2
=========
100 REMark Test CSTR$ skip
110 :
120 CLCHP: CLS
130 adr = ALCHP(100)
140 POKE adr, 'string 1', 0, 'string 2', 0, 'string 3', 0
150 a = adr
160 FOR i = 1 TO 3: PRINT CSTR$(a)
170 PRINT
180 a = adr
190 PRINT CSTR$((a), 2)
200 PRINT CSTR$((a), 1)
210 PRINT CSTR$((a), 0)
220 RECHP adr
Programming notes
=================
This command should work on all systems, including later versions of
Turbo.
See also CSTRCMP% to compare two c-strings in memory, and COMPM% which
compares different specified values in memory including c-strings and
n-strings.
Software status
===============
V0.01, pjw, 2023 Jul 04
V0.02, pjw, 2023 Aug 11, changed buffer for skip
Conditions of use and DISCLAIMER as per Knoware.no
Generated by QuickHTM, 2023 Aug 13