Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 7th Oct 2003 22:58 Edited at: 7th Oct 2003 22:59
With UDTs, can you make assignments as in the last three lines of code below?

type MyData
x as integer
y as integer
name as string
endtype

a as MyData
b as MyData
c as MyData
dim d(1) as MyData

a.x = 1
a.y = 2
a.name = "bob"

b = a
d(1) = b
c = d(1)

Desktop: AMD900/256MB/Radeon 8500 64MB/Win98SE/DX9.0b/Catalyst 3.7
Laptop: P3-850/384MB/GeForce2 Go 16MB/WinXP Pro/DX9.0b/Detonator 45.23
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Oct 2003 23:05
The answer is yes ... but seeing as you've written the code, why didn't you just try it and see?
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 8th Oct 2003 01:00
Not near a PC at the moment... but brain is still working...

So it will copy the members of the UDT from one variable to another or do they variable end up containing a "reference" to the same single UDT structure in memory?

Desktop: AMD900/256MB/Radeon 8500 64MB/Win98SE/DX9.0b/Catalyst 3.7
Laptop: P3-850/384MB/GeForce2 Go 16MB/WinXP Pro/DX9.0b/Detonator 45.23
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Oct 2003 01:18
They are copied - there are no references or pointers to types within DBPro at the moment ... unless you use my array plugin
DrakeX
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 8th Oct 2003 05:34
"unless you use my array plugin"

which is the shi..t BTW

stop looking at me!
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 8th Oct 2003 08:36 Edited at: 8th Oct 2003 08:37
Excellent... I hadn't realized from looking at the online help that UDTs were this capable. Cool! Now if we could just get them to be return-able from a function... ... and something like this to work:

<same as above but add the following>

p as DWORD
e as MyData

make memblock 1, 100
p = get memblock ptr(1)

*p = c
e = *p

The trick would be to make the compiler assume that a pointer variable automatically is pointing to something that is the UDT on the left-hand side of the equals, instead of complaining that both sides need the same members... Weirdly enough, the compiler seems to accept the "*p = c" line. I wonder if it actually copies c into the memblock or not...? Not a ton of good if you can't get it back into a UDT though...

Desktop: AMD900/256MB/Radeon 8500 64MB/Win98SE/DX9.0b/Catalyst 3.7
Laptop: P3-850/384MB/GeForce2 Go 16MB/WinXP Pro/DX9.0b/Detonator 45.23
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Oct 2003 15:57
The '*p = c' line *almost* works - I think that when I tried it, it only copied the first 4 bytes of the type.

Quote: "which is the shi..t BTW"


Does that mean you like it?
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 8th Oct 2003 20:31
What is this "array plugin" IanM? Sounds scary...

Desktop: AMD900/256MB/Radeon 8500 64MB/Win98SE/DX9.0b/Catalyst 3.7
Laptop: P3-850/384MB/GeForce2 Go 16MB/WinXP Pro/DX9.0b/Detonator 45.23
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Oct 2003 20:41
It allows you to do clever things with arrays

- sorting
- reversing
- clearing
- fast swap items
- get low-level array info
- pass arrays by reference (if you are *very* careful)

All you need to do to get it is to navigate through my atrocious site and find it

Login to post a reply

Server time is: 2026-07-26 05:02:25
Your offset time is: 2026-07-26 05:02:25