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

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

タイプミスとか修整

File size: 2.1 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 System.Console.Write(buf)
62End Sub
63/* TODO: _System_GetUsingFormatを用意して実装する
64Sub PRINTUSING_ToPrompt(UsingStr As String)
65 PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
66End Sub
67*/
68
69#endif '_INC_DOS_CONSOLE
Note: See TracBrowser for help on using the repository browser.