Code:
MACRO RealByRef(anything) = BYVAL VARPTR (anything) ... CALL foo ( realbyref (x).....
Code:
MACRO bva(anything) = BYVAL VARPTR(anything) MACRO bvaz(asciizString) = BYVAL IIF(lstrlen(asciizString), VARPTR(AsCIIZString), %NULL)
MACRO RealByRef(anything) = BYVAL VARPTR (anything) ... CALL foo ( realbyref (x).....
MACRO bva(anything) = BYVAL VARPTR(anything) MACRO bvaz(asciizString) = BYVAL IIF(lstrlen(asciizString), VARPTR(AsCIIZString), %NULL)
' elapsed_time.bas ' BUG: Compiler not accepting BYREF override with parameter mismatch error. It Should; it should not even think about ' a parameter mismatch when point-of-call override (BYREF) is used. Just pass the address of the variable! ' PB.Win 9.0.1 #COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" %ONE_FILETIME_DAY = 600000000 * 60 * 24 %ONE_FT_DAY = 864000000000&& ' 864,000,000,000 %ONE_FILETIME_HOUR = %ONE_FILETIME_DAY \ 24 %ONE_FILeTIME_MINUTE = %ONE_FILETIME_HOUR \ 60 %ONE_FILETIME_SECOND = %ONE_FILETIME_MINUTE \ 60 FUNCTION PBMAIN () AS LONG LOCAL StStart AS SYSTEMTIME, STEnd AS SYSTEMTIME CALL TestVUint64() EXIT FUNCTION STStart.wYear = 2009 StStart.WMonth = 9 StStart.wDay = 29 STStart.wHour = 16 STStart.WMinute = 45 STStart.WSecond = 0 GetLocalTime STEnd MSGBOX "Elapsed=" & ElapsedTimeHHMMSS(StStart, StEnd) END FUNCTION FUNCTION ElapsedTimeHHMMSS (StStart AS SYSTEMTIME,StEnd AS SYSTEMTIME) AS STRING LOCAL QStart AS QUAD, QEnd AS QUAD, QDiff AS QUAD LOCAL lDiff AS LONG LOCAL nHour, NMinute, nSec AS LONG ' COMPILER BUG HERE!!!!!! ' SystemTimeToFileTime StStart, BYREF QStart ' compiler is not accepting these it should! ' SystemTimeToFileTime StEnd, BYREF QEnd SystemTimeToFileTime StStart, BYVAL VARPTR (QStart) ' SystemTimeToFileTime StEnd, BYVAL VARPTR (QEnd) QDiff = QEnd - QStart lDiff = QDiff \ %ONE_FILETIME_SECOND ' difference in seconds, rounded nHour = lDiff \ 3600 lDiff = lDiff MOD 3600 nMinute = lDiff \ 60 lDiff = lDiff MOD 60 nSec = lDiff FUNCTION = FORMAT$(nHour, "00") & ":" & FORMAT$(nMinute, "00") & ":" & FORMAT$(nSec, "00") END FUNCTION FUNCTION TestVUint64() AS LONG LOCAL pV AS VARIANTAPI PTR, v AS VARIANT LOCAL Q AS QUAD, pQ AS QUAD PTR LET V = EMPTY ' intialize PV = VARPTR (V) ' pointer @pV.vt = %VT_UI8 ' unint 74 pQ = VARPTR (@pV.VD) Q = 12345&& @pq = Q ' get variant#() value from intrinsic function Q = VARIANT#(V) MSGBOX FORMAT$(Q),, "With value +12345" ' hmm, try with bit 63 set... LET Q = -12345&& @pq = Q Q = VARIANT#(V) MSGBOX FORMAT$(Q),, "With value -12345" END FUNCTION
#COMPILE EXE #DIM ALL #DEBUG ERROR ON #TOOLS ON #OPTIMIZE SIZE #INCLUDE "Win32Api.inc" FUNCTION PBMAIN () AS LONG LOCAL MyOverRide AS LONG MyOverRide = 12 OverRideMyFunction BYREF MyOverRide 'Pass a reference END FUNCTION FUNCTION OverRideMyFunction(BYVAL X AS LONG) AS LONG 'But I wanted a Value, not a reference MSGBOX STR$(X) FUNCTION = %FALSE 'No Error END FUNCTION
OPTIONAL AxisNumber AS LONG
#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 ParseDeviceCommands "Hello", DeviceCommands(), DeviceParams(), DeviceComments(), DeviceBytes(), ComputerSent, CommandTyped 'Dont pass AxisNumber and you will get a Null Pointer error 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 ISMISSING(AxisNumber) CASE %FALSE 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 CASE <> %FALSE MSGBOX "AxisNumber Missing and I would have raised a Null Pointer error (If #DEBUG ERROR ON)" + $CR + "VarPtr = " + STR$(VARPTR(AxisNumber)) END SELECT FUNCTION = %FALSE 'No Error END FUNCTION
#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
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.
Leave a comment: