Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hello , memset not funktion.
#1
hello, good day.

I can't get this memset demo to work.

thanks. regards

Code: (Select All)
DECLARE LIBRARY
FUNCTION memsetB& ALIAS memset (p AS _BYTE, BYVAL c AS _UNSIGNED LONG, BYVAL n AS _UNSIGNED LONG)
FUNCTION memsetI& ALIAS memset (p AS INTEGER, BYVAL c AS _UNSIGNED LONG, BYVAL n AS _UNSIGNED LONG)
FUNCTION memsetL& ALIAS memset (p AS LONG, BYVAL c AS _UNSIGNED LONG, BYVAL n AS _UNSIGNED LONG)
END DECLARE

DIM Barray(1 TO 10) AS _BYTE
res& = memsetB(Barray(1), 65, 5)

FOR i = 1 TO 10
  PRINT Barray(i);                      'display BYTE array decimal values
NEXT
PRINT: PRINT

DIM Larray(1 TO 10) AS LONG
res& = memsetL(Larray(1), 65, 5)

FOR i = 1 TO 10
  PRINT Larray(i);                      'displays LONG array decimal values
NEXT i
PRINT
FOR i = 1 TO 10
  PRINT " " + HEX$(Larray(i));          'displays each byte value &H41 = 65
NEXT i
[Image: memset.jpg]
Reply
#2
Use CUSTOMTYPE to avoid the C++ error.

Code: (Select All)
DECLARE CUSTOMTYPE LIBRARY
    FUNCTION memsetB& ALIAS memset (p AS _BYTE, BYVAL c AS LONG, BYVAL n AS _UNSIGNED _OFFSET)
    FUNCTION memsetI& ALIAS memset (p AS INTEGER, BYVAL c AS LONG, BYVAL n AS _UNSIGNED _OFFSET)
    FUNCTION memsetL& ALIAS memset (p AS LONG, BYVAL c AS LONG, BYVAL n AS _UNSIGNED _OFFSET)
END DECLARE

DIM Barray(1 TO 10) AS _BYTE
res& = memsetB(Barray(1), 65, 5)

FOR i = 1 TO 10
    PRINT Barray(i); 'display BYTE array decimal values
NEXT
PRINT: PRINT

DIM Larray(1 TO 10) AS LONG
res& = memsetL(Larray(1), 65, 5)

FOR i = 1 TO 10
    PRINT Larray(i); 'displays LONG array decimal values
NEXT i
PRINT
FOR i = 1 TO 10
    PRINT " " + HEX$(Larray(i)); 'displays each byte value &H41 = 65
NEXT i

Also, memset will not work the way you are probably expecting for anything other than _BYTE arrays.
Reply




Users browsing this thread: 2 Guest(s)