-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThread.rb
1315 lines (1124 loc) · 22.8 KB
/
Thread.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
when flag clicked
INIT
run_examples
println "#MOBLuSE_FORTH 0.11.3"
println "© 2016 Orbin, Lund, Sweden"
println "FOSS with license CC BY-SA 2.0"
println ""
set TermInpBuf to ""
print_one "_"
stop all
when I receive "INIT"
INIT
define INIT
set TRUE to <not <>>
set FALSE to <not not <>>
set Running to TRUE
broadcast "initScreen" and wait
broadcast "initKeyboard" and wait
hide
set color effect to 0
pen up
set pen color to (256 * 256 * 256 * 128 + 256 * 256 * 100 + 256 * 255 + 200)
set pen size to 3
set pen shade to 50
go to x: 0 y: 0
point in direction 90
delete all of History
clear_stacks
delete all of tokens
set CP437 to "☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼"
set ASCII to " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂"
set BOX_ELEMENTS to "▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟"
set BOX_DRAWING to "─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿"
set CHARACTERS to (join join join (CP437) (ASCII) (BOX_ELEMENTS) (BOX_DRAWING))
make_built_in
make_immediates
make_terminated
delete all of Words
delete all of Word_code
delete all of Codes
run_defs
clear
PAGE
set error to 0
set ip_delete to 0
set in_definition to 0
set TermInpBuf to ""
broadcast "bell"
set Running to FALSE
define run_examples
broadcast "run_examples" and wait
define run_example (ex)
set Number to ex
broadcast "run_example" and wait
define run_defs
broadcast "run_defs" and wait
when I receive "break"
set error to -100
set ip to 1 / 0
broadcast "print_response" and wait
set TermInpBuf to ""
stop all
when I receive "print_response"
if error = 0 then
println "OK"
else
if error = -56 then
println ""
else
println (join (code) join "? MSG # " (error))
end
set error to 0
end
set Running to FALSE
when I receive "evaluate_buffer"
set Running to TRUE
set Inkey to ""
tokenize
run_tokens
define-atomic tokenize
set ackumulator to ""
delete all of tokens
set token to 0
set idx to 1
repeat until idx > length of TermInpBuf
set character to letter idx of TermInpBuf
if token = 0 and not character < "!" then
set token to 1
end
if token = 1 and character < "!" then
set token to 0
add ackumulator to tokens
if not letter 1 of ackumulator = "\"" and Terminated contains letter length of ackumulator of ackumulator? then
join_to_terminator
add ackumulator to tokens
end
set ackumulator to ""
end
if token = 1 then
set ackumulator to (join (ackumulator) (character))
end
change idx by 1
end
if length of ackumulator > 0 then
add ackumulator to tokens
end
define-atomic join_to_terminator
set ackumulator to letter length of ackumulator of ackumulator
set j to 1
repeat until j > length of Terminated
if ackumulator = item j of Terminated then
set ackumulator to ""
change idx by 1
set character to letter idx of TermInpBuf
repeat until character = item j of Terminator or idx > length of TermInpBuf
set ackumulator to (join (ackumulator) (character))
change idx by 1
set character to letter idx of TermInpBuf
end
set j to 1 / 0
end
change j by 1
end
define run_tokens
set error to 0
set ip_repl to 1
repeat until ip_repl > length of tokens
set code to item ip_repl of tokens
set next_code_repl to item (ip_repl + 1) of tokens
if Words contains code? then
set ip to ip_repl
execute_word (code)
else
set next_code to next_code_repl
do_built_in_repl
if ip_delete > 0 then
delete_codes
end
end
change ip_repl by 1
end
define-atomic delete_codes
repeat length of Codes - ip_delete + 1
delete last of Codes
end
set ip_delete to 0
define do_built_in_repl
set error to 0
set ip to ip_repl
if Built_in contains code? then
broadcast (join "rt" (code)) and wait
else
if code / code = 1 or code = 0 then
PUSH (code)
else
set error to -13
clear_stacks
set ip_repl to 1 / 0
end
end
define do_built_in
set error to 0
if letter 1 of code = "c" and letter 2 of code = "t" then
broadcast (code) and wait
else
if Built_in contains code? then
broadcast (join "rt" (code)) and wait
else
if code / code = 1 or code = 0 then
PUSH (code)
else
set error to -13
clear_stacks
set ip to 1 / 0
end
end
end
define make_word
if in_definition = 0 then
set in_definition to 1
begin_definition
change ip_repl by 1
end
set error to 0
repeat until item ip_repl of tokens = ";" or error > 0 or ip_repl > length of tokens
set code to item ip_repl of tokens
if Immediates contains code? then
set next_code_repl to item (ip_repl + 1) of tokens
if Built_in contains code? then
broadcast (join "ct" (code)) and wait
else
set ip to ip_repl
execute_word (code)
if ip = 1 / 0 then
set ip_repl to 1 / 0
end
end
else
if Built_in contains code? or Words contains code? or code / code = 1 or code = 0 then
add code to Codes
else
set error to -13
clear_stacks
set ip_repl to 1 / 0
end
end
change ip_repl by 1
end
if item ip_repl of tokens = ";" then
add_exit
end_definition
set in_definition to 0
end
define-atomic make_marker
begin_definition
set error to 0
add "FORGET" to Codes
add item ip_repl of tokens to Codes
add_exit
end_definition
define-atomic make_create
begin_definition
set error to 0
add length of Codes + 5 to Codes
add "ELSE" to Codes
add "1" to Codes
set does_from to length of Codes
add_exit
end_definition
define-atomic .COMMA.
set error to 0
POP
add Popped to Codes
end_definition
define-atomic make_constant
begin_definition
set error to 0
POP
add Popped to Codes
add_exit
end_definition
define-atomic begin_definition
change ip_repl by 1
add item ip_repl of tokens to Words
add length of Words to Codes
add length of Codes to Word_code
add "0" to Codes
set ilength to length of Codes
define-atomic end_definition
replace item ilength of Codes with length of Codes - ilength
define-atomic add_exit
add "EXIT" to Codes
define execute_word [code_arg]
set ip_save to ip
find_word (code_arg) (length of Words)
set ip to item idx of Word_code + 2
execute_ip
define execute_ip
set code to item ip of Codes
set done to 0
rpush -1
repeat until done = 1
repeat until code = "EXIT"
if Words contains code? then
rpush (ip + 1)
find_word (code) (length of Words)
set ip to item idx of Word_code + 2
set code to item ip of Codes
else
if code = "EXECUTE" then
rpush (ip + 1)
POP
set ip to Popped
set code to item ip of Codes
else
set next_code to item (ip + 1) of Codes
do_built_in
if ip = 1 / 0 then
set code to "EXIT"
set done to 1
set ip_save to ip
else
change ip by 1
set code to item ip of Codes
end
end
end
end
rpop
if ip_delete > 0 then
delete_codes
if Popped > length of Codes then
set done to 1
end
end
if Popped = -1 then
set done to 1
else
set ip to Popped
set code to item ip of Codes
end
end
set ip to ip_save
define-atomic find_word [code_arg] (index)
set idx to index
set found to 0
repeat until found = 1 or idx < 1
if code_arg = item idx of Words then
set found to 1
else
change idx by -1
end
end
when I receive "rtMS"
POP
wait Popped / 1000 secs
when I receive "rtTIMER"
PUSH (1000 * timer)
when I receive "rtTIME&DATE"
PUSH (current second)
PUSH (current minute)
PUSH (current hour)
PUSH (current date)
PUSH (current month)
PUSH (current year)
when I receive "rtDRUM"
POP
set popped2 to Popped
POP
play drum Popped for popped2 beats
when I receive "rtREST"
POP
rest for Popped beats
when I receive "rtPLAY"
POP
set popped2 to Popped
POP
play note Popped for popped2 beats
when I receive "uv-1!"
POP
set instrument to Popped
set _instrument to Popped
when I receive "uv-2!"
POP
set tempo to Popped bpm
when I receive "uv-2+!"
POP
change tempo by Popped
when I receive "uv-2@"
PUSH (tempo)
when I receive "uv-3!"
POP
set volume to Popped%
when I receive "uv-3+!"
POP
change volume by Popped
when I receive "uv-3@"
PUSH (volume)
when I receive "rtGOTO-XY"
POP
set popped2 to Popped
POP
go to x: Popped y: popped2
when I receive "uv-4!"
POP
set x to Popped
when I receive "uv-4+!"
POP
change x by Popped
when I receive "uv-4@"
PUSH (x position)
when I receive "uv-5!"
POP
set y to Popped
when I receive "uv-5+!"
POP
change y by Popped
when I receive "uv-5@"
PUSH (y position)
when I receive "rtMOVE"
POP
move Popped steps
when I receive "uv-6!"
POP
point in direction Popped
when I receive "uv-6+!"
POP
turn cw Popped degrees
when I receive "uv-6@"
PUSH (direction)
when I receive "uv-7!"
POP
set pen color to (Popped)
when I receive "uv-8!"
POP
set pen hue to Popped
when I receive "uv-8+!"
POP
change pen hue by Popped
when I receive "uv-9!"
POP
set pen shade to Popped
when I receive "uv-9+!"
POP
change pen shade by Popped
when I receive "uv-10!"
POP
set pen size to Popped
when I receive "uv-10+!"
POP
change pen shade by Popped
when I receive "rtDOWN"
pen down
when I receive "rtUP"
pen up
define PAGE
broadcast "cls" and wait
when I receive "rtAT-XY"
POP
set Current_row to Popped
POP
set Current_column to Popped
when I receive "rtPOS@"
set str to (join "row" (Current_row)) of "Screen"
ascii (letter (Current_column + 1) of str)
PUSH (idx)
when I receive "rtEMIT"
POP
..DQ. (letter Popped of CHARACTERS)
when I receive "rt.\""
change ip by 1
..DQ. (next_code)
when I receive "ct.\""
ct.LP.
when I receive "rtSPACES"
POP
repeat Popped
..DQ. " "
end
when I receive "rt+"
POP
replace item 1 of data with item 1 of data + Popped
when I receive "rt-"
POP
replace item 1 of data with item 1 of data - Popped
when I receive "rt*"
POP
replace item 1 of data with item 1 of data * Popped
when I receive "rt/"
POP
replace item 1 of data with floor of (item 1 of data / Popped)
when I receive "rtF/"
POP
replace item 1 of data with item 1 of data / Popped
when I receive "rtINT"
POP
if Popped < 0 then
PUSH (ceiling of Popped)
else
PUSH (floor of Popped)
end
when I receive "rtFLOOR"
POP
PUSH (floor of Popped)
when I receive "rtFROUND"
POP
PUSH (round Popped)
when I receive "rtMOD"
POP
replace item 1 of data with item 1 of data mod Popped
when I receive "rt/MOD"
POP
insert item 1 of data mod Popped at 2 of data
replace item 1 of data with floor of (item 1 of data / Popped)
when I receive "rt*/"
POP
replace item 1 of data with floor of (item 2 of data * item 1 of data / Popped)
delete 2 of data
when I receive "rt*/MOD"
POP
replace item 1 of data with item 2 of data * item 1 of data
delete 2 of data
PUSH (item 1 of data mod Popped)
PUSH (floor of (item 2 of data / Popped))
delete 3 of data
when I receive "rt1+"
POP
change Popped by 1
PUSH (Popped)
when I receive "rt1-"
POP
change Popped by -1
PUSH (Popped)
when I receive "rt2+"
POP
change Popped by 2
PUSH (Popped)
when I receive "rt2-"
POP
change Popped by -2
PUSH (Popped)
when I receive "rt2*"
POP
change Popped by Popped
PUSH (Popped)
when I receive "rt2/"
POP
set Popped to floor of (Popped / 2)
PUSH (Popped)
when I receive "rt."
POP
..DQ. (join (Popped) " ")
when I receive "rt.R"
POP
set popped2 to Popped
POP
set str to ""
repeat popped2 - length of Popped
set str to (join (str) " ")
end
..DQ. (join (str) (Popped))
when I receive "rt.S"
set j to length of data
..DQ. (join join "<" (j) "> ")
repeat j
..DQ. (join (item j of data) " ")
change j by -1
end
when I receive "rtR.S"
set j to length of return
..DQ. (join join "<" (j) "> ")
repeat j
..DQ. (join (item j of return) " ")
change j by -1
end
when I receive "rt("
change ip by 1
when I receive "ct("
ct.LP.
define-atomic ct.LP.
add code to Codes
add next_code_repl to Codes
change ip_repl by 1
set next_code_repl to item (ip_repl + 1) of tokens
when I receive "ctPOSTPONE"
add (join "ct" (next_code_repl)) to Codes
change ip_repl by 1
set next_code_repl to item ip_repl of tokens
when I receive "rtDROP"
DROP
when I receive "rt2DROP"
_2DROP
define-atomic _2DROP
DROP
DROP
when I receive "rtDUP"
DUP
define-atomic DUP
PUSH (item 1 of data)
when I receive "rt2DUP"
_2DUP
define-atomic _2DUP
PUSH (item 2 of data)
PUSH (item 2 of data)
when I receive "rtSWAP"
SWAP
define-atomic SWAP
POP
insert Popped at 2 of data
when I receive "rt2SWAP"
insert item 1 of data at 5 of data
insert item 2 of data at 6 of data
DROP
DROP
when I receive "rtROT"
PUSH (item 3 of data)
delete 4 of data
when I receive "rt2ROT"
PUSH (item 6 of data)
PUSH (item 6 of data)
delete 7 of data
delete 7 of data
when I receive "rtOVER"
PUSH (item 2 of data)
when I receive "rt2OVER"
PUSH (item 4 of data)
PUSH (item 4 of data)
when I receive "rtABS"
replace item 1 of data with abs of item 1 of data
when I receive "rtNEGATE"
replace item 1 of data with 0 - item 1 of data
when I receive "rtMIN"
POP
if Popped < item 1 of data then
replace item 1 of data with Popped
end
when I receive "rtMAX"
POP
if Popped > item 1 of data then
replace item 1 of data with Popped
end
when I receive "rt>R"
POP
rpush (Popped)
when I receive "rtR>"
rpop
PUSH (Popped)
when I receive "rtI"
PUSH (item 1 of return)
when I receive "rtI'"
PUSH (item 2 of return)
when I receive "rtJ"
PUSH (item 3 of return)
when I receive "rtK"
PUSH (item 5 of return)
when I receive "rt:"
make_word
when I receive "rtMARKER"
make_marker
when I receive "rtCREATE"
make_create
when I receive "rtDOES>"
replace item does_from of Codes with ip + 1 - does_from
set ip to 1 / 0
when I receive "rt,"
.COMMA.
when I receive "rtALLOT"
POP
repeat Popped
PUSH (pick random -32768 to 32767)
.COMMA.
end
when I receive "rtVARIABLE"
make_create
PUSH (pick random -32768 to 32767)
.COMMA.
when I receive "rt!"
POP
set popped2 to Popped
if popped2 < 0 then
broadcast (join join "uv" (popped2) "!") and wait
else
POP
replace item popped2 of Codes with Popped
end
when I receive "rt+!"
POP
set popped2 to Popped
if popped2 < 0 then
broadcast (join join "uv" (popped2) "+!") and wait
else
POP
replace item popped2 of Codes with item popped2 of Codes + Popped
end
when I receive "rt@"
POP
if Popped < 0 then
broadcast (join join "uv" (Popped) "@") and wait
else
PUSH (item Popped of Codes)
end
when I receive "rtCONSTANT"
make_constant
when I receive "rt="
.EQ.
define-atomic .EQ.
POP
if item 1 of data = Popped then
DROP
PUSH -1
else
DROP
PUSH 0
end
when I receive "rt<"
POP
if item 1 of data < Popped then
DROP
PUSH -1
else
DROP
PUSH 0
end
when I receive "rt>"
POP
if item 1 of data > Popped then
DROP
PUSH -1
else
DROP
PUSH 0
end
when I receive "rtINVERT"
POP
PUSH (-1 - Popped)
define-atomic FALSE
PUSH 0
define-atomic TRUE
PUSH -1
when I receive "rt0="
POP
if Popped = 0 then
TRUE
else
FALSE
end
when I receive "rt0<"
POP
if Popped < 0 then
TRUE
else
FALSE
end
when I receive "rtAND"
POP
if abs of item 1 of data = 0 or abs of Popped = 0 then
DROP
FALSE
else
DROP
TRUE
end
when I receive "rtOR"
POP
if abs of item 1 of data = 0 and abs of Popped = 0 then
DROP
FALSE
else
DROP
TRUE
end
when I receive "rtXOR"
POP
if <abs of item 1 of data = 0> = <abs of Popped = 0> then
DROP
FALSE
else
DROP
TRUE
end
when I receive "rt?DUP"
if not abs of item 1 of data = 0 then
DUP
end
when I receive "rtABORT\""
POP
if not abs of Popped = 0 then
..DQ. (next_code)
set error to -2
clear_stacks
set ip to 1 / 0
else
change ip by 1
end
when I receive "ctABORT\""
ct.LP.
define-atomic clear_stacks
delete all of data
delete all of return
when I receive "rtQUIT"
set error to -56
delete all of return
set ip to 1 / 0
when I receive "rt?STACK"
if length of data = 0 then
TRUE
else
FALSE
end
when I receive "rtIF"
POP
if abs of Popped = 0 then
change ip by next_code
else
change ip by 1
end
when I receive "ctIF"
add "IF" to Codes
add "0" to Codes
PUSH (length of Codes)
when I receive "rtELSE"
change ip by next_code
when I receive "ctELSE"
POP
add "ELSE" to Codes
add "0" to Codes
replace item Popped of Codes with length of Codes - Popped + 1
PUSH (length of Codes)
when I receive "ctTHEN"
POP
replace item Popped of Codes with length of Codes - Popped + 1
when I receive "rt[CHAR]"
ascii (next_code)
PUSH (idx)
change ip by 1
when I receive "ct[CHAR]"
ascii (next_code_repl)
add idx to Codes
change ip_repl by 1
set next_code_repl to item (ip_repl + 1) of tokens
when I receive "rtINKEY"
if Inkey = "" then
PUSH 0
else
ascii (Inkey)
set Inkey to ""
PUSH (idx)
end
define-atomic ascii [char]
set idx to 1
repeat until letter idx of CHARACTERS = letter 1 of char or idx > length of CHARACTERS
change idx by 1
end
when I receive "rtEXECUTE"
set ip_save to ip
POP
set ip to Popped
execute_ip
when I receive "rt'"
find_word (next_code_repl) (length of Words)
PUSH (item idx of Word_code + 2)
change ip_repl by 1
set next_code_repl to item (ip_repl + 1) of tokens
when I receive "rt[']"
find_word (next_code) (length of Words)
PUSH (item idx of Word_code + 2)
change ip by 1
when I receive "ct[']"
ct.LP.
when I receive "rtDO"
SWAP
POP
rpush (Popped)
POP
rpush (Popped)
when I receive "ctDO"
add "DO" to Codes
PUSH (length of Codes)
rpush -1
when I receive "rt?DO"