[1] | 1 | 'dos_console.sbp
|
---|
| 2 | 'このファイルには、コンソール アプリケーション用のサポート プログラムが記載されます。
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | #ifndef _INC_DOS_CONSOLE
|
---|
| 6 | #define _INC_DOS_CONSOLE
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | #include <api_console.sbp>
|
---|
| 10 |
|
---|
| 11 | Dim _System_hConsoleOut As HANDLE, _System_hConsoleIn As HANDLE
|
---|
[110] | 12 | _System_hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
|
---|
| 13 | _System_hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
|
---|
[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)
|
---|
[110] | 20 | Dim i As Long, i2 As Long, i3 As Long
|
---|
[1] | 21 | Dim buf As String
|
---|
| 22 | Dim InputStr[1023] As Byte
|
---|
| 23 | Dim dwAccessBytes As DWord
|
---|
| 24 |
|
---|
| 25 | *InputReStart
|
---|
| 26 |
|
---|
| 27 | PRINT_ToPrompt(ShowStr)
|
---|
| 28 |
|
---|
| 29 | '入力
|
---|
[110] | 30 | ReadConsole(_System_hConsoleIn, InputStr, Len(InputStr), dwAccessBytes, 0)
|
---|
| 31 | If InputStr[dwAccessBytes-2] = &h0d And InputStr[dwAccessBytes-1] = &h0a Then
|
---|
| 32 | InputStr[dwAccessBytes-2] = 0
|
---|
| 33 | End If
|
---|
[1] | 34 |
|
---|
| 35 | 'データを変数に格納
|
---|
| 36 | i=0
|
---|
| 37 | i2=0
|
---|
| 38 | buf.ReSize(lstrlen(InputStr) + 1, 0)
|
---|
[110] | 39 | Dim comma As Char
|
---|
| 40 | comma = &h2c 'Asc(",")
|
---|
[1] | 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 |
|
---|
[123] | 57 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
|
---|
[1] | 58 |
|
---|
| 59 | i++
|
---|
[110] | 60 | If _System_InputDataPtr[i]=0 And InputStr[i2]=comma Then
|
---|
[1] | 61 | PRINT_ToPrompt("入力データの個数が多すぎます"+Chr$(10))
|
---|
| 62 | Goto *InputReStart
|
---|
| 63 | ElseIf InputStr[i2]=0 Then
|
---|
| 64 | If _System_InputDataPtr[i]<>0 Then
|
---|
| 65 | PRINT_ToPrompt("入力データの個数が足りません"+Chr$(10))
|
---|
| 66 | Goto *InputReStart
|
---|
| 67 | Else
|
---|
| 68 | Exit While
|
---|
| 69 | End If
|
---|
| 70 | End If
|
---|
| 71 |
|
---|
| 72 | i2++
|
---|
| 73 | Wend
|
---|
| 74 | End Sub
|
---|
| 75 |
|
---|
| 76 | Macro LOCATE(x As Long, y As Long)
|
---|
[110] | 77 | SetConsoleCursorPosition(_System_hConsoleOut, MAKELONG(x, y))
|
---|
[1] | 78 | End Macro
|
---|
| 79 |
|
---|
| 80 | Sub PRINT_ToPrompt(buf As String)
|
---|
| 81 | Dim dwAccessBytes As DWord
|
---|
[110] | 82 | WriteConsole(_System_hConsoleOut, buf.Chars, buf.Length, dwAccessBytes, 0)
|
---|
[1] | 83 | End Sub
|
---|
| 84 |
|
---|
| 85 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
---|
| 86 | PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
---|
| 87 | End Sub
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | #endif '_INC_DOS_CONSOLE
|
---|