source: trunk/ab5.0/ablib/src/basic/dos_console.sbp@ 606

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

Consoleにてエラー出力を整備

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