source: Include/basic/dos_console.sbp@ 94

Last change on this file since 94 was 1, checked in by (none), 18 years ago
File size: 2.7 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 InputStr[1023] As Byte
23 Dim dwAccessBytes As DWord
24
25*InputReStart
26
27 PRINT_ToPrompt(ShowStr)
28
29 '入力
30 ReadFile(_System_hConsoleIn,InputStr,1024,VarPtr(dwAccessBytes),ByVal 0)
31 InputStr[dwAccessBytes-2]=0
32
33 'データを変数に格納
34 i=0
35 i2=0
36 buf.ReSize(lstrlen(InputStr) + 1, 0)
37 Dim comma As Byte
38 comma = Asc(",")
39 While 1
40 i3=0
41 While 1
42 If InputStr[i2]=comma Then
43 buf[i3]=0
44 Exit While
45 End If
46
47 buf[i3]=InputStr[i2]
48
49 If InputStr[i2]=0 Then Exit While
50
51 i2++
52 i3++
53 Wend
54
55 Select Case _System_InputDataType[i]
56 Case _System_Type_Double
57 SetDouble(_System_InputDataPtr[i],Val(buf))
58 Case _System_Type_Single
59 SetSingle(_System_InputDataPtr[i],Val(buf))
60 Case _System_Type_Int64,_System_Type_QWord
61 SetQWord(_System_InputDataPtr[i],Val(buf))
62 Case _System_Type_Long,_System_Type_DWord
63 SetDWord(_System_InputDataPtr[i],Val(buf))
64 Case _System_Type_Integer,_System_Type_Word
65 SetWord(_System_InputDataPtr[i],Val(buf))
66 Case _System_Type_Char,_System_Type_Byte
67 SetByte(_System_InputDataPtr[i],Val(buf))
68 Case _System_Type_String
69 Dim pTempStr As *String
70 pTempStr=_System_InputDataPtr[i] As *String
71 pTempStr->Assign(buf, i3)
72 End Select
73
74 i++
75 If _System_InputDataPtr[i]=0 and InputStr[i2]=comma Then
76 PRINT_ToPrompt("入力データの個数が多すぎます"+Chr$(10))
77 Goto *InputReStart
78 ElseIf InputStr[i2]=0 Then
79 If _System_InputDataPtr[i]<>0 Then
80 PRINT_ToPrompt("入力データの個数が足りません"+Chr$(10))
81 Goto *InputReStart
82 Else
83 Exit While
84 End If
85 End If
86
87 i2++
88 Wend
89End Sub
90
91Macro LOCATE(x As Long, y As Long)
92 SetConsoleCursorPosition(_System_hConsoleOut, MAKELONG(x ,y))
93End Macro
94
95Sub PRINT_ToPrompt(buf As String)
96 Dim dwAccessBytes As DWord
97 WriteFile(_System_hConsoleOut, buf.Chars, buf.Length, VarPtr(dwAccessBytes), ByVal 0)
98End Sub
99
100Sub PRINTUSING_ToPrompt(UsingStr As String)
101 PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
102End Sub
103
104
105#endif '_INC_DOS_CONSOLE
Note: See TracBrowser for help on using the repository browser.