qbasic newbie - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

qbasic newbie

denkatdenkat Posts: 3Member
hi im taking a intro to programming class, which keeps getting harder for me, and could use some help on this qbasic project.

the instructor has givin us a skeleton for this assignment and im trying to fill in all the working sections but im having some difficulty, the project is to make a simple english to french and german translator, so you enter the sentence in english and you get both a german and french translation.

thanks for any help anyone could give

here is what i have so far:

DECLARE FUNCTION GETUSERSSENTENCE$ ()
DECLARE FUNCTION PARSEUSERSSENTENCE! (SENTENCE$, WORDARRAY$())
DECLARE FUNCTION COUNTWORDS! (SENTENCE$)
DECLARE SUB INDEXUSERSENTENCE (ENGLISHWORDS$(), WORDCOUNT!, USERSWORDS$(), INDEXTOWORDS!(), WORDSINSENTENCE!)
DECLARE SUB PRINTFRENCHTRANSLATION (INDEXWORDS!(), FRENCHWORDS$(), WORDSINSENTENCE!)
DECLARE SUB PRINTGERMANTRANSLATION (INDEXWORDS!(), GERMANWORDS$(), WORDSINSENTENCE!)
DECLARE SUB FILLARRAYS (ENGLISHWORDS$(), FRENCHWORDS$(), GERMANWORDS$(), WORDCOUNT!)
DECLARE SUB SORTSYNCARRAYS (ENGLISHWORDS$(), FRENCHWORDS$(), GERMANWORDS$(), WORDCOUNT!)

REM !!!!!!!!!!!!!!!!!! THIS PROJECT IS NOT FINISHED YET !!!!!!!!!!!!!!!!!!!!!

REM DENIS LACOURSE
REM 12/2/01
REM INTRO TO PROG 211
REM PROJECT #8 PAGE 296/#3
REM PROGRAM NAME TRANS.BAS
REM PROGRAM FOR SIMPLE ENGLISH/FRENCH/GERMAN LANGUAGE TRANSLATION,
REM 16 WORDS PER LANGUAGE, TRANSLATION OF ENGLISH ENTRY INTO FRENCH AND GERMAN

CLS
INDEX = 0
DO
INDEX = INDEX + 1
READ WORD$
LOOP UNTIL WORD$ = "EOD"
RESTORE
WORDCOUNT = (INDEX - 1) / 3

DIM ENGLISHWORDS$(1 TO WORDCOUNT)
DIM FRENCHWORDS$(1 TO WORDCOUNT)
DIM GERMANWORDS$(1 TO WORDCOUNT)

'$DYNAMIC

DIM INDEXTOWORDS(0)
DIM USERSWORDS$(0)

REM FILL ARRAYS WITH LANGUAGE DATA
CALL FILLARRAYS(ENGLISHWORDS$(), FRENCHWORDS$(), GERMANWORDS$(), WORDCOUNT)

REM SORT ARRAYS
CALL SORTSYNCARRAYS(ENGLISHWORDS$(), FRENCHWORDS$(), GERMANWORDS$(), WORDCOUNT)



REM GET USERS SENTENCE
SENTENCE$ = GETUSERSSENTENCE
'CALL INDEXUSERSENTENCE(ENGLISHWORDS$(), WORDCOUNT, USERSWORDS$(), INDEXTOWORDS(), WORDSINSENTENCE)

REM PARSE USERS SENTENCE
WORDSINSENTENCE = PARSEUSERSSENTENCE(SENTENCE$, USERWORDS$())



'CALL PRINTFRENCHTRANSLATION(INDEXWORDS(), FRENCHWORDS$(), WORDSINSENTENCE)

'CALL PRINTGERMANTRANSLATION(INDEXWORDS(), GERMANWORDS$(), WORDSINSENTENCE)















REM $STATIC

REM DATA FOR WORDARRAYS
REM ENGLISH, FRENCH, GERMAN

DATA YES, OUI, JA
DATA TABLE, TABLE, TISCH
DATA IS, EST, IST
DATA YELLOW, JUANE, 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 AUTO, AUTO, AUTO
DATA OFTEN, SOUVENT, OFT
DATA EOD


END

FUNCTION COUNTWORDS (SENTENCE$)
REM COUNT WORDS IN USERSENTENCE

FOR INDEX = 1 TO LEN(SENTENCE$)
IF MID$(SENTENCE$, INDEX, 1) = "" THEN
WORDCOUNT = WORDCOUNT + 1
END IF
NEXT INDEX


END FUNCTION

SUB FILLARRAYS (ENGLISHWORDS$(), FRENCHWORDS$(), GERMANWORDS$(), WORDCOUNT)
REM FILL ARRAYS WITH LANGUAGE DATA

INDEX = WORDCOUNT
FOR INDEX = 1 TO WORDCOUNT
READ ENGLISHWORDS$(INDEX), FRENCHWORDS$(INDEX), GERMANWORDS$(INDEX)
NEXT INDEX
END SUB

SUB FILLARRAYS2 (ARRAY1$(), ARRAY2$(), ARRAY3$(), WORDCOUNT)

END SUB

FUNCTION GETUSERSSENTENCE$
INPUT "ENTER AN ENGLISH SENTENCE:"; SENTENCE$
SENTENCE$ = GETUSERSSENTENCE$
END FUNCTION

