I am trying to find a list of errors that appears as "Macro Expansion Error" codes, but can not find anything. The closest I can find is the help manual mentioning how if you had a space in your macro in the wrong spot it would cause an error.
or more specifically
Now in my case my code is
and the functions are defined as
so I am stuck determining what am I doing wrong? and what does the error code mean?
The help file does point out that a probable cause would be in a UDT which I am using, but if necessary I will post my code in whole (in progress because I am porting USB Complete VB code, and not sure how it works just yet, so it may be TMI, but maybe I have missed relevant code by snippets?)
Anyways, any help finding what the macro expansion error codes are, or correcting my error would be of great help
or more specifically
Macro parameters are substituted directly, so whitespace characters in the passed macro parameters may cause unexpected problems if the expanded code is syntactically incorrect with the additional whitespace. For example, this can be important when specifying UDT variables as macro parameters. Consider the following code:
TYPE MyType
lCount AS LONG
szText AS ASCIIZ * 256
END TYPE
MACRO PresetUDT(u)
u.lCount = 1
u.szText = SPACE$(256)
END MACRO
FUNCTION PBMAIN
DIM x AS MyType
PresetUDT(x)
PresetUDT(x ) ' This line causes an Error 526
END FUNCTION
In the code above, the second macro expansion fails to compile because the trailing space in the passed macro parameter becomes part of the expanded code. In this situation, this additional space character breaks the syntax of the UDT variable reference within the expanded macro, triggering a compile-time Error 526 ("Period not allowed"). If we examine how the two expanded macro statements would appear, the problem becomes immediately obvious:
x .lCount = 1
^
x .szText = SPACE$(256)
^
(Please note that the caret symbols (^) above have been added purely to illustrate the exact position of the problem)
TYPE MyType
lCount AS LONG
szText AS ASCIIZ * 256
END TYPE
MACRO PresetUDT(u)
u.lCount = 1
u.szText = SPACE$(256)
END MACRO
FUNCTION PBMAIN
DIM x AS MyType
PresetUDT(x)
PresetUDT(x ) ' This line causes an Error 526
END FUNCTION
In the code above, the second macro expansion fails to compile because the trailing space in the passed macro parameter becomes part of the expanded code. In this situation, this additional space character breaks the syntax of the UDT variable reference within the expanded macro, triggering a compile-time Error 526 ("Period not allowed"). If we examine how the two expanded macro statements would appear, the problem becomes immediately obvious:
x .lCount = 1
^
x .szText = SPACE$(256)
^
(Please note that the caret symbols (^) above have been added purely to illustrate the exact position of the problem)
Code:
Result = SetupDiGetDeviceInterfaceDetail _ (DeviceInfoSet, _ MyDeviceInterfaceData, _ VARPTR(DetailDataBuffer(0)), _ DetailData, _ Needed, _ BYVAL %NULL)
Code:
MACRO SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, DeviceInterfaceData, DeviceInterfaceDetailData, DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData) = _ SetupDiGetDeviceInterfaceDetailW(DeviceInfoSet, DeviceInterfaceData, DeviceInterfaceDetailData, DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData) DECLARE FUNCTION SetupDiGetDeviceInterfaceDetailA LIB "SETUPAPI.DLL" ALIAS "SetupDiGetDeviceInterfaceDetailA" (BYVAL DeviceInfoSet AS DWORD, _ BYREF DeviceInterfaceData AS SP_DEVICE_INTERFACE_DATA, _ BYREF DeviceInterfaceDetailData AS SP_DEVICE_INTERFACE_DETAIL_DATA_A, _ BYVAL DeviceInterfaceDetailDataSize AS DWORD, _ BYREF RequiredSize AS DWORD, _ BYREF DeviceInfoData AS SP_DEVINFO_DATA) AS LONG MACRO SetupDiGetDeviceInterfaceDetail(DeviceInfoSet, DeviceInterfaceData, DeviceInterfaceDetailData, DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData) = _ SetupDiGetDeviceInterfaceDetailA(DeviceInfoSet, DeviceInterfaceData, DeviceInterfaceDetailData, DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData)
The help file does point out that a probable cause would be in a UDT which I am using, but if necessary I will post my code in whole (in progress because I am porting USB Complete VB code, and not sure how it works just yet, so it may be TMI, but maybe I have missed relevant code by snippets?)
Anyways, any help finding what the macro expansion error codes are, or correcting my error would be of great help
Comment