[1] | 1 | 'dos_console.sbp
|
---|
| 2 | 'このファイルには、コンソール アプリケーション用のサポート プログラムが記載されます。
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | #ifndef _INC_DOS_CONSOLE
|
---|
| 6 | #define _INC_DOS_CONSOLE
|
---|
| 7 |
|
---|
| 8 |
|
---|
[268] | 9 | Dim _System_hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
|
---|
| 10 | Dim _System_hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
|
---|
[432] | 11 | System.Console.SetIn(
|
---|
| 12 | New System.IO.StreamReader(
|
---|
| 13 | New System.IO.FileStream(_System_hConsoleIn, System.IO.FileAccess.Read, False)))
|
---|
[1] | 14 |
|
---|
| 15 | '---------- command.sbp内で定義済み ----------
|
---|
| 16 | 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
|
---|
| 17 | 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
|
---|
| 18 | '---------------------------------------------
|
---|
| 19 | Sub INPUT_FromPrompt(ShowStr As String)
|
---|
[432] | 20 | *InputReStart '多重Continueがあるので、これはループ構文に直せない。
|
---|
[1] | 21 | PRINT_ToPrompt(ShowStr)
|
---|
| 22 |
|
---|
| 23 | '入力
|
---|
[432] | 24 | Dim input = System.Console.ReadLine()
|
---|
| 25 | If ActiveBasic.IsNothing(input) Then
|
---|
| 26 | Exit Sub
|
---|
[110] | 27 | End If
|
---|
[1] | 28 |
|
---|
[432] | 29 | If input.Length = 0 Then Goto *InputReStart
|
---|
[272] | 30 |
|
---|
[1] | 31 | 'データを変数に格納
|
---|
[272] | 32 | Const comma = &h2c As StrChar 'Asc(",")
|
---|
[432] | 33 | Dim broken = ActiveBasic.Strings.Detail.Split(input, comma)
|
---|
[272] | 34 | Dim i As Long
|
---|
| 35 | For i = 0 To ELM(broken.Count)
|
---|
| 36 | If _System_InputDataPtr[i] = 0 Then
|
---|
[142] | 37 | PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
|
---|
[432] | 38 | Goto *InputReStart
|
---|
[1] | 39 | End If
|
---|
[391] | 40 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i])
|
---|
[272] | 41 | Next
|
---|
[1] | 42 |
|
---|
[272] | 43 | If _System_InputDataPtr[i]<>0 Then
|
---|
| 44 | PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
|
---|
[432] | 45 | Goto *InputReStart
|
---|
[272] | 46 | End If
|
---|
[1] | 47 | End Sub
|
---|
| 48 |
|
---|
| 49 | Macro LOCATE(x As Long, y As Long)
|
---|
[110] | 50 | SetConsoleCursorPosition(_System_hConsoleOut, MAKELONG(x, y))
|
---|
[1] | 51 | End Macro
|
---|
| 52 |
|
---|
| 53 | Sub PRINT_ToPrompt(buf As String)
|
---|
[432] | 54 | If String.IsNullOrEmpty(buf) Then
|
---|
| 55 | Exit Sub
|
---|
| 56 | End If
|
---|
| 57 |
|
---|
[1] | 58 | Dim dwAccessBytes As DWord
|
---|
[142] | 59 | #ifdef __STRING_UNICODE_WINDOWS_ANSI
|
---|
| 60 | ' Debug
|
---|
| 61 | Dim oldAlloc = _System_AllocForConvertedString
|
---|
| 62 | _System_AllocForConvertedString = AddressOf (_System_malloc)
|
---|
| 63 | Dim pszOut As PCSTR
|
---|
| 64 | Dim len = GetStr(buf, pszOut)
|
---|
| 65 | _System_AllocForConvertedString = oldAlloc
|
---|
| 66 | WriteConsole(_System_hConsoleOut, pszOut, len, dwAccessBytes, 0)
|
---|
| 67 | _System_free(pszOut)
|
---|
| 68 | #else
|
---|
[272] | 69 | WriteConsole(_System_hConsoleOut, buf.StrPtr, buf.Length, dwAccessBytes, 0)
|
---|
[142] | 70 | #endif
|
---|
[1] | 71 | End Sub
|
---|
[288] | 72 | /* TODO: _System_GetUsingFormatを用意して実装する
|
---|
[1] | 73 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
---|
| 74 | PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
---|
| 75 | End Sub
|
---|
[288] | 76 | */
|
---|
[1] | 77 |
|
---|
| 78 | #endif '_INC_DOS_CONSOLE
|
---|