I'm trying to set up an array to point to a structure. I want each element of the array to point to differently filled structs. Hey it's almost 10:15 on a Saturday night :grin: . Below I will paste some code for your viewing pleasure.

assume edx: ptr CLIPFORMATSTRUCT
mov .format, CF_TEXT
mov .fName, offset tmpfname
mov .fSize, offset bReadWrite
mov ptrtemphWnd, ; ERR LINE
assume edx:nothing

Everything else works like a charm wrapped around a piece of fried chicken in a bowl of happy soup. I was taught on how to use the STRUCTs a while ago, now I need to learn how to move 'em.

Thanks to all (even if you're just looking).
Posted on 2001-10-20 21:11:55 by lackluster
Hi lackluster

To copy a struct is just like copying a string.

.data

MyStruct CLIPFORMATSTRUCT <>
MyCopy CLIPFORMATSTRUCT <>

.code

lea esi,MyStruct
lea edi,MyCopy
mov ecx,sizeof CLIPFORMATSTRUCT
rep movsb

KetilO
Posted on 2001-10-20 21:21:46 by KetilO
Thanks, KetilO. I believe it is correct, but I have other errors in that segment I posted. I thought you might like to know I am using your RadASM Editior which is GREAT! The only problem I'm having with it is the output window comes up sometimes spuraticaly. Small price to pay for such a cool editor. Many thanks to your time, effort and knowledge on that. Zepplin Rules.
Posted on 2001-10-20 21:30:37 by lackluster
Ah, the output window comes up when I'm over the statusbar. I get it now :cool: . As an extension of my orginal post, does anyone know why when I run certain code it breaks down giving me a message about my prog generating errors and being shutdown? It seems really odd things trigger it. For example:

mov ebx, tmppos

does it,

mov .format, 1
mov .fName, offset tmpfname
mov .fSize, offset bReadWrites

these lines do it,

rep movsb

and this!

Any help is as always wonderful and appreciated. THANKS@! :stupid:
Posted on 2001-10-21 00:35:26 by lackluster

Ah, the output window comes up when I'm over the statusbar. I get it now :cool: . As an extension of my orginal post, does anyone know why when I run certain code it breaks down giving me a message about my prog generating errors and being shutdown? It seems really odd things trigger it. For example:


mov ebx, tmppos


This line should not crash but it IS wrong, you probably should use "mov ebx, offset tmppos", or "lea ebx, tmppos". This loads the address of the structure instead of the first dword at that address.



mov [edx].format, 1
mov [edx].fName, offset tmpfname
mov [edx].fSize, offset bReadWrites


these lines do it


This problem is solved by making the above modification.




rep movsb

and this!

Here you probably forgot to initialize esi (source pointer), edi (destination pointer) or ecx (byte count to copy).


Any help is as always wonderful and appreciated. THANKS@! :stupid:
Posted on 2001-10-21 04:10:49 by Thomas
I'm sorry. I probably should have made the statement more clear. The var tmppos is basically an array pointer, not the structure. In fact it's the same code as in the first post except now with KetilO's advice in it.

	

mov ebx, tmppos [B] ; I just want to load ebx with the array pointer so I can put the struct in the array[/B]
assume edx: ptr CLIPFORMATSTRUCT
mov [edx].format, 1 [B] ; Crash line[/B]
mov [edx].fName, offset tmpfname [B] ; Crash line[/B]
mov [edx].fSize, offset bReadWrite [B] ; Crash line[/B]
lea esi, [edx]
lea edi, ptrtemphWnd[ebx]
mov ecx, SIZEOF CLIPFORMATSTRUCT
mov eax, ecx
debuglast [B]; just used to print out the val of eax[/B]
rep movsb [B]; This line crashes[/B]
assume edx:nothing


Thanks for your time.
Posted on 2001-10-21 11:14:44 by lackluster
It may have to do with the fact that it's 00:11 here :) but I'm still not sure I get what you want exactly: do you want an array of pointers (to structures) or an array of structures?? In your first post you said you wanted an array of pointers but now it seems to me that you want an array of structures..
Then another question: what's ptrtemphWnd? Is it an array? Is it differrent from tmppos?
If you let me know these things I can help you further.

Thomas
Posted on 2001-10-21 17:15:31 by Thomas
Orginally my idea was to have an array filled with pointers to differntly filled structures. After much frustration though, I gave up on this idea and decided to go with ini files in seperate sections instead. I'm writing my first full-fleged application in asm and am running into some difficulty :]. Anyways, the way I'm doing it with the ini file seems to be working out okay. THanks, KetilO & Thomas.
Posted on 2001-10-21 17:46:14 by lackluster