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/dos_console.sbp

    r268 r272  
    88
    99#include <api_console.sbp>
     10#include <Classes/ActiveBasic/Strings/Strings.ab>
    1011
    1112Dim _System_hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
     
    1718'---------------------------------------------
    1819Sub INPUT_FromPrompt(ShowStr As String)
    19     Dim i As Long, i2 As Long, i3 As Long
    20     Dim buf As String
    2120    Dim InputBuf[1023] As TCHAR
    2221    Dim dwAccessBytes As DWord
     
    3029    If InputBuf[dwAccessBytes-2] = &h0d And InputBuf[dwAccessBytes-1] = &h0a Then
    3130        InputBuf[dwAccessBytes-2] = 0
     31        dwAccessBytes -= 2
    3232    End If
    33     Dim InputStr As String(InputBuf)
     33
     34    If dwAccessBytes = 0 Then Goto *InputReStart
    3435
    3536    'データを変数に格納
    36     i=0
    37     i2=0
    38     buf.ReSize(lstrlen(InputStr) + 1, 0)
    39     Dim comma As Char
    40     comma = &h2c 'Asc(",")
    41     While 1
    42         i3=0
    43         While 1
    44             If InputStr[i2]=comma Then
    45                 buf[i3]=0
    46                 Exit While
    47             End If
    48 
    49             buf[i3]=InputStr[i2]
    50 
    51             If InputStr[i2]=0 Then Exit While
    52 
    53             i2++
    54             i3++
    55         Wend
    56 
    57         _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
    58 
    59         i++
    60         If _System_InputDataPtr[i]=0 And InputStr[i2]=comma Then
     37    Const comma = &h2c As StrChar 'Asc(",")
     38    Dim broken = ActiveBasic.Strings.Detail.Split(New String(InputBuf, dwAccessBytes As Long), comma)
     39    Dim i As Long
     40    For i = 0 To ELM(broken.Count)
     41        If _System_InputDataPtr[i] = 0 Then
    6142            PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
    6243            Goto *InputReStart
    63         ElseIf InputStr[i2]=0 Then
    64             If _System_InputDataPtr[i]<>0 Then
    65                 PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
    66                 Goto *InputReStart
    67             Else
    68                 Exit While
    69             End If
    7044        End If
     45        _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i].ToString)
     46    Next
    7147
    72         i2++
    73     Wend
     48    If _System_InputDataPtr[i]<>0 Then
     49        PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
     50        Goto *InputReStart
     51    End If
    7452End Sub
    7553
     
    9068    _System_free(pszOut)
    9169#else
    92     WriteConsole(_System_hConsoleOut, buf.Chars, buf.Length, dwAccessBytes, 0)
     70    WriteConsole(_System_hConsoleOut, buf.StrPtr, buf.Length, dwAccessBytes, 0)
    9371#endif
    9472End Sub
Note: See TracChangeset for help on using the changeset viewer.