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.

DarkBASIC Discussion / Noob needs help lol

Author
Message
Damien
18
Years of Service
User Offline
Joined: 22nd Sep 2006
Location:
Posted: 21st Jan 2008 22:53
Basicly i wrote a prog that generates lines of 26 random letters to a text file (not hard i know but i only got db today)
I have a couple of questions about this if anyone could help please.
is there anyway i can clean this coding up?
How do i stop the text file putting it in lines of 26? ( i want 1 long line so i can word wrap it in notepad)
And how would i write a prog that takes the text files and deletes things like double spaces, and rubbish letters leaving only real words?
any help is appriciated
Thanks
Cal

Heres the code

and heres a samplke of what the text comes out like

Thanks again

There are two types of people in this world,
Those who like me and those who can go to hell
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Jan 2008 23:36
Oh dear!

It's only day one of your programming career so you are allowed to write very bad programs... for now. Our job is to coax you into doing it a little bit better...

I see you've been doing a bit of reading, but so you don't waste too much time, I seriously suggest that you read a few tutorials which cover all the basic stuff.

If you haven't seen them already, there are a load here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

As your topic is search facility unfriendly, you also need to read this:

http://forum.thegamecreators.com/?m=forum_view&t=116024&b=10

As for your program thus far, you are doing more typing than you need to. You also need a Close File for every Open File in your program.

Also, I'm pretty sure that your program isn't doing what you think it is.

1. It's in a closed loop and if left running long enough, the file output.txt will grow to an enormous size and everything will explode! You need to set a max number of characters to write.

2. When a string is written to a file, it will have a CR/LF added to the end automatically. This makes the next line start on a new line. Use Write Byte for this particular task.

Here's the same program slightly differently:



I think it does what you are aiming for...

PS: Only kidding about the exploding bit!

TDK_Man

Damien
18
Years of Service
User Offline
Joined: 22nd Sep 2006
Location:
Posted: 21st Jan 2008 23:52 Edited at: 22nd Jan 2008 01:07
Thanks for the quick reply basicly what im trying to do is test the monkey keyboard theory http://en.wikipedia.org/wiki/Infinite_monkey_theorem
so size is not an object lol (got a spare 200 gig layin about somewhere)
also tested your code (which i like very much lol)
so thanks again for the help
Cal

There are two types of people in this world,
Those who like me and those who can go to hell
Damien
18
Years of Service
User Offline
Joined: 22nd Sep 2006
Location:
Posted: 22nd Jan 2008 02:43
Sorry to double post but the forum is takeing ages to accept my last one.
if had a fiddle with your code so it does carry on forever this is what i have at the moment.

I have probably messed it up again but it seems to do the job i want it to
I have started to look at writing somthing that remove all the rubbish but i really have no idea how to do this.
I dont want to sound like im asking for someone to write this for me as i would really like to do this myself so i can learn from it. But could someone give me some idea of how to collect all the words between spaces as strings and compair them to a word list please?
My guess is that i would be using the readlong command but other than that i have really no idea.
I have looked through loads of tutorials but i cant seem to find anything that could help.
If you know any that may please could you link me.
Thanks
Callum

There are two types of people in this world,
Those who like me and those who can go to hell
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Jan 2008 03:33
Quote: "Sorry to double post but the forum is takeing ages to accept my last one."


All new members are on post approval for a while so we can weed out spammers and undesirables!

I (or another mod) have to approve all posts that you make during this period. So some delay is inevitable, depending on what mods are online when you post.

Quote: "I have probably messed it up again"


Yes - a bit, but it's all part of the learning process. I'm happy to help out, but only if you are happy drop the bad habits.

For example, these days my eyes are not as good as they used to be and I'm finding it more and more difficult to follow code which isn't indented correctly. To be honest, it's a lot to do with the font in the forum code boxes, but there's little we can do about that!

Note the 2 character indents of all loops and If..Then blocks in my code? Anyway, have a quick read of tutorial here.

Quote: "I have started to look at writing somthing that remove all the rubbish"


By 'rubbish' I assume you mean groups of characters which are not proper English words right?

