You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
' MessageBox app
#INCLUDE "WIN32API.INC" 'include Windows API calls
FUNCTION PBMAIN
DIM retval AS LONG, hWnd AS LONG
hWnd = GetDesktopWindow()
retval = MessageBox hWnd, "Sprinkles on that?", _
"The Sundae Shoppe", %MB_YESNOCANCEL+%MB_ICONQUESTION
PRINT retval
WAITKEY$
END FUNCTION
As is, this gives me a 480 error "parameter mismatches definition." If I remove the retval = part, it works fine, but I don't get the return value.
I'm sure it's something simple, but I'm new to Windows programming.
>retval = MessageBox hWnd, "Sprinkles on that?", _
> "The Sundae Shoppe", %MB_YESNOCANCEL+%MB_ICONQUESTION
That's a syntax error. When using a procedure as a function (returning a value), any procedure parameters must be enclosed by parentheses. (In 6x and 8x. In 7x there was a bug in the compiler which allowed you to get away with no parens).
Crap error message, but that IS your problem (assuming you are using 6x or 8x, version not shown).
BTW you should combine styles with the OR operator, not the '+' (addition) operator. You will 'get away with this' some of the time, but that will be plain old dumb luck.
I fool so feelish... When I teach Java at work, I always point out "somename(" tells you right away it's a function/method. Now I just need to remember that for PB too. (Using PBCC 4.04)
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment