source: branch/egtra-gdiplus/basic/dos_console.sbp@ 421

Last change on this file since 421 was 142, checked in by イグトランス (egtra), 18 years ago

Environment, OperatingSystem, Versionの追加、Unicode対応修正ほか

File size: 2.5 KB
Line 
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
11Dim _System_hConsoleOut As HANDLE, _System_hConsoleIn As HANDLE
12_System_hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
13_System_hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
14
15'---------- command.sbp内で定義済み ----------
16'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
17'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
18'---------------------------------------------
19Sub INPUT_FromPrompt(ShowStr As String)
20 Dim i As Long, i2 As Long, i3 As Long
21 Dim buf As String
22 Dim InputBuf[1023] As TCHAR
23 Dim dwAccessBytes As DWord
24
25*InputReStart
26
27 PRINT_ToPrompt(ShowStr)
28
29 '入力
30 ReadConsole(_System_hConsoleIn, InputBuf, Len(InputBuf), dwAccessBytes, 0)
31 If InputBuf[dwAccessBytes-2] = &h0d And InputBuf[dwAccessBytes-1] = &h0a Then
32 InputBuf[dwAccessBytes-2] = 0
33 End If
34 Dim InputStr As String(InputBuf)
35
36 'データを変数に格納
37 i=0
38 i2=0
39 buf.ReSize(lstrlen(InputStr) + 1, 0)
40 Dim comma As Char
41 comma = &h2c 'Asc(",")
42 While 1
43 i3=0
44 While 1
45 If InputStr[i2]=comma Then
46 buf[i3]=0
47 Exit While
48 End If
49
50 buf[i3]=InputStr[i2]
51
52 If InputStr[i2]=0 Then Exit While
53
54 i2++
55 i3++
56 Wend
57
58 _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
59
60 i++
61 If _System_InputDataPtr[i]=0 And InputStr[i2]=comma Then
62 PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
63 Goto *InputReStart
64 ElseIf InputStr[i2]=0 Then
65 If _System_InputDataPtr[i]<>0 Then
66 PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
67 Goto *InputReStart
68 Else
69 Exit While
70 End If
71 End If
72
73 i2++
74 Wend
75End Sub
76
77Macro LOCATE(x As Long, y As Long)
78 SetConsoleCursorPosition(_System_hConsoleOut, MAKELONG(x, y))
79End Macro
80
81Sub PRINT_ToPrompt(buf As String)
82 Dim dwAccessBytes As DWord
83#ifdef __STRING_UNICODE_WINDOWS_ANSI
84' Debug
85 Dim oldAlloc = _System_AllocForConvertedString
86 _System_AllocForConvertedString = AddressOf (_System_malloc)
87 Dim pszOut As PCSTR
88 Dim len = GetStr(buf, pszOut)
89 _System_AllocForConvertedString = oldAlloc
90 WriteConsole(_System_hConsoleOut, pszOut, len, dwAccessBytes, 0)
91 _System_free(pszOut)
92#else
93 WriteConsole(_System_hConsoleOut, buf.Chars, buf.Length, dwAccessBytes, 0)
94#endif
95End Sub
96
97Sub PRINTUSING_ToPrompt(UsingStr As String)
98 PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
99End Sub
100
101
102#endif '_INC_DOS_CONSOLE
Note: See TracBrowser for help on using the repository browser.