Guidance
指路人
g.yi.org
software / rapidq / Examples / ASM / CheckString / CheckString.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'From:  Jacques Philippe <jphilip@t...> Wed Nov 6, 2002  10:00 pm

' ------- RQ code cut Start -------
' This Assembler Function suppresses characters < 33 and > 127 from a string
' and it put the rest in Uppercase
'
' Use : result$ = CheckString (ptrToInputString as Long, lenghtOfInputString As Long)
'
' ptrToInputString = VarPtr(inputString) ' Will bug without that
'
'
' THIS IS ASSEMBLER, USE AT YOUR OWN RISK
' THIS IS ASSEMBLER, USE AT YOUR OWN RISK
' THIS IS ASSEMBLER, USE AT YOUR OWN RISK
' THIS IS ASSEMBLER, USE AT YOUR OWN RISK
'
     $ESCAPECHARS ON
     $TYPECHECK ON
     $INCLUDE "RAPIDQ.INC"
'
' ==== Start Include ==========================================
     DECLARE FUNCTION CallAsmProc LIB "user32" ALIAS "CallWindowProcA" _
      (Proc AS LONG, A1 AS LONG, A2 AS LONG, A3 AS LONG, _
      A4 AS LONG) AS LONG
' ----- START ASM CheckString -----
     DEFBYTE CheckStringArray (0 TO 75) = _
      { _
      &HC8, &H00, &H00, &H00, &H56, &H57, &H51, &H52, &H8B, &H75, _
      &H08, &H8B, &H7D, &H10, &H8B, &H4D, &H0C, &HBA, &H00, &H00, _
      &H00, &H00, &H4E, &H41, &H46, &H49, &H0F, &H84, &H22, &H00, _
      &H00, &H00, &H8A, &H06, &H3C, &H21, &H72, &HF2, &H3C, &H80, _
      &H73, &HEE, &H3C, &H61, &H0F, &H82, &H0A, &H00, &H00, &H00, _
      &H3C, &H7B, &H0F, &H83, &H02, &H00, &H00, &H00, &H2C, &H20, _
      &H88, &H07, &H42, &H47, &HEB, &HD6, &H89, &HD0, &H5A, &H59, _
      &H5F, &H5E, &HC9, &HC2, &H10, &H00 _
      }
' ----- END ASM CheckString -----
'
' ----- POINTER to use In CallAsmProc -----
' A Bit Faster than Calling CheckString
     DEFINT ptrCheckString
     ptrCheckString = VARPTR (CheckStringArray(0))
'
' ----- RQ CALL CheckString -----
     FUNCTION CheckString (ptrBinString AS LONG, lenBinString AS LONG) AS STRING
      DEFSTR returnedString
      DEFINT lenReturnedString, ptrReturnedString
      returnedString = SPACE$(lenBinString)
      ptrReturnedString = VARPTR(returnedString)
      lenReturnedString = CallAsmProc (ptrCheckString, ptrBinString,lenBinString, ptrReturnedString, 0)
      CheckString = LEFT$(returnedString, lenReturnedString)
     END FUNCTION
' ----- END ASM CheckString -----
' ==== End Include =============================================
'
'
'
' DEMO
' ----
     DEFSTR testStr
     testStr = SPACE$(256) ' all characters
     DEFINT N
' Create a binary string made of all different chars
     FOR N = 0 TO 255
      testStr = REPLACE$(testStr, CHR$(N), N + 1)
     NEXT N
'
     PRINT ("Original string : \n" & testStr & "\n\n\n\n")
     PRINT ("Modified String : \n" & CheckString(VARPTR(testStr), LEN(testStr)))
'
' -------------------------------------------------------------
' EXIT CONSOLE
' ------------
     DEFSTR sExit
     INPUT "\n\n CR to QUIT \n\n", sExit
     Application.Terminate
     END
' ------- RQ code cut End -------

'RqAsm is not necessarly faster, RQ spend a lot lot lot time calling API's, and
'thus CallAsmProc = CallWindowsProcA ! (400.000 machine cycles, IIRC).
掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-11-06 23:20:16