Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 6th May 2006 14:28
i am making a messaging system, a bit like offline email, so all other users of my pc can leave messages for each other. how can i make it so that when a user is typing a message, the message will save and can be printed off (outside the program cos db cannot connect to a printer, i know that!). if i use the input command, the user will have to press enter at the end of each line and that can become irritating...
how can i get round this?

I am a Christian and I know that God loves me. That is what makes my life so great!
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 6th May 2006 15:14
Quote: "how can i make it so that when a user is typing a message, the message will save"


Open to write?

Quote: "if i use the input command, the user will have to press enter at the end of each line and that can become irritating"


As in, you want one long string? Sorry, can't be done with DB Classic, the string limit is 256 characters, which is slightly too many to fill a 1024 width screen (assuming the character is used, 256 full stops will easily fit 800 width). So basically, you're probably going to need a whole collection of strings anyway
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th May 2006 16:01
It can be done if you use scancodes, and cut strings up when the person presses the spacebar, then store the strings in an array.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th May 2006 03:50
The principle you need to use is fairly straight forward, but in DBC, you'll have to do a tricky bit of work with string manipulation...

The whole of the text window you use to type into is split into lines - each one, the text being held in a string array.

Wherever the cursor is vertically on the screen tells you which element of the array you are currently working on and where the cursor is horizontally tells you at what point in that array element.

So for example, if you use:

Dim Lines$(500)

this will allow you to have up to 500 lines in your message.

When you are on the first line of the window, you are altering the text in Lines$(1) and when on the second line you modify Lines$(2) and so on.

The trick is to know the width of the window and how many characters will fit on it. As you type, you always know how many characters are before and after the cursor so you can a) drop to the start of the next line (the next array element) and b) push text after the cursor to the next line.

You've also got to handle Backspace, Delete and the cursor keys yourself, so it won't be a five minute job. Ideal though if you are fairly new to programming and want a good project to learn string handling with!

As SimSmall says, you use Open To Write to save all the array lines of text to a file on disk.

It's not too difficult to do, so give it a try and shout if you have any problems.

TDK_Man

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th May 2006 20:20 Edited at: 7th May 2006 20:21
I've just knocked together a small example of how you can write a basic text editor using string arrays. It's not complete, but it functions enough to demonstrate how the method works.

You could easily add a wordwrap function.

It's not optimized at all and I've written the code a bit 'Janet and John' so it's easier to follow what's happening.

Note: You may have to alter the Sleep values for the machine it's being run on. Ideally, these would all be replaced by a better timing system, but that's for you to do yourself...

Currently supports cursor keys, backspace, home, end and entering text.

Ctrl-S to save a file, Ctrl-L to load a file, Ctrl-C to clear the current text and Ctrl-X to exit.

It supports up to 100 lines of text with the array, but I've not done any code for scrolling the text window so you are limited to the 30 lines in the window at the moment. I have included the LineOffset variable though, so adding a scrolling window would be a doddle.



TDK_Man

Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 14th May 2006 07:52
search the online help for help on the command entry$() and load the example. this also might solve some problems possibly

Bluestar4~
http://www.geocities.com/bluestar4games
Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 14th May 2006 21:10
this can be done much more easily in visual basic, if i understand you right, this can be done with a few lines in vb...

juice is made from oranges....

http://whatishl.ytmnd.com/ so friggin funny!
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 15th May 2006 00:45
http://msdn.microsoft.com/vstudio/express/vb/download/default.aspx

Still Free! I hope. Or at least a trial.

Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 15th May 2006 01:56
yes, but that is the .net edition, it sux, vb6 is the best of them all. you might have to validate windows to download the .net edition....

juice is made from oranges....

http://whatishl.ytmnd.com/ so friggin funny!

Login to post a reply

Server time is: 2025-05-25 02:23:26
Your offset time is: 2025-05-25 02:23:26