05-23-2003, 07:01 PM
It's a silly but popular english language game. Words beginning with vowels have "WAY" attached to it ('igloo' becomes 'igloo-way'). If a word has constants at the beginning, they're move to the end with "AY" at the end. ('string' becomes ing-stray). Words beginning with QU are done like this. ('quest' becomes 'est-quay')
It's worthless talk, but became very popular in the US among both kids and adults.
Here's my last try. This one parses, but periods, question marks, etc, are not handled.
- Dav
It's worthless talk, but became very popular in the US among both kids and adults.
Here's my last try. This one parses, but periods, question marks, etc, are not handled.
Code:
DECLARE FUNCTION Piggy$ (In$)
PRINT Piggy$("what is pig latin that is the question")
PRINT Piggy$("hello my name is dave and i'm a pig")
PRINT
INPUT "What do you say, pig"; A$
PRINT Piggy$(A$)
FUNCTION Piggy$ (In$)
Out$ = ""
DO UNTIL w >= LEN(In$)
'=== Parse a word...
temp$ = ""
WHILE MID$(In$, w + 1, 1) <> " " AND MID$(In$, w + 1, 1) <> ""
temp$ = temp$ + MID$(In$, w + 1, 1)
w = w + 1
WEND
'====== piggy it ====
FOR x% = 1 TO LEN(temp$)
SELECT CASE UCASE$(MID$(temp$, x%, 1))
CASE IS = "A", "E", "I", "O", "U", "Y": EXIT FOR
END SELECT
NEXT
'=== If vowel first...
IF x% = 1 THEN
Out$ = Out$ + temp$ + "-way "
'=== If starts with "qu"...
ELSEIF UCASE$(LEFT$(temp$, 2)) = "QU" THEN
Out$ = Out$ + RIGHT$(temp$, LEN(temp$) - 2)
Out$ = Out$ + "-" + LEFT$(temp$, 2) + "ay "
'=== else...
ELSE
L$ = LEFT$(temp$, x% - 1)
R$ = MID$(temp$, x%, LEN(temp$))
Out$ = Out$ + R$ + "-" + L$ + "ay "
END IF
'====================
w = w + 1
LOOP
Piggy$ = Out$
END FUNCTION
- Dav
Visit Dav's Qbasic Site