Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help With Working With 'Enter'
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Slaivis




PostPosted: Sat Jun 24, 2006 10:21 pm   Post subject: Help With Working With 'Enter'

Alright, you may have read the title and thought 'Oh, easy... Just use ""'.

The thing is... My problem is a bit.. Weird. I don't know how to phrase it.

I'll start with what my program does. It's a program to switch the characters in a message with other, seemingly random characters.

My program can also unencode a message.

Here's what my alphabet looks like:

Quote:
const alpha : string := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+`-={}[]:;'<>?,./1234567890 "


Now, the problem comes in with the "enter" key. I would like my program to be able to read and output enter as it is, without encoding it.

However, as it is right now, my program will read enter, and output "I", no matter the location of the enter within the message.

Is there some way to make the "Enter" key a part of the alphabet?

Thanks for your help, it will be greatly appreciated.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sat Jun 24, 2006 10:34 pm   Post subject: (No subject)

Your question is a bit confusing, but I believe what you are looking for is the escaped newline character. Try adding "\n" to your alphabet, and treat the \ with the n as one letter, that letter being the enter character as you referred to it.
Slaivis




PostPosted: Sat Jun 24, 2006 10:37 pm   Post subject: (No subject)

I've read about special characters using a combination of \ and some other letter.

And you know what, I think that might be what I was looking for.


Thanks a ton!
Clayton




PostPosted: Thu Jun 29, 2006 7:19 pm   Post subject: (No subject)

why not just use the enter key's ordinal value (10) in your alphabet string? just add it in on the end and treat "10" as one item Very Happy
Slaivis




PostPosted: Thu Jun 29, 2006 10:38 pm   Post subject: (No subject)

SuperFreak82 wrote:
why not just use the enter key's ordinal value (10) in your alphabet string? just add it in on the end and treat "10" as one item Very Happy


Actually, the previous idea solved the problem very well.

But assuming that I were to use your idea...

Would I simply add ORD(10) to the end of the string via concantenation?
[Gandalf]




PostPosted: Thu Jun 29, 2006 11:18 pm   Post subject: (No subject)

Yep. But not all langauges include an ord function by default, and it's a good introduction to escape characters anyway.
Slaivis




PostPosted: Thu Jun 29, 2006 11:33 pm   Post subject: (No subject)

[Gandalf] wrote:
Yep. But not all langauges include an ord function by default, and it's a good introduction to escape characters anyway.


Heh, cool, thanks.

Now if I find some time, I can go improve the program then optimize it.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: