Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Zlatko Vid on May 02, 2022, 09:42:57 AM

Title: byte pointers how ?
Post by: Zlatko Vid on May 02, 2022, 09:42:57 AM
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


Title: Re: byte pointers how ?
Post by: Charles Pegge on May 02, 2022, 11:30:14 AM
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
Title: Re: byte pointers how ?
Post by: Zlatko Vid on May 02, 2022, 11:37:32 AM
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
print p


yes i see it now ...ok  :)
Title: Re: byte pointers how ?
Post by: Zlatko Vid on May 02, 2022, 11:45:04 AM
hmm but how print content of that
array of ascii bytes ?
Title: Re: byte pointers how ?
Post by: Charles Pegge on May 02, 2022, 12:44:49 PM
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
strptr(bs)=@b
print bs

Title: Re: byte pointers how ?
Post by: Zlatko Vid on May 02, 2022, 05:47:58 PM
thanks Charles

i see now where is a trick  :)