Changeset 121 for Include/basic/function.sbp
- Timestamp:
- Feb 25, 2007, 12:56:09 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/basic/function.sbp
r119 r121 290 290 End Function 291 291 292 Function IsNaN(ByVal x As Double) As B OOL292 Function IsNaN(ByVal x As Double) As Boolean 293 293 Dim p As *DWord 294 294 p = VarPtr(x) As *DWord … … 296 296 If (p[1] And &H7FF00000) = &H7FF00000 Then 297 297 If (p[0] <> 0) Or ((p[1] And &HFFFFF) <> 0) Then 298 IsNaN = T RUE298 IsNaN = True 299 299 End If 300 300 End If … … 303 303 End Function 304 304 305 Function IsInf(x As Double) As B OOL305 Function IsInf(x As Double) As Boolean 306 306 Dim p As *DWord, nan As Double 307 307 p = VarPtr(x) As *DWord … … 311 311 End Function 312 312 313 Function IsNaNOrInf(x As Double) As B OOL313 Function IsNaNOrInf(x As Double) As Boolean 314 314 IsNaNOrInf = IsFinite(x) 315 315 End Function 316 316 317 Function IsFinite(x As Double) As B OOL317 Function IsFinite(x As Double) As Boolean 318 318 Dim p As *DWord, nan As Double 319 319 p = VarPtr(x) As *DWord … … 322 322 p[0] = 0 323 323 nan = _System_GetInf(/*x,*/ FALSE) 324 Is NaNOrInf= (memcmp(p As BytePtr, VarPtr(nan), SizeOf (Double)) = 0)324 IsFinite = (memcmp(p As BytePtr, VarPtr(nan), SizeOf (Double)) = 0) 325 325 End Function 326 326 … … 349 349 350 350 Function 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 353 End Function 354 355 #ifdef UNICODE 356 Function 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 366 End Function 367 368 Function 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 379 End Function 380 #endif 354 381 355 382 Function Date$() As String 356 383 Dim st As SYSTEMTIME 357 358 384 GetLocalTime(st) 359 385 … … 378 404 End Function 379 405 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) 406 Dim _System_HexadecimalTable[&h10] = [&h30, &h31, &h32, &h33, &h34, &h35, &h36, &h37, &h38, &h39, &h41, &h42, &h43, &h44, &h45, &h46] As Byte 407 408 Function 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) 420 End Function 421 422 Function Hex$(x As QWord) As String 423 Hex$ = Hex$((x >> 32) As DWord) + Hex$((x And &hffffffff) As DWord) 392 424 End Function 393 425 … … 429 461 430 462 Function 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) 436 465 End Function 437 466 … … 458 487 459 488 Mid$=ZeroString(ReadLength) 460 memcpy(StrPtr(Mid$), StrPtr(buf)+StartPos,ReadLength)489 memcpy(StrPtr(Mid$), VarPtr(buf[StartPos]), SizeOf (Char) * ReadLength) 461 490 End Function 462 491 … … 486 515 If i>length Then 487 516 Right$=ZeroString(length) 488 memcpy(StrPtr(Right$), StrPtr(buf)+i-length,length)517 memcpy(StrPtr(Right$), VarPtr(buf[i-length]), SizeOf (Char) * length) 489 518 Else 490 519 Right$=buf … … 665 694 Function Str$(value As LONG_PTR) As String 666 695 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 669 702 End Function 670 703 … … 681 714 Dim i As Long 682 715 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) 684 717 Next 685 718 End Function … … 727 760 728 761 If buf[0]=Asc("&") Then 729 temporary=ZeroString(lstrlen(buf)) 730 lstrcpy(temporary,buf) 762 temporary=buf 731 763 TempPtr=StrPtr(temporary) 732 764 CharUpper(TempPtr)
Note:
See TracChangeset
for help on using the changeset viewer.