this is a continuation of thread: http://www.powerbasic.com/support/pb...ead.php?t=4084
------------------
[email protected]
------------------
[email protected]
FUNCTION TextParser(hdPtr AS LONG, hdEnd AS LONG) AS LONG LOCAL i AS LONG 'other locals STATIC chPointersDone AS LONG STATIC chDispatch() AS DWORD STATIC chDispatcher AS DWORD IF ISFALSE(chPointersDone) THEN ' DIM chDispatch(256) AS DWORD 'Default responses: FOR i = 0 TO 255 chDispatch(i) = CODEPTR(char_Default) NEXT i chDispatch(9 ) = CODEPTR(ch_Tab ) chDispatch(10 ) = CODEPTR(ch_Linefeed ) chDispatch(13 ) = CODEPTR(ch_Return ) chDispatch(32 ) = CODEPTR(ch_Space ) chDispatch(34 ) = CODEPTR(ch_Quote ) chDispatch(61 ) = CODEPTR(ch_Equal ) ' FOR i = 48 TO 57 chDispatch(i) = CODEPTR(ch_Digit) NEXT i FOR i = 65 TO 90 chDispatch(i) = CODEPTR(ch_Letter) NEXT i 'etc etc. chDispatcher = VARPTR(chDispatch(0)) chPointersDone = %TRUE END IF 'init all flags and variables here: QuoteMode = %FALSE ! mov eax, 0 ch_StartLoop: 'eax is already cleared. ! mov ebx, hdPtr ! mov al, BYTE PTR [ebx] ! inc ebx ! mov hdPtr, ebx ! mov i, eax ! shl eax, 2 ! mov ebx, chDispatcher ! add ebx, eax ! mov ebx, DWORD PTR [ebx] ! CALL ebx ! OR eax, eax ! jnz ch_ExitLoop ! mov ebx, hdPtr ! cmp ebx, hdEnd ! jb ch_StartLoop ch_ExitLoop: ! cmp eax, %chFinished ! jne ch_Finish ! mov eax, 0 ch_Finish: ! mov i, eax FUNCTION = i EXIT FUNCTION '------------------------------------------------------------------------------ ch_Default: IF QuoteMode THEN ! mov eax, 0 ! ret ELSE ! mov eax, %chBadData ! ret END IF '------------------------------------------------------------------------------ ch_Return: 'reset line flags (this is just an example [img]http://www.powerbasic.com/support/forums/smile.gif[/img] QuoteMode = %FALSE ! mov eax, 0 ! ret '------------------------------------------------------------------------------ ch_Space: ch_Tab: IF QuoteMode = %FALSE THEN 'last word was completed, process word, reset word flags ' ' END IF ! mov eax, 0 ! ret '------------------------------------------------------------------------------ ch_Quote: QuoteMode = 1 - QuoteMode ! mov eax, 0 ! ret '------------------------------------------------------------------------------ 'all other character processing goes here. END FUNCTION
CASE %WM_DESTROY CALL DragAcceptFiles(CBHNDL, 0)
CALL DragFinish(hDrop)
'************************************************************************ ' GetCommandFiles - Function Loads File/Folder names into the global arrays '************************************************************************ FUNCTION GetCommandFiles( BYVAL CmdStr AS STRING, Fi() AS STRING, Fo() AS STRING ) AS LONG 'Returns the number of files in the string LOCAL TempStr AS STRING, i AS LONG, j AS LONG, k AS LONG, Count AS LONG, pStr AS STRING IF INSTR(CmdStr, $DQ) THEN pStr = $DQ ELSE pStr = " " END IF Count = PARSECOUNT(CmdStr, pStr) REDIM Fi(Count) ' Make room in the global array REDIM Fo(Count) ' Make room in the global array DO INCR k TempStr = TRIM$(PARSE$(CmdStr, pStr, k)) IF LEN(TempStr) = 0 THEN EXIT DO IF (GETATTR(TempStr) AND 16) THEN ' check if it's a dir INCR i Fo(i) = TempStr ' directorys ELSE INCR j Fi(j) = TempStr ' Files END IF LOOP REDIM PRESERVE Fi(j) ' Make array the correct size REDIM PRESERVE Fo(i) ' Make array the correct size FUNCTION = Count END FUNCTION
******************************************************************************** --- TOTAL REFERENCE COUNTS --- (format is: Reference count, Name) INCLUDES: D:\PBDLL\WINAPI\WIN32API.INC D:\PBDLL\WINAPI\COMDLG32.INC
Dim RealFunction 'Dim CommentedFunction MyStr$ = "Dim StringFunction"
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.
Comment