Ignore:
Timestamp:
Feb 25, 2007, 12:56:09 AM (18 years ago)
Author:
イグトランス (egtra)
Message:

#51対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/basic/function.sbp

    r119 r121  
    290290End Function
    291291
    292 Function IsNaN(ByVal x As Double) As BOOL
     292Function IsNaN(ByVal x As Double) As Boolean
    293293    Dim p As *DWord
    294294    p = VarPtr(x) As *DWord
     
    296296    If (p[1] And &H7FF00000) = &H7FF00000 Then
    297297        If (p[0] <> 0) Or ((p[1] And &HFFFFF) <> 0) Then
    298             IsNaN = TRUE
     298            IsNaN = True
    299299        End If
    300300    End If
     
    303303End Function
    304304
    305 Function IsInf(x As Double) As BOOL
     305Function IsInf(x As Double) As Boolean
    306306    Dim p As *DWord, nan As Double
    307307    p = VarPtr(x) As *DWord
     
    311311End Function
    312312
    313 Function IsNaNOrInf(x As Double) As BOOL
     313Function IsNaNOrInf(x As Double) As Boolean
    314314    IsNaNOrInf = IsFinite(x)
    315315End Function
    316316
    317 Function IsFinite(x As Double) As BOOL
     317Function IsFinite(x As Double) As Boolean
    318318    Dim p As *DWord, nan As Double
    319319    p = VarPtr(x) As *DWord
     
    322322    p[0] = 0
    323323    nan = _System_GetInf(/*x,*/ FALSE)
    324     IsNaNOrInf = (memcmp(p As BytePtr, VarPtr(nan), SizeOf (Double)) = 0)
     324    IsFinite = (memcmp(p As BytePtr, VarPtr(nan), SizeOf (Double)) = 0)
    325325End Function
    326326
     
    349349
    350350Function Chr$(code As Char) As String
    351     Chr$=ZeroString(1)
    352     Chr$[0]=code
    353 End Function
     351    Chr$ = ZeroString(1)
     352    Chr$[0] = code
     353End Function
     354
     355#ifdef UNICODE
     356Function AscW(s As String) As UCSCHAR
     357    If s.Length = 0 Then
     358        AscW = 0
     359    Else
     360        If _System_IsSurrogatePair(s[0], s[1]) Then
     361            AscW = ((s[0] And &h3FF) As DWord << 10) Or (s[1] And &h3FF)
     362        Else
     363            AscW = s[0]
     364        End If
     365    End If
     366End Function
     367
     368Function ChrW(c As UCSCHAR) As String
     369    If c <= &hFFFF Then
     370        ChrW.ReSize(1)
     371        ChrW[0] = c As WCHAR
     372    ElseIf c < &h10FFFF Then
     373        ChrW.ReSize(2)
     374        ChrW[0] = &hD800 Or (c >> 10)
     375        ChrW[1] = &hDC00 Or (c And &h3FF)
     376    Else
     377        ' OutOfRangeException
     378    End If
     379End Function
     380#endif
    354381
    355382Function Date$() As String
    356383    Dim st As SYSTEMTIME
    357 
    358384    GetLocalTime(st)
    359385
     
    378404End Function
    379405
    380 Function Hex$(num As DWord) As String
    381     Dim length As Long
    382     Hex$=ZeroString(8)
    383     length=wsprintf(Hex$, "%X", num)
    384     Hex$=Left$(Hex$,length)
    385 End Function
    386 
    387 Function Hex$(num As QWord) As String
    388     Dim length As Long
    389     Hex$=ZeroString(16)
    390     length=wsprintf(Hex$, "%X%X", num)
    391     Hex$=Left$(Hex$,length)
     406Dim _System_HexadecimalTable[&h10] = [&h30, &h31, &h32, &h33, &h34, &h35, &h36, &h37, &h38, &h39, &h41, &h42, &h43, &h44, &h45, &h46] As Byte
     407
     408Function Hex$(x As DWord) As String
     409    Dim i = 0
     410    Hex$ = ZeroString(8)
     411    While (x And &hf0000000) = 0
     412        x <<= 4
     413    Wend
     414    While x <> 0
     415        Hex$[i] = _System_HexadecimalTable[(x And &hf0000000) >> 28] As Char
     416        x <<= 4
     417        i++
     418    Wend
     419    Hex$.ReSize(i)
     420End Function
     421
     422Function Hex$(x As QWord) As String
     423    Hex$ = Hex$((x >> 32) As DWord) + Hex$((x And &hffffffff) As DWord)
    392424End Function
    393425
     
    429461
    430462Function Left$(buf As String, length As Long) As String
    431     Left$=ZeroString(length)
    432     memcpy(
    433         StrPtr(Left$),
    434         StrPtr(buf),
    435         length)
     463    Left$ = ZeroString(length)
     464    memcpy(StrPtr(Left$), StrPtr(buf), SizeOf (Char) * length)
    436465End Function
    437466
     
    458487
    459488    Mid$=ZeroString(ReadLength)
    460     memcpy(StrPtr(Mid$),StrPtr(buf)+StartPos,ReadLength)
     489    memcpy(StrPtr(Mid$), VarPtr(buf[StartPos]), SizeOf (Char) * ReadLength)
    461490End Function
    462491
     
    486515    If i>length Then
    487516        Right$=ZeroString(length)
    488         memcpy(StrPtr(Right$),StrPtr(buf)+i-length,length)
     517        memcpy(StrPtr(Right$), VarPtr(buf[i-length]), SizeOf (Char) * length)
    489518    Else
    490519        Right$=buf
     
    665694Function Str$(value As LONG_PTR) As String
    666695    Dim temp[255] As Char
    667     wsprintf(temp,"%d",value)
    668     Str$=MakeStr(temp)
     696#ifdef _WIN64
     697    _sntprintf(temp, Len (temp) / SizeOf (Char), "%I64d", value)
     698#else
     699    _sntprintf(temp, Len (temp) / SizeOf (Char), "%d", value)
     700#endif
     701    Str$ = temp
    669702End Function
    670703
     
    681714    Dim i As Long
    682715    For i=0 To num-1
    683         memcpy(StrPtr(String$)+i*length,StrPtr(buf),length)
     716        memcpy(VarPtr(String$[i*length]),StrPtr(buf),SizeOf (Char) * length)
    684717    Next
    685718End Function
     
    727760
    728761    If buf[0]=Asc("&") Then
    729         temporary=ZeroString(lstrlen(buf))
    730         lstrcpy(temporary,buf)
     762        temporary=buf
    731763        TempPtr=StrPtr(temporary)
    732764        CharUpper(TempPtr)
Note: See TracChangeset for help on using the changeset viewer.