Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About Union and it's uses in FB
#4
all union members have same address in memory, and the entire lenght in bytes of the union is the size of it's biggest field. It helps to save memory. Also modifying one you change the value of all members.

Code:
UNION MyUnion
   i AS UINTEGER
   s AS STRING * 1
   b AS UBYTE
END UNION
DIM u AS MyUnion

PRINT "Lenght of the union in bytes:"; LEN(u)
print "Before u.i=2400:"
print "u.i = "; u.i
print "u.s = "; u.s
print "u.b = "; u.b

u.i=2400

print "After u.i=2400:"
print "u.i = "; u.i
print "u.s = "; u.s
print "u.b = "; u.b

print "Addresses of the union members:"
print "u.i = "; @u.i
print "u.s = "; @u.s
print "u.b = "; @u.b

SLEEP
url]http://fbide.sourceforge.net/[/url]
Reply


Messages In This Thread
About Union and it's uses in FB - by no.d - 03-04-2005, 11:05 AM
About Union and it's uses in FB - by Joakim - 03-04-2005, 03:47 PM
About Union and it's uses in FB - by Aquarius - 03-04-2005, 04:24 PM
About Union and it's uses in FB - by VonGodric - 03-04-2005, 05:09 PM
Thanks guys - by no.d - 03-04-2005, 07:51 PM
About Union and it's uses in FB - by na_th_an - 03-04-2005, 08:12 PM
About Union and it's uses in FB - by no.d - 03-04-2005, 08:28 PM
About Union and it's uses in FB - by Joakim - 03-04-2005, 10:28 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)