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