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

Last change on this file since 522 was 522, checked in by OverTaker, 16 years ago

Console.Writeを実装。TextWriter.Synchronizedは実装してません。

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