.Character .Ascii structures etc

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

.Character .Ascii structures etc

Post by Rinzwind »

Any reason why these are NOT declared as:

Code: Select all

EnableExplicit

Structure pcharacter
  c.c[0]  
EndStructure

Define s.s = "Test"

Define *pb.pcharacter
*pb = @s
Debug Chr(*pb\c)
Debug Chr(*pb\c[3])
So we can index into the structure?

Please change; it seems to be backwards compatible, right?
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: .Character .Ascii structures etc

Post by STARGÅTE »

Rinzwind wrote: Fri Nov 12, 2021 9:29 am Please change; it seems to be backwards compatible, right?
No, because SizeOf(pcharacter) would then give always 0.
SizeOf(Character) is 1 or 2.

I have defined a general structure like:

Code: Select all

Structure GeneralArray
	StructureUnion
		a.a[0]  
		b.b[0]  
		c.c[0]  
		d.d[0]  
		f.f[0]  
		i.i[0]  
		l.l[0]  
		q.q[0]  
		u.u[0]  
		w.w[0]  
	EndStructureUnion
EndStructure
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply