Guidance
指路人
g.yi.org
software / RapidQ / RQ Intro / Subs / functions.bas

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

  
' This is freeware to help Rapid-Q users to enjoy the power of this great
' Basic language, note that use in your own risk.
' Any update of this file please keep full backward compatibility and
' upload to: 
' Thanks!
' Updated by Guidance 2004-04-18
' Created by Guidance _at_ g.yi.org 2002-9-11
'
' string is 1 based
' array is 0 based
' convbase$(String must UCASE$)
' QStringList is 0 based

     $MACRO getbits(w,msb,lsb) ((w SHR lsb) AND NOT((NOT 0???) SHL (msb-lsb+1)))
' Usage:
'   getbits(&HAA55,13,9)  -- get bit13~9 = 10101(bin), note DWord is same with
' Long under windows in RQ, so for negtive value (MSB is 1), this macro may not
' work correctly.
' be sure v is within msb~lsb bits before use macro putbits
     $MACRO setbits(w,msb,lsb,v) ((NOT(NOT((NOT 0???) SHL (msb-lsb+1)) SHL lsb) AND w) OR (v SHL lsb))

     $DEFINE keypressenter 13
     $DEFINE keydownenter 13
     $DEFINE keydownup 38
     $DEFINE keydowndown 40
     $DEFINE keydownpageup 33
     $DEFINE keydownpagedown 34
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     DECLARE FUNCTION str2num(s AS STRING) AS VARIANT
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     FUNCTION str2num(s AS STRING) AS VARIANT ' $.. or ..h or ..H or 0x.. or &H..
      DIM n AS STRING,n2 AS STRING *2
      n=UCASE$(LTRIM$(RTRIM$(s)))
      n2=LEFT$(n,2)
      IF LEFT$(n,1)="$" THEN
       str2num=VAL(CONVBASE$(MID$(n,2),16,10))
      ELSEIF RIGHT$(n,1)="H" THEN
       str2num=VAL(CONVBASE$(LEFT$(n,LEN(n)-1),16,10))
      ELSEIF (n2="0X") OR (n2="&H") THEN
       str2num=VAL(CONVBASE$(MID$(n,3),16,10))
      ELSE
       str2num=VAL(n)
      END IF
     END FUNCTION
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-21 21:13:20