SUB INDEXUSERSSENTENCE (ENGLISHWORDS$(), WORDCOUNT, USERSWORDS$(), INDEXTOWORDS(), WORDSINSENTENCE)
WORDCOUNT = COUNTWORDS(SENTENCE$)
REDIM ENGLISWORDS$(1 TO WORDCOUNT)
STARTPOSITION = 1
FOR INDEX = 1 TO WORDCOUNT
ENDPOSITION = INSTR(STARTPOSITION, SENTENCE$, "")
IF ENDPOSITION > 0 THEN
WORD$ = MID$(SENTENCE$, STARTPOSITION, ENDPOSITION - STARTPOSITION)
STARTPOSITION = ENDPOSITION + 1
ELSE
WORD$ = RIGHT$(SENTENCE$, LEN(SENTENCE$) - STARTPOSITION + 1)
END IF
ENGLISHWORDS$(INDEX) = WORD$
NEXT INDEX
INDEX = ENGLISHWORDS$

END SUB

FUNCTION PARSEUSERSSENTENCE (SENTENCE$, WORDARRAY$())
REM PARSE SENTENCE AND PLACE THEM INTO ARRAY AS INDIVIDUAL WORDS
WORDCOUNT = COUNTWORDS(SENTENCE$)
REDIM WORDARRAY$(1 TO WORDCOUNT)
STARTPOSITION = 1
FOR INDEX = 1 TO WORDCOUNT
ENDPOSITION = INSTR(STARTPOSITION, SENTENCE$, "")
IF ENDPOSITION > 0 THEN
WORD$ = MID$(SENTENCE$, STARTPOSITION, ENDPOSITION - STARTPOSITION)
STARTPOSITION = ENDPOSITION + 1
ELSE
WORD$ = RIGHT$(SENTENCE$, LEN(SENTENCE$) - STARTPOSITION + 1)
END IF
WORDARRAY$(INDEX) = WORD$
NEXT INDEX
PARSEUSERSSENTENCE = WORDCOUNT
END FUNCTION

SUB PRINTFRENCHTRANSLATION (INDEXWORDS(), FRENCHWORDS$(), WORDSINSENTENCE)

END SUB

SUB PRINTGERMANTRANSLATION (INDEXWORDS(), GERMANWORDS$(), WORDSINSENTENCE)

END SUB

SUB SORTSYNCARRAYS (ENGLISHWORDS$(), FRENCHWORDS$(), GERMANWORDS$(), WORDCOUNT)
SWAP ENGLISHWORD$(WORDCOUNT), ENGLISHWORD$(WORDCOUNT + 1)
SWAP FRENCHWORD$(WORDCOUNT), FRENCHWORD$(WORDCOUNT + 1)
SWAP GERMANWORD$(WORDCOUNT), GERMANWORD$(WORDCOUNT + 1)
END SUB


Comments

  • eikedehlingeikedehling Posts: 123Member
    Giving some more specific info about the help you need might be not be bad, otherwise its hard to help; hardly anyone will finish your project for you, even if he could ...

    but one weird error i've seen :
    : REM DATA FOR WORDARRAYS
    : REM ENGLISH, FRENCH, GERMAN
    :
    : DATA YES, OUI, JA
    : DATA TABLE, TABLE, TISCH
    : DATA IS, EST, IST
    : DATA YELLOW, JUANE, 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 AUTO, AUTO, AUTO
    : DATA OFTEN, SOUVENT, OFT
    : DATA EOD

    what about putting some double-quotes around the strings ?!?
    this way you should get quite some weird errors ....

    now just try to fill out the empty parts of your functions. often it is usefull to think up as much small parts as possible, them programm them, and put them together to bigger working parts; if you put them all in procedures, that is what they call 'procedural programming' it is often usefull, because you only have to solve small problems at the time, which is easier than doing all at once, which probably will look a little to much
    to do all at the same time, and lett you lose most of the 'hey lets do that now' - hope ....

    SUSE LINUX 7.3 PRO - The world starts behind windows

  • deldel Posts: 51Member
    Your dictionaries are a bit limited. If you know anything about files, why not use an external data file which contains the dictionaries? You can download text files that contain listings of translations at http://www.june29.com/IDP/IDPfiles.html . Just an idea...
  • denkatdenkat Posts: 3Member
    : Your dictionaries are a bit limited. If you know anything about files, why not use an external data file which contains the dictionaries? You can download text files that contain listings of translations at http://www.june29.com/IDP/IDPfiles.html . Just an idea...
    :

    thanks for your help i will check it out
  • denkatdenkat Posts: 3Member
    : Giving some more specific info about the help you need might be not be bad, otherwise its hard to help; hardly anyone will finish your project for you, even if he could ...
    :
    : but one weird error i've seen :
    : : REM DATA FOR WORDARRAYS
    : : REM ENGLISH, FRENCH, GERMAN
    : :
    : : DATA YES, OUI, JA
    : : DATA TABLE, TABLE, TISCH
    : : DATA IS, EST, IST
    : : DATA YELLOW, JUANE, 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 AUTO, AUTO, AUTO
    : : DATA OFTEN, SOUVENT, OFT
    : : DATA EOD
    :
    : what about putting some double-quotes around the strings ?!?
    : this way you should get quite some weird errors ....
    :
    : now just try to fill out the empty parts of your functions. often it is usefull to think up as much small parts as possible, them programm them, and put them together to bigger working parts; if you put them all in procedures, that is what they call 'procedural programming' it is often usefull, because you only have to solve small problems at the time, which is easier than doing all at once, which probably will look a little to much
    : to do all at the same time, and lett you lose most of the 'hey lets do that now' - hope ....
    :
    : SUSE LINUX 7.3 PRO - The world starts behind windows
    :
    :
    thanks for the advice
Sign In or Register to comment.