Quote: "how to collect all the words between spaces as strings and compair them to a word list"


Create a string variable like NewWord$ and set it to NULL with:

NewWord$=""

Next, you'll need to open a text file and read each byte (number) in one at a time, converting it to a character with Chr$() and adding it to the end of NewWord$.

This is repeated until a space character is read in.

You then compare this string with the dictionary, discarding it if it's not a found word and adding it to a string array if it is.

You then set NewWord$ back to NULL continue reading more bytes in until you reach the end of the file.

The big problem is that you can't open a text file while it's in use. So, I suggest that you set a fixed number of bytes to write to the text file (say 64000) then close it, create a new one then continue.

You can then work on the created files not in use.

Using a variable counter, you can get DB to automatically name the text files File000001.txt, File000002.txt, File000003.txt and so on - each containing say 64K of text.

There's a tutorial on strings on the page linked to above and you'll find one on arrays which you'll find explained in very simple terms.

Have a go with the outlines I've given you here and shout if you get stuck.

TDK_Man

Damien
18
Years of Service
User Offline
Joined: 22nd Sep 2006
Location:
Posted: 22nd Jan 2008 03:45
Thank you very much for the help mate. Ill have a look tomorow when im not half asleep.
Thanks
Callum

There are two types of people in this world,
Those who like me and those who can go to hell
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 24th Jan 2008 02:44
sorry to get off-topic, but I thought the forum gives a notification that your post will not go through without an approval that could take up to 24 hours... and people still think that the post doesn't go through because of a bug in the forum...

Seriously, how do you make the little blue text come up below your message?
Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 24th Jan 2008 08:55
if you want to write a program that would be both interesting, challenging and that deals with strings, then I suggest this : some years ago in the world of dos there was a program that acted like a phychiatrist. you would start the program , and a command prompt would come up and it would say "hello , I'm dr. so and so , how are you feeling today" the user would ofcourse respond by typing something in like "great" or "rotton" or whatever he wanted to.
then the program would ask you why you were feeling that way ,
ect,....
it was basically a program that done nothing more than parse the text that the user would type in , never the less ,the text parcer in the program was extremely well written to the point that it seemed to flawlessly parse the input text. although DB is made for doing games you could try and do something like this for fun if your up to the challenge

demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 24th Jan 2008 20:57
@Bluestar4: That would take ages! I could never be bothered with anything that included writing big old lists of words. I wanted to do hangman at one point but I gave up when I realised that I'm not going to waste my time copying down an entire dictionary, and while there are less words for something like this, it'd still have to account for all the misspellings (like your "rotton") and different varieties of saying one thing.

"A West Texas girl, just like me"
-Bush
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 25th Jan 2008 06:06 Edited at: 25th Jan 2008 06:06
The program the Bluestar mentioned was once a challenge for the DB Classic Programming Challenge Thread. No one entered the challenge, though, and TDK thought it would be easy...

Seriously, how do you make the little blue text come up below your message?
Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 25th Jan 2008 07:51
even if your well versed in the string functions , making a decent text parcer can be either easy or difficult - depending on the game and what the programmer has in mind ofcourse

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Jan 2008 19:37 Edited at: 25th Jan 2008 19:38
Quote: "TDK thought it would be easy"


Actually it is - I wrote a program called PAM a long, long time ago which you could have a conversation with.

The problem is not that it's hard to write, but that it gets boring very quickly and involves a lot of work, That's why I think there were no entries in the challenge.

I'll attach PAM to another thread in case anyone is interested in it.

TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jan 2008 19:39
@TDK
I'm interested, I couldn't get my head round it for the challenge and would like to see what you did.

Bluestar4
19
Years of Service
User Offline
Joined: 19th Dec 2005
Location: USA
Posted: 26th Jan 2008 10:06
Quote: "The problem is not that it's hard to write, but that it gets boring very quickly and involves a lot of work"

thats what I was meaning to say... I like the way you put it better though.

Login to post a reply

Server time is: 2025-06-04 02:13:45
Your offset time is: 2025-06-04 02:13:45