Code:
'pbread.bas works fine using ASCIIZ in this example 'Note: DO not use LSET with ASCIIZ strings ' 'To work with dynamic string would STRPTR be used? ' DECLARE SUB Rsvb LIB "OTSW32.DLL" ALIAS "s_1raat" (BYVAL func AS LONG, IoArea AS ASCIIZ, IOAreaLen AS DWORD, retcode AS LONG) 'C 'extern _declspec(dllexport) void _stdcall WINAPI s_1raat(unsigned int,LPSTR,LPINT,LPINT) FUNCTION PBMAIN AS LONG DIM func AS DWORD DIM controlstatement AS STRING DIM IoArea AS ASCIIZ * 255 DIM IoAreaLen AS LONG DIM RetCode AS DWORD DIM sValueToSort AS STRING DIM NumberOfStrings AS LONG DIM randomCharacter AS LONG DIM StringLength AS LONG DIM sResults AS STRING func = 1 controlStatement = "S(1,2,C,A)" IoArea = controlStatement IoAreaLen = LEN(controlstatement) CALL RSVB(Func,IOArea,IoAreaLen,RetCode) IF retcode <> 0 THEN ? "Unable to init simple test" GOTO endPgm END IF func = 2 FOR NumberOfStrings = 1 TO 10 sValueToSort = "" 'Create random string FOR StringLength = 1 TO RND(1,10) RandomCharacter = RND(65,90) sValueToSort = sValueToSort + CHR$(RandomCharacter) NEXT IoAreaLen = LEN(sValueToSort) Ioarea = sValueToSort CALL RSVB(Func,IOArea,IoAreaLen,RetCode) IF retcode <> 0 THEN ? "Retcode giving first record" + STR$(Retcode) GOTO EndPgm END IF NEXT DO func = 3 CALL RSVB(Func,IOArea,IoAreaLen,RetCode) IF retcode >0 THEN EXIT DO #IF %DEF(%PB_CC32) ? MID$(IoArea,1,IoAreaLen) 'just print using PBCC #ELSE sResults = sResults + MID$(IoArea,1,IoAreaLen) + $CRLF 'create a string so only 1 MSGBOX with PBWin #ENDIF LOOP ? sResults EndPgm: #IF %DEF(%PB_CC32) ? "Press any key to end" WAITKEY$ #ENDIF END FUNCTION
Leave a comment: