Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Frank BrĂ¼bach on December 02, 2024, 07:33:41 PM

Title: Strptr.o2bas
Post by: Frank BrĂ¼bach on December 02, 2024, 07:33:41 PM
Hello ... Found this little Error.. in strptr.o2bas example..

zstring * tz' doesn't Work

Must be zstring tz


' demos/Basics/strptr.o2bas
' correction
'
string  sa="Hello String"
bstring sb="Hello Bstring"
zstring sz[]="Hello Zstring"

'zstring * tz="Hello LpSzString" ' doesnt work
zstring tz="Hello LpSzString"

wstring  wsa="Hello Wide String"
wbstring wsb="Hello Wide Bstring"
wzstring wsz[]="Hello Wide Zstring"

'GET THE POINTERS FOR EACH STRING TYPE
sys psa,psb,psz,psi,psl,wpsa,wpsb,wpsz
psa=strptr sa
psb=strptr sb
psz=strptr sz
psi=strptr tz
psl=strptr "Hello literal String"

wpsa=strptr wsa
wpsb=strptr wsb
wpsz=strptr wsz

string pr,cr

cr=chr(13)+chr(10)

'USE CASTING TO DISPLAY AS ZSTRINGS:

pr=
  cast zstring *psa + cr +
  cast zstring *psb + cr +
  cast zstring *psz + cr +
  cast zstring *psi + cr +
  cast zstring *psl + cr +
  cr +
  cast wzstring *wpsa + cr +
  cast wzstring *wpsb + cr +
  cast wzstring *wpsz + cr +
  cr

print pr

The using of cast zstring * PSA for example does Work only with zstring and wzstring? Here you can use IT Else?
Title: Re: Strptr.o2bas
Post by: Charles Pegge on December 02, 2024, 10:22:00 PM
The string pointers for each initialized string type:

string:  *s
bstring: ?s
zstring: @s
literal strings: ?s
byval] string arguments: ?s

I use strptr() to abstract away these differences and avoid the necessity of low-level coding.