Page 1 of 1

Posted: Tue Sep 17, 2002 4:01 pm
by BackupUser
Restored from previous forum. Originally posted by fweil.

Hi,

I am having a guess about the best way to make two variables, even of different types, having the same start address.

Some years ago I was designing Fortan apps using Equivalence keyword which allow to make ie the following :

Dim text[1000] as string * 1 (means a 1000 single characters text array)
Dim array[1000] as byte (means a 1000 single bytes array)
Equivalence text, array

From there you can either look at text or array at the same address.

How would one here do the same to make a fixed start address for both variables in good regular PureBasic coding ?

KRgds

Francois Weil
14, rue Douer
F64100 Bayonne

Posted: Tue Sep 17, 2002 5:06 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Pointers are here for that :)

For example:

Code: Select all

Structure Byte
  b.b
EndStructure

Text$ = "HELLO"

*Cursor1.Byte = @Text$
*Cursor2.Byte = @Text$

Repeat
  Debug Chr(*Cursor1\b) : *Cursor1+1
  Debug Chr(*Cursor2\b) : *Cursor2+1
Until *Cursor1\b = 0


Fred - AlphaSND

Posted: Tue Sep 17, 2002 5:35 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.

You could also create a union for a more general case of variables occupying the same memory locations.

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)

Posted: Wed Sep 18, 2002 5:37 am
by BackupUser
Restored from previous forum. Originally posted by fweil.

Thanks a lot for this. I will make tests and take profit of it.

KRgrds

Francois Weil
14, rue Douer
F64100 Bayonne