What function or statement to use in Qbasic to breakdown a string value (sentence) word by word?

Hi. I’ve been trying for days to write a program for homework titled “Rudimentary Translator” for my CS class.

Purpose: A user enters a sentence in English, and the program translates it into French and German.

I have already done the parallel arrays on each language using dim, read/data, and for/next loops.

[expected sample run]

Enter an english sentence: MY PENCIL IS ON THE TABLE.

French translation: MON CRAYON EST SUR LA TABLE.

German translation: MEIN BLEISTIFT IST AUF DEM TISCH.

Here is the unfinished code I’ve made. Forgive me if it’s lousy.

CLS

‘Program to sort English, French, German and to translate a given sentence

‘to two of the oter language.

DIM ENGLISH$(), FRENCH$(), GERMAN$()

FOR G = TO

READ ENGLISH$(G), FRENCH$(G), GERMAN$(G)

NEXT G

FOR engsort = TO ( – )

FOR e = TO ( – )

IF ENGLISH$(e) > ENGLISH$(e + ) THEN

SWAP ENGLISH$(e), ENGLISH$(e + )

SWAP FRENCH$(e), FRENCH$(e + )

SWAP GERMAN$(e), GERMAN$(e + )

END IF

NEXT e

NEXT engsort

DO

INPUT “Enter an English phrase: “, userEng$

LET userEng$ = UCASE$(userEng$)

FOR t = TO

IF userEng$ = ENGLISH$(t) THEN

PRINT FRENCH$(t), GERMAN$(t)

END IF

NEXT t

LOOP UNTIL userEng$ = “”

DATA “YES”,”OUI”,”JA”

DATA “TABLE”,”TABLE”,”TISCH”

DATA “THE”,”LA”,”DEM”

DATA “IS”,”EST”,”IST”

DATA “YELLOW”,”JAUNE”,”GELB”

DATA “FRIEND”,”AMI”,”FREUND”

DATA “SICK”,”MALADE”,”KRANK”

DATA “MY”,”MON”,”MEIN”

DATA “LARGE”,”GROS”,”GROSS”

DATA “NO”,”NON”,”NEIN”

DATA “HAT”,”CHAPEAU”,”HUT”

DATA “PENCIL”,”CRAYON”,”BLEISTIFT”

DATA “RED”,”ROUGE”,”ROT”

DATA “ON”,”SUR”,”AUF”

DATA “AUTO”,”AUTO”,”AUTO”

DATA “OFTEM”,”SOUVENT”,”OFT”

END

I appreciate the help you guys can give. Thank you.

Answer
? Favorite Answer

  • PRINT RIGHT$(A$,)

  • Leave a Comment