Ignore:
Timestamp:
Jun 12, 2007, 7:24:38 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

StringBuilderを追加。String不変へ。共通の文字列操作関数をActiveBasic.Strings内に配置(設計に検討の余地あり)。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/basic/prompt.sbp

    r269 r272  
    7575
    7676Sub _PromptSys_Initialize()
    77 _PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0)
    78 Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID)
    79 If _PromptSys_hThread = 0 Then
    80     Debug
    81     ExitProcess(1)
    82 End If
    83 WaitForSingleObject(_PromptSys_hInitFinish, INFINITE)
     77    _PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0)
     78    Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID)
     79    If _PromptSys_hThread = 0 Then
     80        Debug
     81        ExitProcess(1)
     82    End If
     83    WaitForSingleObject(_PromptSys_hInitFinish, INFINITE)
    8484End Sub
    8585
     
    191191                            charLen = 1
    192192                        EndIf
    193                         _PromptSys_GetTextExtentPoint32(hdc, VarPtr(buf.Chars[i2]) As *StrChar, charLen, sz)
     193                        Dim p = buf.StrPtr
     194                        _PromptSys_GetTextExtentPoint32(hdc, VarPtr(p[i2]) As *StrChar, charLen, sz)
    194195                        currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos + sz.cx
    195196/*
     
    363364*/
    364365        Else
    365             _PromptSys_InputStr[_PromptSys_InputLen] = wParam As Byte
     366            Dim t = wParam As TCHAR
     367            TempStr = New String(VarPtr(t), 1)
     368            _PromptSys_InputStr[_PromptSys_InputLen] = TempStr[0]
    366369            _PromptSys_InputLen++
    367 
    368             TempStr.ReSize(1)
    369             TempStr[0] = wParam As Char
    370370        End If
    371371
     
    403403            Return 0
    404404        End If
    405         Dim tempStr As String
     405        Dim tempStr = Nothing As String
    406406        Dim str As *StrChar
    407407#ifdef __STRING_IS_NOT_UNICODE
    408408        Dim size = _PromptWnd_GetCompositionStringA(himc, str)
    409         tempStr.Assign(str, size)
     409        tempStr = New String(str, size As Long)
    410410#else
    411411        Dim osver = System.Environment.OSVersion
     
    415415                Dim strA As PCSTR
    416416                Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA)
    417                 tempStr.AssignFromMultiByte(strA, sizeA)
     417                tempStr = New String(strA, sizeA As Long)
    418418            Else
    419419                Dim size = _PromptWnd_GetCompositionStringW(himc, str)
    420                 tempStr.Assign(str, size \ SizeOf (WCHAR))
     420                tempStr = New String(str, (size \ SizeOf (WCHAR)) As Long)
    421421            End If
    422422        End With
     
    425425        _System_free(str)
    426426
    427         memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.Chars, SizeOf (StrChar) * tempStr.Length)
     427        ActiveBasic.Strings.ChrCopy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.StrPtr, tempStr.Length As SIZE_T)
    428428        _PromptSys_InputLen += tempStr.Length
    429429
     
    583583
    584584Sub INPUT_FromPrompt(showStr As String)
    585     Dim i As Long, i2 As Long, i3 As Long
    586     Dim buf As String
    587 
    588585*InputReStart
    589586
     
    599596
    600597    'Set value to variable
    601     i = 0
    602     i2 = 0
    603     buf = ZeroString(lstrlen(_PromptSys_InputStr))
    604     While 1
    605         i3 = 0
    606         While 1
    607             If _PromptSys_InputStr[i2] = &h2c Then
    608                 buf.Chars[i3] = 0
    609                 Exit While
    610             End If
    611 
    612             buf.Chars[i3] = _PromptSys_InputStr[i2]
    613 
    614             If _PromptSys_InputStr[i2] = 0 Then Exit While
    615 
    616             i2++
    617             i3++
    618         Wend
    619 
    620         _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
    621 
    622         i++
    623         If _System_InputDataPtr[i] = 0 and _PromptSys_InputStr[i2] = &h2c Then 'Asc(",")
     598    Const comma = &h2c As StrChar 'Asc(",")
     599    Dim broken = ActiveBasic.Strings.Detail.Split(New String(_PromptSys_InputStr), comma)
     600    Dim i As Long
     601    For i = 0 To ELM(broken.Count)
     602        If _System_InputDataPtr[i] = 0 Then
    624603            ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
    625604            Goto *InputReStart
    626         ElseIf _PromptSys_InputStr[i2] = 0 Then
    627             If _System_InputDataPtr[i]<>0 Then
    628                 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
    629                 Goto *InputReStart
    630             Else
    631                 Exit While
    632             End If
    633         End If
    634 
    635         i2++
    636     Wend
     605        End If
     606        _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i].ToString)
     607    Next
     608
     609    If _System_InputDataPtr[i]<>0 Then
     610        ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
     611        Goto *InputReStart
     612    End If
    637613End Sub
    638614
Note: See TracChangeset for help on using the changeset viewer.