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