----- Original Message ----- From: "Leopold Toetsch" <[EMAIL PROTECTED]> To: "Jonathan Worthington" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, January 13, 2004 9:13 AM Subject: Re: find_global failing
> Jonathan Worthington <[EMAIL PROTECTED]> wrote: > > Hi, > > > I currently have a file named win32.pasm containing the following:- > > > saveall > > loadlib P1, 'user32' > > dlfunc P2, P1, 'MessageBoxA', 'llttl' > > store_global 'MessageBox', P2 > > # MANY MORE LINES LIKE THIS > > restoreall > > > I compile that file to a .pbc file, which works out OK. In then have an imc > > file that starts like this:- > > > .sub _MAIN > > # Load Win32 library. > > load_bytecode "win32.pbc" > > > # Look up MessageBox function. > > find_global $P1, "MessageBox" > > > Executing that results in the following error:- > > > Global 'MessageBox' not found > > in file '(unknown file)' near line -1 > > The loaded byte code isn't executed. Its not like .include "win32.pasm". > > We don't have automagic _init or _load functions yet, but finally it > could be: > > .pcc_sub _init: > loadlib P16, 'user32' > dlfunc P17, P16, ... > store_global ... P17 > ... > invoke P1 > > That is after load_bytecode C<_init> is invoked, if its present in the > loaded file. > > For now, you have to call such initialisation manually. That is above > init code and: > > load_bytecode ... > find_global P0, "_init" > pushtopp > invokecc > poptopp > Thanks, that works great. I now have a .pbc with loadlibs and dlfuncs for pretty much the entire Win32 API. The next thing I want to look at is constants. At first I thought I could do something like:- .constant MB_YESNOCANCEL 3 But when I compile the pasm file containing that to a .pbc to use with load_bytecode, these constants appear to just get dropped. I've determined this through grepping the .pbc for the identifier associated with the constant (nothing found), and also by observing that no matter how many .constant lines I have in the source .pasm file, the size of the resultant .pbc is the same. So, is .constant not working correctly, or (more likely) not the Right Thing to use in this situation? How should I go about storing the constants for use with the APIs? Thank you, Jonathan