X,Y章で利用したプログラム

'-------------------------------------------------
'     電圧の測定
'-------------------------------------------------
' マウスでポインティングできます。
'$INCLUDE: 'QB.BI'
'$INCLUDE: 'MOUSE.BI'

DECLARE SUB INITIALIZE ()
DECLARE SUB GRAPH ()
DECLARE SUB END.PROGRAM ()

CONST PI = 3.141592, XO.T = 12, YO.T = 18, X.TIME = 1, X.VOLT = 57
CONST M.MAX = 60, X.LEN = M.MAX, Y.LEN = 16, END.TIME = 180
CONST SAMPLING.TIME = 8, LINE.COLOR = 11

CALL INITIALIZE
Mouseini: Mcolor 0
Mview 3 + 8 * XO.T, 8 + 16 * YO.T - 16 * Y.LEN, 3 + 8 * XO.T + 8 * X.LEN, 8 + 2 * 16 + 16 * YO.T

CLS
COLOR 7
LOCATE 9, 14: PRINT "Copyright (C) 1993 by Ibaraki Teacher Training Center"
LOCATE 6, 16: PRINT "==============================================="
COLOR 6
LOCATE 7, 16: PRINT "  電圧の時間変化を測定します"
COLOR 7
LOCATE 8, 16: PRINT "==============================================="
COLOR 6
LOCATE 13, 16: PRINT " INPUT1"; : COLOR 3: PRINT "に電圧を入力して下さい"
COLOR 2
LOCATE 15, 16: PRINT "   SW1を"; : COLOR 6: PRINT "STD"; : COLOR2: PRINT "にして下さい"
LOCATE 17, 16: PRINT "   SW2を"; : COLOR 6: PRINT "MONO"; : COLOR2: PRINT "にして下さい"
COLOR 7
BEEP: COLOR 23
LOCATE 23, 16: PRINT "準備ができましたら,リターンキーを押して下さい"
COLOR 7
DO
   IK$ = INKEY$
LOOP WHILE IK$ = ""
START:
Flag = 0
BEEP
CALL GRAPH
DO
   IF Flag = 1 THEN BEEP
   IK$ = INKEY$
   IF IK$ = "" THEN
         GOTO LAST.IF
   END IF
   IK = ASC(IK$)
   IF IK = &H53 OR IK = &H73 OR IK = &HC4 THEN
          IF FLG = 0 GOTO LAST.IF
          Flag = 0: FLG = Flag
          CLS 1: CALL GRAPH
          LOCATE 2, 61: PRINT "       "
          GOTO LAST.IF
   ELSEIF IK = &H47 OR IK = &H67 OR IK = &HB7 THEN
          IF FLG = 1 GOTO LAST.IF
          Flag = 1: FLG = Flag
          T = 0
          LOCATE 1, 55: PRINT "開始時刻"; : PRINT LEFT$(TIME$, SAMPLING.TIME)
          GOTO LAST.IF
   ELSEIF IK = &H48 OR IK = &H68 OR IK = &HB8 THEN
          BEEP
          LOCATE 23, 10
          COLOR 5: PRINT "     どれかキーを押すと,";
          COLOR 7: PRINT "待機";
          COLOR 6: PRINT "S"; : COLOR 7: PRINT "tandby";
          COLOR 5: PRINT "にもどります      "
          COLOR 7:
          Setmouse XO, YO - 16 * Y.LEN
          Mouse 1
          LOCATE 5, 50: PRINT "指示時間    秒"
          LOCATE 4, 50: PRINT "指示電圧    V"
          DO
                 IK$ = INKEY$
                 Getmouse Right, left, X, Y
                 IF YO - Y < 0 THEN Y = YO
                 LOCATE 5, 59: COLOR 2: PRINT USING "  ###"; (X - XO) * 3 / 8
                 LOCATE 4, 59: COLOR 3: PRINT USING "##.##"; (YO - Y) / 16 / 4
          LOOP WHILE IK$ = ""
          Mouse 0
          FLG = 0
          GOTO START
   ELSEIF IK = &H45 OR IK = &H65 OR IK = &HB2 THEN
          CALL END.PROGRAM
          EXIT DO
   END IF
