I have a problem that I have FINALLY tracked down to being a Null pointer problem. Below is the "Meat and Potatoes" of where the problem is occurring in my real program, but does not occur in the example below.
Now using the same code in my much bigger program I find that "AxisNumber" has a Null Pointer error associated with it. (HUH???
I declared it as long, not a pointer)
To test it, I set a VarPtr(AxisNumber) comes back as 0
So what could I be inadvertently be doing to set a null pointer? Or for that matter how would I PURPOSELY set a Null Pointer????? (No idea why I would, but I could easily do it with a string, but this is a Long)
I am at a loss of ideas of what to check that I could be accidentally be passing a Null pointer?
Code:
#COMPILE EXE #DIM ALL #DEBUG ERROR ON #TOOLS ON #OPTIMIZE SIZE #INCLUDE "Win32Api.inc" FUNCTION PBMAIN () AS LONG LOCAL DeviceCommandsToParse AS STRING DIM DeviceCommands() AS STRING DIM DeviceParams() AS STRING DIM DeviceComments() AS STRING DIM DeviceBytes() AS LONG LOCAL ComputerSent AS LONG LOCAL CommandTyped AS LONG LOCAL AxisNumber AS LONG ' AxisNumber = 0 ParseDeviceCommands "Hello", DeviceCommands(), DeviceParams(), DeviceComments(), DeviceBytes(), ComputerSent, CommandTyped, AxisNumber END FUNCTION FUNCTION ParseDeviceCommands ALIAS "ParseDeviceCommands"(DeviceCommandsToParse AS STRING, DeviceCommands() AS STRING, DeviceParams() AS STRING, DeviceComments() AS STRING, DeviceBytes() AS LONG, _ OPTIONAL ComputerSent AS LONG, OPTIONAL CommandTyped AS LONG, OPTIONAL AxisNumber AS LONG) EXPORT AS LONG SELECT CASE AxisNumber CASE 0 'No Motor Axis slipped in MSGBOX "Device Reply" + $CR + "VarPtr = " + STR$(VARPTR(AxisNumber)) CASE 1 'Slipped in X MSGBOX "Motor 1 Position" + $CR + "VarPtr = " + STR$(VARPTR(AxisNumber)) CASE 2 'Slipped in Y MSGBOX "Motor 2 Position" + $CR + "VarPtr = " + STR$(VARPTR(AxisNumber)) CASE 3 'Slipped in Z MSGBOX "Motor 3 Position" + $CR + "VarPtr = " + STR$(VARPTR(AxisNumber)) CASE 4 'Slipped in T MSGBOX "Motor 4 Position" + $CR + "VarPtr = " + STR$(VARPTR(AxisNumber)) END SELECT FUNCTION = %FALSE 'No Error END FUNCTION

To test it, I set a VarPtr(AxisNumber) comes back as 0
So what could I be inadvertently be doing to set a null pointer? Or for that matter how would I PURPOSELY set a Null Pointer????? (No idea why I would, but I could easily do it with a string, but this is a Long)
I am at a loss of ideas of what to check that I could be accidentally be passing a Null pointer?
Comment