Changeset 514


Ignore:
Timestamp:
May 30, 2008, 10:23:36 PM (16 years ago)
Author:
イグトランス (egtra)
Message:

String型引数にNothingが渡された場合への対処。暫定的に""が渡されたのと同じ扱いにしている。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/basic/function.sbp

    r497 r514  
    314314    Dim i As Long, i2 As Long, i3 As Long
    315315
    316     Dim len1 = buf1.Length
    317     Dim len2 = buf2.Length
    318 
    319     If len2=0 Then
    320         InStr=StartPos
     316    Dim len1 = 0 As Long
     317    Dim len2 = 0 As Long
     318    If Not ActiveBasic.IsNothing(buf1) Then len1 = buf1.Length
     319    If Not ActiveBasic.IsNothing(buf2) Then len2 = buf2.Length
     320
     321    If len2 = 0 Then
     322        InStr = StartPos
    321323        Exit Function
    322324    End If
    323325
    324326    StartPos--
    325     If StartPos<0 Then
     327    If StartPos < 0 Then
    326328        'error
    327         InStr=0
     329        InStr = 0
    328330        Exit Function
    329331    End If
     
    348350
    349351Function Left$(s As String, length As Long) As String
    350     Left$ = s.Substring(0, System.Math.Min(s.Length, length))
     352    If Not ActiveBasic.IsNothing(s) Then
     353        Left$ = s.Substring(0, System.Math.Min(s.Length, length))
     354    Else
     355        Left$ = ""
     356    End If
    351357End Function
    352358
    353359Function Mid$(s As String, startPos As Long) As String
    354     startPos--
    355     Mid$ = s.Substring(startPos)
     360    If Not ActiveBasic.IsNothing(s) Then
     361        startPos--
     362        Mid$ = s.Substring(startPos)
     363    Else
     364        Mid$ = ""
     365    End If
    356366End Function
    357367
    358368Function Mid$(s As String, startPos As Long, readLength = 0 As Long) As String
    359     startPos--
    360     Dim length = s.Length
    361     Mid$ = s.Substring(System.Math.Min(startPos, length), System.Math.Min(readLength, length - startPos))
     369    If Not ActiveBasic.IsNothing(s) Then
     370        startPos--
     371        Dim length = s.Length
     372        Mid$ = s.Substring(System.Math.Min(startPos, length), System.Math.Min(readLength, length - startPos))
     373    Else
     374        Mid$ = ""
     375    End If
    362376End Function
    363377
     
    373387
    374388Function Right$(s As String, length As Long) As String
    375     Right$ = s.Substring(System.Math.Max(0, s.Length - length), s.Length)
     389    If Not ActiveBasic.IsNothing(s) Then
     390        Right$ = s.Substring(System.Math.Max(0, s.Length - length), s.Length)
     391    Else
     392        Right$ = ""
     393    End If
    376394End Function
    377395
     
    627645
    628646Function Val(buf As *Char) As Double
     647    If buf = 0 Then
     648        Exit Function
     649    End If
     650
    629651    Dim i As Long, i2 As Long, i3 As Long, i4 As Long
    630652    Dim temporary As String
Note: See TracChangeset for help on using the changeset viewer.