LAST.IF:
   LOCATE 2, 55: PRINT "現在時刻"
   TIME0$ = MID$(TIME$, SAMPLING.TIME, 1)
   COLOR 2: PRINT LEFT$(TIME$, SAMPLING.TIME): COLOR 7
   PRINT #1, "a";
   DO
   LOOP WHILE LOC(1) = 0
   DUMMY$ = INPUT$(1, #1)
   PRINT #1, "i";
   LINE INPUT #1, D$: VT = VAL(D$): DUMMY$ = INPUT$(1, #1)
   VT = VT / 256 * 5
   COLOR 3: LOCATE 2, 25: PRINT USING "##.##"; VT: COLOR 7
   IF VT > 4 THEN VT = 4
   IF VS <> VT THEN
          CIRCLE (XO - 8 * 8.5, YO -16 * 4 * VS), 6, 0, , , .4
          PRINT (XO - 8 * 8.5, YO -16 * 4 * VS), 0, 0
   END IF
   CIRCLE (XO - 8 * 8.5, YO -16 * 4 * VT), 6, 4, , , .4
   PRINT (XO - 8 * 8.5, YO -16 * 4 * VT), 4, 4
   VS = VT
   IF Flag = 0 THEN
          GOTO END.LOOP
   ELSEIF Flag = 1 THEN
          CIRCLE (XO + 8 * T * 2 / 6, YO -16 * 4 * VT), 1, 7
          PRINT (XO + 8 * T * 2 / 6, YO -16 * 4 * VT), 7
   END IF
   DO
   LOOP WHILE MID$(TIME$, SAMPLING.TIME, 1) = TIME0$
   T = T + 1
   IF T > END.TIME THEN
BEGIN.DO:
          DO
                 BEEP
                 IK$ = INKEY$
                 LOOP WHILE IK$ = ""
          IK = ASC(IK$)
          IF IK = &H53 OR IK = &H73 OR IK = &HC4 THEN
                 FLG = 0
                 GOTO START
          ELSEIF IK = &H45 OR OR IK = &H65 OR IK = &HB2 THEN
                 EXIT DO
          ELSEIF IK = &H48 OR OR IK = &H68 OR IK = &HB8 THEN
                 BEEP
                 LOCATE 23, 10
                 COLOR 5: PRINT "     どれかキーを押すと,";
                 COLOR 7: PRINT "待機";
                 COLOR 6: PRINT "S"; : COLOR 7: PRINT "tandby";
                 COLOR 5: PRINT "にもどります      "
                 COLOR 7:
                 Setmouse XO, YO - 16 * Y.LEN
                 Mouse 1
                 LOCATE 5, 50: PRINT "指示時間    秒"
                 LOCATE 4, 50: PRINT "指示電圧    V"
                 DO
                        IK$ = INKEY$
                        Getmouse Right, left, X, Y
                        IF YO - Y < 0 THEN Y = YO
                        LOCATE 5, 59: COLOR 2: PRINT USING "  ###"; (X - XO) * 3 / 8
                        LOCATE 4, 59: COLOR 3: PRINT USING "##.##"; (YO - Y) / 16 / 4
                 LOOP WHILE IK$ = ""
                 Mouse 0
                 FLG = 0
                 GOTO START'GOTO START
          END IF
          GOTO BEGIN.DO
   END IF
END.LOOP:
LOOP WHILE 1
CLS
CLOSE #1
END

SUB END.PROGRAM
   CLS
   CLOSE #1
END SUB

SUB GRAPH
   SHARED XO, YO
   CLS
   XO = 3 + 8 * XO.T: YO = 8 + 16 * YO.T
   LINE (XO - 8 * 7, YO - 16 * Y.LEN)-(XO - 8 * 5, YO), 15, BF
   FOR I = 1 TO Y.LEN - 1
          LINE (XO - 8 * 7, YO - 16 * I)-(XO - 8 * 6.5, YO - 16 * I), 0
   NEXT
   TITLE$ = "秒"
   LINE (XO , YO)-(XO + 8 * X.LEN, YO - 16 * Y.LEN), LINE.COLOR, B
   FOR I = 1 TO Y.LEN - 1
          LINE (XO , YO - 16 * I)-(XO + 8 * X.LEN, YO - 16 * I), LINE.COLOR, , &H8888
   NEXT
   FOR I = 1 TO X.LEN / 10 - 1
          LINE (XO + 8 * 10 * I, YO)-(XO + 8 * 10 * I, YO - 16 * Y.LEN), LINE.COLOR, , &H8888
   NEXT
   COLOR 6
   COLOR 7
   LOCATE 2, 14: PRINT "現在の電圧    V"
   COLOR 3
   FOR I = 1 TO Y.LEN STEP 4
          LOCATE YO.T - I + 1, XO.T - 2: PRINT USING "##"; I / 4
          YO)-(XO + 8 * 10 * I, YO - 16 * Y.LEN), LINE.COLOR, , &H8888
   NEXT
   LOCATE YO.T - 9, 1: PRINT "電"
   LOCATE YO.T - 7, 1: PRINT "圧"
   LOCATE YO.T - 5, 1: PRINT "V"
   COLOR 2
   FOR I = 0 TO X.LEN / 10
          LOCATE YO.T + 2, XO.T + 10 * I: PRINT USING "###"; 30 * I
   NEXT
   LOCATE YO.T + 3, 38: PRINT "測定時間 [ ": TITLE$; "]"
   COLOR 7: LOCATE 23, 15: PRINT "待機"; : COLOR 6: PRINT "S";
   COLOR 7: PRINT "tandby   実行"; : COLOR 6: PRINT "G";
   COLOR 7: PRINT "o   停止"; : COLOR 6: PRINT "H";
   COLOR 7: PRINT "alt   終了"; : COLOR 6: PRINT "E";
   COLOR 7: PRINT "nd"
END SUB

SUB INITIALIZE
   CLS
   VIEW PRINT 1 TO 24
   OPEN "COM1:9600,N,8,1,ASC" FOR RANDOM AS #1
END SUB


[目次へ]