• Welcome to Jose's Read Only Forum 2023.

byte pointers how ?

Started by Zlatko Vid, May 02, 2022, 09:42:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zlatko Vid

Hello Charles

i know that you show me once something similar
but i simply forget how...

my question is how to use

]byte b as strptr(s)
byte b1 as strptr(s1)

and how connect this two strings into one ?

here is my try :
'pointer with byte type ...
string s1="Aurel", s3= "_microA"

byte b At strptr s1
byte b1 At strptr s3

bp = b+b1

ps = @bp

'p = @ps

print ps

Charles Pegge

Hi Aurel,

You will need to add your strings first. Then you have byte access to the whole string.

'pointer with byte type ...
string s1="Aurel", s2= "_microA"
string s3=s1+s2

byte b[] at strptr s3 'array of ascii bytes

Zlatko Vid

ahh  i see array of ascii bytes.... i get it
thanks Charles

in this case  is also same :

'string pointer
string s = "viva" ,s2 = " LasVegas",ps
'concat two strings
ps = s+s2
int p As string ptr
' p hold addres of ps
p = @ps

print p

yes i see it now ...ok  :)

Zlatko Vid

hmm but how print content of that
array of ascii bytes ?

Charles Pegge

If you don't want to refer to the original string, it is possible to turn the array of bytes back into a string for printing etc.
But both the byte array and the new string are directly coupled to the original string.

byte b[] at strptr s3 'array of ascii bytes
print b[3]
'now reference b as a string again
bstring bs
print bs

Zlatko Vid

thanks Charles

i see now where is a trick  :)