mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2024-11-30 01:49:29 +00:00
139 lines
2.6 KiB
Plaintext
139 lines
2.6 KiB
Plaintext
10 REM PIG LATIN TRANSLATOR
|
|
|
|
20 REM BY Gregg Buntin
|
|
|
|
30 REM OCT. 10, 1984
|
|
|
|
40 GOTO 140
|
|
|
|
50 REM THINGS TO WATCH FOR
|
|
|
|
60 CK$ = " .,;:><?/)(*&^%$#@!+={}[]1234567890"
|
|
|
|
70 REM VOWELS
|
|
|
|
80 CV$ = "AEIOU"
|
|
|
|
90 DIM X$(100)
|
|
|
|
100 RETURN
|
|
|
|
110 REM CENTER STRING ON SCREEN
|
|
|
|
120 HTAB (39 - LEN (A$)) / 2 + 1: PRINT A$: RETURN
|
|
|
|
130 REM BEGINING
|
|
|
|
140 TEXT : HOME :A$ = "PIG LATIN TRANSLATOR"
|
|
|
|
150 GOSUB 120:A$ = "BY Gregg Buntin": VTAB 2: GOSUB 120
|
|
|
|
160 REM KEEP TITLE ON PAGE
|
|
|
|
170 POKE 34,2: VTAB 6
|
|
|
|
180 REM DIRECTIONS
|
|
|
|
190 PRINT : PRINT : PRINT
|
|
|
|
200 HOME : VTAB 5: PRINT "THIS FUNCTION WILL CONVERT ANY SENTENCE"
|
|
|
|
210 PRINT "FROM ENGLISH TO PIG LATIN. BE SURE TO"
|
|
|
|
220 PRINT "TYPE THE WORDS IN CORRECTLY OR YOU MAY"
|
|
|
|
230 PRINT "GET GARBAGE SENTENCES. DO NOT USE ANY"
|
|
|
|
240 PRINT "COMMAS OR QUOTATION MARKS. WHEN READY"
|
|
|
|
250 PRINT "TO QUIT JUST TYPE 'FINISHED'. HAVE FUN!"
|
|
|
|
260 PRINT : PRINT : PRINT
|
|
|
|
270 REM GET SET TO START
|
|
|
|
280 VTAB 15:A$ = "PRESS RETURN TO CONTINUE": GOSUB 120
|
|
|
|
290 K = PEEK ( - 16384): IF K < > 141 THEN 290
|
|
|
|
300 POKE - 16368,0
|
|
|
|
310 REM GET SENTENCE
|
|
|
|
320 HOME : VTAB 10
|
|
|
|
330 PRINT : PRINT : PRINT
|
|
|
|
340 INPUT "ENGLISH SENTENCE :";ES$
|
|
|
|
350 IF ES$ = "" THEN 320
|
|
|
|
360 GOSUB 60
|
|
|
|
370 REM ARE THEY DONE?
|
|
|
|
380 IF ES$ = "FINISHED" THEN TEXT : HOME :A$ = "ATSTHA ALLA OLKSFA": GOSUB 120:A$ = "(THATS ALL FOLKS)": GOSUB 120: END
|
|
|
|
390 REM TRANSLATE THE SENTENCE
|
|
|
|
400 PRINT : PRINT : PRINT
|
|
|
|
410 HOME : FLASH :A$ = "TRANSLATING": VTAB 6: GOSUB 120: NORMAL
|
|
|
|
420 REM ISOLATE WORDS & GARBAGE
|
|
|
|
430 X = 1: FOR I = 1 TO LEN (ES$)
|
|
|
|
440 Q$ = MID$ (ES$,I,1): FOR J = 1 TO LEN (CK$): IF Q$ = MID$ (CK$,J,1) THEN X = X + 1:X$(X) = Q$: GOTO 460
|
|
|
|
450 GOTO 480
|
|
|
|
460 IF X$(X) = " " THEN X = X + 1
|
|
|
|
470 GOTO 500
|
|
|
|
480 NEXT J
|
|
|
|
490 X$(X) = X$(X) + Q$
|
|
|
|
500 NEXT I
|
|
|
|
510 REM CONVERT TO PIG LATIN
|
|
|
|
520 FOR I = 1 TO X: IF LEN (X$(I)) < 3 THEN 610
|
|
|
|
530 FOR J = 1 TO LEN (X$(I)): FOR K = 1 TO LEN (CV$)
|
|
|
|
540 IF MID$ (X$(I),J,1) = MID$ (CV$,K,1) THEN 560
|
|
|
|
550 NEXT K,J
|
|
|
|
560 IF J = 1 THEN X$(I) = X$(I) + "A": GOTO 610
|
|
|
|
570 IF J - 1 = > LEN (X$(I)) THEN X$(I) = X$(I) + "A": GOTO 610
|
|
|
|
580 T$ = LEFT$ (X$(I),J - 1)
|
|
|
|
590 T$ = RIGHT$ (X$(I), LEN (X$(I)) - (J - 1)) + T$ + "A"
|
|
|
|
600 X$(I) = T$
|
|
|
|
610 NEXT I
|
|
|
|
620 REM PRINT OUT RESULT
|
|
|
|
630 HOME : VTAB 6: PRINT "YOUR SENTENCE:": PRINT : PRINT ES$
|
|
|
|
640 PRINT : INVERSE : PRINT "PIG LATIN TRANSLATION:": NORMAL : PRINT : FOR I = 1 TO X: PRINT X$(I);: NEXT
|
|
|
|
650 REM GET SET FOR MORE
|
|
|
|
660 PRINT : PRINT : PRINT
|
|
|
|
670 VTAB 20:A$ = "PRESS RETURN TO CONTINUE": GOSUB 120
|
|
|
|
680 K = PEEK ( - 16384): IF K < > 141 THEN 680
|
|
|
|
690 POKE - 16368,0: CLEAR : PRINT : PRINT : PRINT : GOTO 320
|
|
|