モールス

 投稿者:しばっち  投稿日:2019年 9月 8日(日)19時18分56秒
  https://ja.wikipedia.org/wiki/モールス符号


これで合っているのかはわかりません(タイミングとか)
アルファベットと数字と一部の記号のみ入力できます(data文参照)


CALL GINIT(800,800)
DIM B$(128)
DO
   READ IF MISSING THEN EXIT DO:A$
   READ B$(ORD(A$))
LOOP
INPUT X$
FOR I=1 TO LEN(X$)
   LET Z$=Z$&B$(ORD(UCASE$(X$(I:I))))&"/"
NEXT I
LET Y=20
LET X=20
CALL BOX(295,495,505,705,4)
SET LINE WIDTH 10
SET LINE COLOR 7
FOR I=1 TO LEN(Z$)
   IF Z$(I:I)="0" THEN
      IF X+20<800 THEN
         PLOT LINES:X,Y;X+20,Y
         LET X=X+40
      ELSE
         LET X=20
         LET Y=Y+40
         PLOT LINES:X,Y;X+20,Y
         LET X=X+40
      END IF
   ELSEIF Z$(I:I)="1" THEN
      IF X+60<800 THEN
         PLOT LINES:X,Y;X+60,Y
         LET X=X+80
      ELSE
         LET Y=Y+40
         LET X=20
         PLOT LINES:X,Y;X+60,Y
         LET X=X+80
      END IF
   ELSEIF Z$(I:I)="/" THEN
      IF X+20<800 THEN
         LET X=X+20
      ELSE
         LET X=20
         LET Y=Y+40
      END IF
   END IF
NEXT I
LET X=20
LET Y=20
LOCATE VALUE NOWAIT(1),RANGE .2 TO 1.5,AT 1:SPEED
FOR I=1 TO LEN(Z$)-1
   LOCATE VALUE NOWAIT(1):SPEED
   SET LINE COLOR 2
   SELECT CASE Z$(I:I)
   CASE "0"
      IF X+20<800 THEN
         PLOT LINES:X,Y;X+20,Y
         LET X=X+40
      ELSE
         LET X=20
         LET Y=Y+40
         PLOT LINES:X,Y;X+20,Y
         LET X=X+40
      END IF
      CALL CIRCLEFULL(400,600,90,7)
      BEEP 440,150*SPEED
      CALL CIRCLEFULL(400,600,90,0)
      WAIT DELAY .15*SPEED
   CASE "1"
      IF X+60<800 THEN
         PLOT LINES:X,Y;X+60,Y
         LET X=X+80
      ELSE
         LET Y=Y+40
         LET X=20
         PLOT LINES:X,Y;X+60,Y
         LET X=X+80
      END IF
      CALL CIRCLEFULL(400,600,90,7)
      BEEP 440,450*SPEED
      CALL CIRCLEFULL(400,600,90,0)
      WAIT DELAY .15*SPEED
   CASE "/" !文字間隔区切り
      IF X+20<800 THEN
         LET X=X+20
      ELSE
         LET X=20
         LET Y=Y+40
      END IF
      WAIT DELAY .45*SPEED
   CASE "2" !語間隔区切り
      WAIT DELAY .15*SPEED
   END SELECT
NEXT I
DATA A,01
DATA B,1000
DATA C,1010
DATA D,100
DATA E,0
DATA F,0010
DATA G,110
DATA H,0000
DATA I,00
DATA J,0111
DATA K,101
DATA L,0100
DATA M,11
DATA N,10
DATA O,111
DATA P,0110
DATA Q,1101
DATA R,010
DATA S,000
DATA T,1
DATA U,001
DATA V,0001
DATA W,011
DATA X,1001
DATA Y,1011
DATA Z,1100
DATA 1,0111
DATA 2,00111
DATA 3,00011
DATA 4,00001
DATA 5,00000
DATA 6,10000
DATA 7,11000
DATA 8,11100
DATA 9,11110
DATA 0,11111
DATA ".",010101
DATA ",",110011
DATA "?",001100
DATA "!",101011
DATA "-",100001
DATA "/",10010
DATA @,011010
DATA "(",10110
DATA ")",101101
DATA " ",2222222
END

EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
FOR I=0 TO 7
   SET COLOR MIX(I) BITAND(I,2)/2,BITAND(I,4)/4,BITAND(I,1)
NEXT I
CLEAR
END SUB

EXTERNAL SUB CIRCLEFULL(X,Y,RR,C)
SET COLOR C
DRAW DISK WITH SCALE(RR)*SHIFT(X,Y)
END SUB

EXTERNAL SUB BOX(XS,YS,XE,YE,C)
CALL LINE(XS,YS,XE,YS,C)
CALL LINE(XE,YS,XE,YE,C)
CALL LINE(XE,YE,XS,YE,C)
CALL LINE(XS,YE,XS,YS,C)
END SUB

EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES
PLOT LINES:XS,YS;XE,YE
END SUB
 

戻る