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.

DarkBASIC Professional Discussion / Passing Results to Parameters of Function Issues

Author
Message
Darian Glinski
17
Years of Service
User Offline
Joined: 2nd Jun 2009
Location:
Posted: 22nd Sep 2010 17:56
I can not seem to pass the results of my queries into the parameters of my functions. Please look at the rOut parameter of the PeekMessage function and GetMessage function. As you can see I have even used a pointer to try the pass but Dark Basic refuses to pass information to the parameter of a function for me. Is this a technical issue or limitation?

REMSTART
**Author: Darian A. Glinski
**Company: Digital Reality
**Copyright: June 2010, All rights Reserved
**Description: Digital Reality Messaging
REMEND

#CONSTANT NULL 0
#CONSTANT FAIL -1
#CONSTANT FALSE 0
#CONSTANT TRUE 1

REMSTART
**Post Message Constants**
REMEND
#CONSTANT PM_NOREMOVE 100
#CONSTANT PM_REMOVE 105

REMSTART
**System Messages**
REMEND
#CONSTANT DRM_INITIALIZE_SYSTEM 1000
#CONSTANT DRM_TERMINATE_SYSTEM 1005
#CONSTANT DRM_INITIALIZE_DISPLAY 1010
#CONSTANT DRM_INITIALIZE_MEDIA 1015

TYPE MESSAGE
UMsg AS INTEGER
X AS FLOAT
Y AS FLOAT
Z AS FLOAT
LParam AS INTEGER
WParam AS INTEGER
Remove AS INTEGER
ENDTYPE

FUNCTION Initialize()

DISABLE SYSTEMKEYS: DISABLE ESCAPEKEY

GLOBAL DIM g_bKernel(0) AS MESSAGE

PostMessage(DRM_INITIALIZE_SYSTEM, 0, 0, 0, 0, 0)

PostMessage(DRM_INITIALIZE_DISPLAY, 0, 0, 0, 0, 0)

PostMessage(DRM_INITIALIZE_MEDIA, 0, 0, 0, 0, 0)

ENDFUNCTION

FUNCTION Terminate()

UNDIM g_bKernel(0)

ENABLE ESCAPEKEY: ENABLE SYSTEMKEYS
ENDFUNCTION

REMSTART
**Returns Number of Messages In Queue**
REMEND
FUNCTION GetMessageCount()
nResult = ARRAY COUNT(g_bKernel(0))
ENDFUNCTION nResult

REMSTART
**Posts A Message**
REMEND
FUNCTION PostMessage(uMsg AS DWORD, nX AS FLOAT, nY AS FLOAT, nZ AS FLOAT, lParam AS DWORD, wParam AS DWORD)
nResult AS INTEGER
IF uMsg <> 0
ADD TO QUEUE g_bKernel(0)
g_bKernel().UMsg = uMsg
g_bKernel().X = nX
g_bKernel().Y = nY
g_bKernel().Z = nZ
g_bKernel().LParam = lParam
g_bKernel().WParam = wParam
g_bKernel().Remove = PM_NOREMOVE
nResult = GetMessageCount()
ELSE
nResult = FAIL
ENDIF
ENDFUNCTION nResult

REMSTART
**Get Next Message**
REMEND
FUNCTION GetMessage(rOut AS MESSAGE)
ARRAY INDEX TO QUEUE g_bKernel(0)
WHILE ARRAY INDEX VALID(g_bKernel()) = TRUE
IF g_bKernel().Remove = PM_NOREMOVE
g_bKernel().Remove = PM_REMOVE
*rOut = g_bKernel()
EXIT
ENDIF
NEXT ARRAY INDEX g_bKernel(0)
ENDWHILE
ENDFUNCTION 0

REMSTART
**Finds A Specific Message**
REMEND
FUNCTION PeekMessage(rOut AS MESSAGE, uMsg AS DWORD, pmRemove AS DWORD)
nResult AS INTEGER
ARRAY INDEX TO QUEUE g_bKernel(0)
WHILE ARRAY INDEX VALID(g_bKernel()) = TRUE
IF g_bKernel().UMsg = uMsg AND g_bKernel().Remove = PM_NOREMOVE
g_bKernel().Remove = pmRemove
*rOut = g_bKernel()
nResult = TRUE
EXIT
ELSE
nResult = FAIL
ENDIF
NEXT ARRAY INDEX g_bKernel(0)
ENDWHILE
ENDFUNCTION nResult

REMSTART
**Clears Handled Messages**
REMEND
FUNCTION DispatchMessages()
ARRAY INDEX TO QUEUE g_bKernel(0)
WHILE ARRAY INDEX VALID(g_bKernel()) = TRUE
IF g_bKernel().Remove = PM_REMOVE
REMOVE FROM QUEUE g_bKernel()
ENDIF
NEXT ARRAY INDEX g_bKernel(0)
ENDWHILE
ENDFUNCTION

Strategic Simulations
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Sep 2010 20:39
In DBPro you can do this:



but you can't do this and expect to see the change to rOut:



The only results returned by functions are the argument of endfunction or changes to various global variables and entities inside the function.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 24th Sep 2010 00:17
Also, you can use ` or rem to make a comment.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 24th Sep 2010 02:24
or the [code ][/code ] tags in the forum posts to do


Login to post a reply

Server time is: 2026-07-24 23:12:43
Your offset time is: 2026-07-24 23:12:43