Author |
Message |
SkaarjSlayer
|
Posted: Thu Sep 25, 2008 4:27 pm Post subject: Phonetic Alphabet |
|
|
Here is a better and slightly more complicated program that took me 2 hours to create. I normally would have posted the code but it's 5917 lines of code so I won't spam it on here. In the .zip is included the .exe file as well as the original .t file so don't worry, you can still view the code before running the program.
For those who don't know what the phonetic alphabet is, it's more commonly used over radio especially with the military. Each letter of the alphabet has a corresponding word for it.
For example:
A = Alpha
B = Bravo
C = Charlie
D = Delta
E = Echo
F = Foxtrot
and so on.
Now, this program will let you input any word with a maximum of up to 10-letter words and translate it into the phonetic alphabet (any words over 10 letters will not work) The 2 annoying things about this program is that A) you'll have to FIRST input how many letters are in the word and THEN input the actual word and B) the first letter must be capitalized.
To give an example of how the program will work, say you wanted to translate the word CAKE.
Well, CAKE is 4 letters so you tell the program it has 4 letters and then you input "Cake". The program will then translate it as:
Charlie Alpha Kilo Echo
Simple, no?
Now, this program is overly long and complicated and I know there's simpler code to make this program work, but this is how it is written so try to enjoy and tell me what you think.
(Warning: Almost no indentation and extremely little internal documentation.)
Description: |
|
Download |
Filename: |
phonetc_alphabet.zip |
Filesize: |
415.3 KB |
Downloaded: |
263 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
gitoxa
|
Posted: Thu Sep 25, 2008 4:34 pm Post subject: RE:Phonetic Alphabet |
|
|
Turing has a length function that you can use to get the length of the word
code: | Word := "Hello"
length(Word) = 5 |
And you should be able to use string manipulation to change any letters to upper/lower case, or not accept them if they're not right (input error checking)
|
|
|
|
|
|
Insectoid
|
Posted: Thu Sep 25, 2008 4:35 pm Post subject: RE:Phonetic Alphabet |
|
|
to get around entering the number of characters, use the length () command. It returns the amount of characters in the string. Why did this take over 5000 lines? It fairly simple, using a for loop and some big if statements.
EDIT: darn you Gitoxa, you beat me by 1 minute!
|
|
|
|
|
|
gitoxa
|
Posted: Thu Sep 25, 2008 4:36 pm Post subject: RE:Phonetic Alphabet |
|
|
Yea, a for loop would have probably benefited you big time... wow.
@insectoid: You're too slow
|
|
|
|
|
|
Insectoid
|
Posted: Thu Sep 25, 2008 4:38 pm Post subject: RE:Phonetic Alphabet |
|
|
With a for loop, you could also translate any size of word, instead of having a 10 word limit
|
|
|
|
|
|
SkaarjSlayer
|
Posted: Thu Sep 25, 2008 4:38 pm Post subject: Re: Phonetic Alphabet |
|
|
well I did gitoxa's original suggestion but it had a logic error and didn't do what I wanted it to so the program ended up taking over 5000 lines.
IMO: As long as it works
|
|
|
|
|
|
Insectoid
|
Posted: Thu Sep 25, 2008 4:40 pm Post subject: RE:Phonetic Alphabet |
|
|
IMO: As long as it works AND doesn't fill my hard drive with unnecessary inefficient code.
|
|
|
|
|
|
gitoxa
|
Posted: Thu Sep 25, 2008 4:41 pm Post subject: RE:Phonetic Alphabet |
|
|
That's a bad opinion to have, to be honest.
It took you over two hours to write a program that really should have taken maybe 10-15 mins.
The hardest part is getting all the codewords setup into one if/case structure.
What was this 'logic error' ?
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Thu Sep 25, 2008 4:43 pm Post subject: RE:Phonetic Alphabet |
|
|
who's opinion? Mine or his?
|
|
|
|
|
|
SkaarjSlayer
|
Posted: Thu Sep 25, 2008 4:44 pm Post subject: Re: Phonetic Alphabet |
|
|
Not quite bad, if it were a program that took much more than 1 MB then there'd be cause for concern.. or if you have a very crappy computer.
To be honest, I don't quite remember, it just wouldn't work with every letter in the code for some reason and the only way I found it to work was the way I did it.
I'd like to point out that I'm not the greatest coder and so what might've taken *you* 10-15 minutes, well, not everyone is the same.
|
|
|
|
|
|
Insectoid
|
Posted: Thu Sep 25, 2008 4:47 pm Post subject: RE:Phonetic Alphabet |
|
|
Meh, you'll get faster. By the end of the semester you'll be typing out multiple-hundred-line programs where no line is unnecessary in a mere hour.
|
|
|
|
|
|
gitoxa
|
Posted: Thu Sep 25, 2008 4:47 pm Post subject: RE:Phonetic Alphabet |
|
|
insectoid, his.
And it took me 2 minutes, so I think 10-15 is a good estimation.
|
|
|
|
|
|
The_Bean
|
Posted: Thu Sep 25, 2008 4:47 pm Post subject: Re: Phonetic Alphabet |
|
|
An easy way to do it would be to set up the codewords in an array then call them out corresponding to the ascii value of the that letter.
and why are you importing the entire GUI class when you only use it for GUI.SetBackgroundColour (black)
|
|
|
|
|
|
SkaarjSlayer
|
Posted: Thu Sep 25, 2008 4:52 pm Post subject: Re: Phonetic Alphabet |
|
|
I first started using Turing since about February of this year. I'm sure you'll say "I learned it in 'this' much time" and "It's not that hard." but IMO that's pretty ignorant. There's lots of stuff I absolutely do not know about Turing and I'm learning as I go. I can accept criticism but don't assume I know everything you people know.
|
|
|
|
|
|
gitoxa
|
Posted: Thu Sep 25, 2008 4:55 pm Post subject: RE:Phonetic Alphabet |
|
|
I'm not assuming you should know everything, but when a simple program is taking 5000+ lines to make, you should be thinking to yourself "is this right?"
|
|
|
|
|
|
|