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