The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: AndyR on March 26, 2005, 03:13:18 PM

Title: Scope of variables
Post by: AndyR on March 26, 2005, 03:13:18 PM
Hi all,

I've got a problem with structures in winmm API(or any windows API). I writing a prog to recieve MIDI in sysex messages in which I use a callback routine.
In WndProc, if I declare an instance of the MIDIHDR structure as LOCAL, I can't refer to it in the callback routine. How do I do I get at it in both procs? I realise there's probably a simple answer but I just can't find a way of doing it. I've read the docs and been through loads of tutorials, but haven't found anything yet.

For instance:

a_proc proc

LOCAL midiHdr:MIDIHDR

mov eax,offset sysbuf
mov  midiHdr.lpData,eax

a_proc endp


b_proc proc

mov  eax,midiHdr.lpData   ;Never heard of it!!

b_proc endp

How do I give midiHdr global scope? :red

Thanks,


Andy





Title: Re: Scope of variables
Post by: mnemonic on March 26, 2005, 03:18:01 PM
Hi Andy,

try putting it in the .data or .data? section and it will be available from anywhere.

Regards
Title: Re: Scope of variables
Post by: AndyR on March 26, 2005, 03:59:56 PM
Hi all,

Thanks mnemonic, I did try that but it threw errors. What format should I use?

Andy
Title: Re: Scope of variables
Post by: MichaelW on March 26, 2005, 05:37:12 PM
To use the default initializers:

midiHdr MIDIHDR <>

Or to initialize dwBufferiLength to 100:

midiHdr MIDIHDR <,100>

etc

Title: Re: Scope of variables
Post by: AndyR on March 27, 2005, 05:06:18 PM
Hi all,

That did the job! Thanks  :U

Andy.