Here's the code i've done so far:
PROGRAM MORSE_CODE_TRANSLATOR;
USES CRT;
VAR Sentence : STRING[25]; {Maximum of 25 characters in sentence}
MorseOut, EnglishIn, EnglishOut : STRING;
Count : INTEGER; KEY : CHAR;
PROCEDURE AnyKey;Forward;
{~~~~~~~~~~~~~~~~~~~~~~EXTRA PROCEDURES~~~~~~~~~~~~~~~~~~~~~~~~~}
PROCEDURE AnyKey; {Makes the program move on when any alphanumerical key is pressed}
VAR AnyKeyIN : CHAR;
BEGIN {AnyKey}
WRITE ('Press ANY KEY to continue ');
AnyKeyIN := readkey;
WHILE (AnyKeyIN = #0) DO
BEGIN {WHILE}
AnyKeyIN := readkey
END; {WHILE}
END; {AnyKey}
{~~~~~~~~~~~~~~~~~~~~~~TRANSLATE MORSE~~~~~~~~~~~~~~~~~~~~~~~~~}
PROCEDURE TranslateMorse; {Translates the Morse Code into English}
BEGIN {TranslateMorse}
IF KEYPRESSED THEN BEGIN
IF EnglishIn := 'a' THEN MorseOut := '.-';
END;
END; {TranslateMorse}
PROCEDURE EnglishSentence; {Asks for a English sentence to translate to Morse}
BEGIN {EnglishSentence}
CLRSCR;
GOTOXY(40-(LENGTH('---------------------------------------') DIV 2), 2);
WRITELN ('MORSE CODE TRANSLATOR: ENGLISH SENTENCE');
GOTOXY(40-(LENGTH('---------------------------------------') DIV 2), 3);
WRITELN ('=======================================');
GOTOXY(40-(LENGTH('-------------------------------------') DIV 2), 5);
WRITE ('Enter a short sentence (25chrs Max): ');
READLN(Sentence);
GOTOXY(30,23);
AnyKey;
END; {EnglishSentence}
PROCEDURE SentenceOutput;
BEGIN {SentenceOutput}
CLRSCR;
GOTOXY(40-(LENGTH('---------------------------------------') DIV 2), 2);
WRITELN ('MORSE CODE TRANSLATOR: ENGLISH TO MORSE');
GOTOXY(40-(LENGTH('---------------------------------------') DIV 2), 3);
WRITELN ('=======================================');
TranslateMorse;
GOTOXY(40-(LENGTH('-------------------------') DIV 2), 6);
WRITE(MorseOut);
GOTOXY(30,23);
AnyKey;
END; {SentenceOutput}
BEGIN {MainProgram}
EnglishSentence;
SentenceOutput;
END.
Yep. I know. heaps of errors everywhere! I am trying very hard on this one, i've only started programming this year, so i'm not a pro programmer. And I will GREATLY appriciate any answers (prefferably in pascal code) to help get this working.
The funny part is my teacher and classmates reckon this one's easy, I've tried using records, arrays, keypressed, and case / if statements so far, but I've had no success at all, aw.
thanks anyone for any help on this crazy program!