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 / The DB Classic Programming Challenge Thread

Author
Message
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 7th Apr 2007 03:05
I had a question for latch. Would i be able to use gosub to go to a new level if the player has won?

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Apr 2007 04:34
@Zombie

The question is a bit vague. The answer could be yes, no, or maybe. To cover the bases, I start with a general explanation. A GOSUB is used to jump to a subrountine (GO to SUBroutine). A subroutine is a block of code that is referenced by a label (i.e. a character and/or number sequence terminated with a : ) and ending with RETURN. A GOSUB leaves a footprint behind so the program can RETURN to the next line after the GOSUB was called when the block of referenced code has finished executing. GOSUBS can be nested inside subroutines and functions as well. When GOSUBbing a label, you don't need the : anymore. The : is only used to define the label and the beginning of the block of code

Here is an example:



Now, in answer to your question: if you have a subroutine set up to change the level, then you could use a gosub to that routine.

psuedo code:



Enjoy your day.
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 7th Apr 2007 05:14 Edited at: 7th Apr 2007 07:35
ah thanks, i was wondering because functions i'm writing don't want to work for me. I was curious because i'm expanding on the pong project, seeing as i'm enjoying it and you've already given me a score code, it would be rude to not keep working on it. I'm slowly getting my *dream* project working, but i'm also sticking to basics and learning. So i hope i wasn't bothering you by asking.

Oh yea, one more thing, since you're one of the user's that has helped me the most, have you seen any improvements? I just want to know if you guys have seen progress, it feels like i have.

for example, not sure what i'm doing wrong. That clears up some things, i'm going to go experiment, thanks again. By the way, the subroutines example is just what i needed, its working out great. thanks again.



Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Apr 2007 02:34
@Zombie

As long as this thread stays on topic ask questions by all means.

As far as your improvement, it's hard to say - has it been like two weeks or something since I responded to your first request for help? That's not a whole lot of time. It seems you are working very hard and trying to take in as much information as you can. That's a very good thing! You are grateful for assistance and polite so that's a really good thing - everybody appreciates courtesy.

One thing I think would help you is if you reworked the code in the examples I've shown you. For instance, the score keeping routine I showed you is pretty weak in the way I implemented it. I also just commented out some code and copied it under a label I made called main: Not very neat or clean and a bit redundant. You didn't clean it up but just left it exactly as I posted it which suggests that perhaps you didn't understand what I did:



It's ok not to understand, but it won't help you in the long run if you can't disect a routine and piece it together so it's "yours" so to speak. Example code is very useful, but if you can understand what it is doing, then you are on your way to being able to create something similar yourself. A concept you're gonna want to get under your belt is using FUNCTIONS and SUBROUTINES to divide your program into chunks or modules. I highly recommend putting your dream project on the back burner for now and working through some of these challenges.

Enjoy your day.
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 8th Apr 2007 03:15
latch

Thank you for your kind words, i am working hard, i'm trying to understand everything i can, i have a number of examples to keep improving upon and writing my own programs. As far as not changing your code, i do apologize for that, i understood most of it, but what confused me late last night *usually when i code a lot* is i had written a new level but i couldn't get it to go there if the player won.

This in a way aggravated me because i understood your example, i just have not been able to apply it and this is one aspect of my life that i'm very determined to succeed in.

And yes, i try to be as respectful as i can be to all of the users, i respect each and every one of you for what you've accomplished, even if its two lines, its great because you all made it unique. That is what i want to achieve, i will always welcome example code to show me a different method, but i know i will finally gain the resepect i want so badly when i can create an application that stuns one of the mods or more experienced users.

Haha, as for my "dream projects", i realized after reading about programming for the first time when i was twelve that you cannot construct such large scale games within 3 months. I'm excited but i know developing technique and skills is vastly more important to my growth as a programmer.

I just wanted to thank you, and quisco, and ruccus, and Batvink,VanB,Turoid,Xenocyth,The Crazy, and so many others that have aided me for being nice and generous with their time and their code.

Wow has it only been two weeks since i asked for help? It feels like its been so much longer, but its not a bad thing. I've really enjoyed it here and i hope to become one of tgc top preformers in time.

I plan to rework the pong title now with my own functions *finally learned how to write one :p* and i'm currently stuck on a collision program based off of the katamari damacy series, i'm only one issue away from having a complete engine. Oh dear, i hope i haven't written too much, but you guys next to my already big family, already feel like my family. And that's why i'm on the forums so much, because i feel like i belong. And well, i'm rambling so, thank you again and best of luck to you and your coding.

Hey, i'm looking forward to the next competition, no help this time :p, i'm going to do this one all on my own!

laters

zombie

Binary Coder
17
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 9th Apr 2007 11:42
Errr....
Is it time to set another challenge?
Comrade Robski
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 9th Apr 2007 16:15 Edited at: 9th Apr 2007 16:17
OK everyone - many apologies for the delay - I've been away from my computer over the Easter holiday.

Thanks to the three entrants to the latest DBC challenge. All three entries were impressive. Here are my comments:



After much thought I've decided the winner is...



The winner can set the next challenge.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 9th Apr 2007 21:04
Thanks Comrade Robski, I'll just think of a new challenge now.


Nothing is impossible...
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 9th Apr 2007 23:45
congratulations nano, i look forward to your challenge.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Apr 2007 23:58 Edited at: 10th Apr 2007 00:30
Yes - well done Nano!

I'm not quite so busy now, so I'm hoping to join in myself with the next challenge...

Zombie 20:

The secret to knowing where and how to use Gosubs is having an understanding of the PC. No, not your computer PC - in programming, the PC is actually the 'Program Counter'. Linear programming languages like DB have a PC which keeps note of what line is currently being executed.

Loops and gosubs (branches) simply modify the PC to define what line of code gets executed next. Therefore, the PC always knows what line number the program is at.

As long as you have a picture of this little PC thing jumping to different parts of your program, things are a little easier.

The idea is to have the PC never reach the last line of the program and end - until you want it to.

For example, when you want a menu on screen, you can do so with a Gosub and trap the PC in a Repeat..Until loop until the user has made the decision to play a new game - at which point you let the PC drop out of the loop and exit the procedure - back to the main program loop where you play the game.

A loop in a procedure can call another procedure and so on. The beauty of procedures is that the Return on the end always knows where to return to thanks to something called the 'stack'.

The important thing is that doing this relies on you maintaining a strict coding structure (layout) and using Goto can seriously mess it up - the reason I'm always warning people not to use it under any circumstances.

Remember, there is no such thing as a program which has to use Goto. You can always accomplish the same thing using Gosub or functions! You might just have to think about how to do it a little harder...

TDK_Man

Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 10th Apr 2007 02:13
@tdk- hahaha, in one of my first weeks here, i read that it was frowned upon to use goto commands. I see what you're saying. I was drawing a diagram of the program flow in my head as i read.

It can be spelled out like a flowchart, you have the main loop and the different branches based on the user's decision. I've been trying to figure out gosubs and functions for this very reason, i wanted clean code and i wanted to show the user's that i was learning and capable of writing clean code.

Thank you for taking the time to write such a long description, i appreciate it, i look forward to seeing your comp entry, you all can do some really cool stuff. Can't wait to join the ranks haha.

have a good night.

zombie


NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 10th Apr 2007 10:39
Thanks guys, OK here it is:

Text editing program

Specification
The challenge is to design a text editing program without use of the enhancment pack. Try to stay away from the 'input' command and mabye make a function of your own for inputing text. Extra marks will be given for layout, the ability to load and save and anything extra you can think of.

Deadline
Tuesday, 17th at midnight


Nothing is impossible...
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Apr 2007 19:08
NanoGamez guy:

Nice Challenge!


To All:

Everyone who enters will learn a lot about strings from this challenge. You might think that strings have very little to do with 3D games, but believe me, they do. Hiscore tables, on-screen messages, item descriptions, interaction with characters all use strings.

After attempting this challenge you should be proficient with string arrays and most (if not all) of the string commands.


Quote: "It can be spelled out like a flowchart, you have the main loop and the different branches based on the user's decision."


That's right. The thing many newcomers struggle with is the game's menu screen. They put it in the main loop and branch to the game rather than have the actual game there and branch off to menus in loops inside procedures.

TDK_Man

Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 10th Apr 2007 22:40
this sounds fun..i have a question though. Will i be able to find the commands included with the enhancement pack on the home page? I have my enhancments on, ah, never mind, i know where they are.

Hey...i'm going to win this one

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Apr 2007 08:53
I'm sure someone will correct me if I'm wrong, but AFAIK, the only string command in the Enhancement pack and therefore not usable in this challenge is Clear Entry Buffer.

I'm not 100% sure on that though - it might have been included in V1.13 un-enhanced.

Besides, I'm fairly sure that command is not essential in completing the challenge.

TDK_Man

Binary Coder
17
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 11th Apr 2007 15:09
Hi,
I am a beginner and I was wonder if it is possible to use an IF-THEN statement with any key. For example:



thank you!
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 11th Apr 2007 18:39
Quote: "I was wonder if it is possible to use an IF-THEN statement with any key. "


Yes it is possible, you can use inkey$(). For example:



or:



There are other ways of doing it but that is the best way.


Nothing is impossible...
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Apr 2007 01:06
Here's what I have so far.



There are a couple of glitches with it at the moment:

1. As it's reading in keyboard presses one at a time in a loop, it's quite difficult getting the timing just right. Too fast and you get lots of repeated letters and too slow, some letters you type are missed. ATM, it doesn't suite a very fast typer and needs looking at.

2. Words at the end of lines are split. I'm writing a word-wrap routine at the moment,

TDK_Man

Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 12th Apr 2007 09:01
I'm out for this one, i'm reading TDK's tuts, i'm modifying the pong program, i'm trying to make particles for storms and rain. so i've got a lot to do as it is, i'll catch you guys in the next one.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Apr 2007 10:24 Edited at: 12th Apr 2007 10:27
Hey, I won this challenge when we did it for DBP! Hmm, this is gonna be hard in DBC.

Well, I had to ditch a few features I had in my Pro version, such as multiple resizeable windows.

Let's see, my first headache was due to thinking scancodes and ascii were the same.

So far you can use arrow keys to navigate, return can break current line and put it below. Backspace will move whole lines up when pressed from the beginning of a line just as you would expect. And the delete key is in there as well, but it doesn't bring up any other lines below it when at the end of the current line. I didn't implement that because I didn't really wanna deal with any text wrapping issues since I'm using a fixed line width.(cause then I'd have to break up words delimited by spaces to figure out what moves up and whatnot)

Text window size is 80 chars across, 28 down. I did peek at TDK's code to see how he got the text sizes. Default font apparently doesn't have a standard width for all characters and I saw he set the font to courier so I just copied that little bit.





Noticed TDK said he was working on a word wrap, which means I gotta at least do the same to keep up. Was thinking about it and I think it might be simple. But it'll have to wait until tomorrow as I haven't slept yet and I gotta leave for class in 4 hours.

Binary Coder
17
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 12th Apr 2007 10:37
Thank you NanoGamez!
That really helpped me because I have been wondering that for ages!
Comrade Robski
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 12th Apr 2007 16:45
@Latch. I really liked your Ice Orb demo from the last challenge - I hope this turns into a really great game. I loved the reflection effect, I'll have to try it out myself.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Apr 2007 17:21
One of the biggest problems with this type of long thread is when someone asks a question and it gets answered with "ah yes - that was answered in the challenge thread".

When there are lots of challenges, it's just so difficult to find the one you want.

Anyone have any objections if I edit the posts which set the challenges so that they stand out when skimming down the page? (I've edited the first challenge post that I did so you can see what I was thinking of adding).

From now on, (if we all agree), you can copy and paste these lines into your own post if you are the one to set a challenge.

At some point, I'll also add a page index to each challenge in the first post.

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 12th Apr 2007 17:43
I personally don't have any objections, It'll be quite useful.


Nothing is impossible...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Apr 2007 20:56
Quote: "At some point, I'll also add a page index to each challenge in the first post."


I was thinking about that as I was reading your post. Like stating each challenge the page it starts on. But then, not all of us display the same number of threads on each page.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Apr 2007 21:19
Quote: "But then, not all of us display the same number of threads on each page."


Lol! I didn't even know you could change it!

The chances are that most users are lazy like me and leave it set to the default value - in which case it would work...

TDK_Man

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Apr 2007 23:01 Edited at: 12th Apr 2007 23:20
Just found this!

http://darkbasic.thegamecreators.com/?f=dbep

It's the complete list of commands which are added to Dark Basic Classic by the enhancement pack. Should make judging challenge entries a little easier...

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Apr 2007 00:01
In your profile under display settings you can set number of messages and threads per page. I display 40 messages per page.

Just thought I'd let everybody know that I've begun storing all the challenges and entries into a database. I've got a simple form that lets me add everything quickly and easily. I've just finished everything up to the current text editor challenge. Now the bummer is that I did it on my own computer, not realizing I didn't build the database on my webserver. Hopefully, I can export/import the data and save another hour of work. I'll try to get the website published tonight, just after I make dinner and calculate the size the Earth would be if it was compressed into creating a blackhole (astronomy homework).

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Apr 2007 01:08
@Comrade

Quote: "@Latch. I really liked your Ice Orb demo from the last challenge "


Thanks! Though I can make all of the players interested in the Ice Orb, I'm having trouble figuring out the logic of making them try and score on the opposing team while having everyone (including the human player) use the same movement routine.

Enjoy your day.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Apr 2007 07:49
Finally got the site online. Moving the database turned out to be simple. It's not 100% complete yet, but its close. The only thing you can't see yet is the actual code. But you can view all the challenges to date and sort them in ascending or descending order for whichever column header you click on. The left side lists everyone who's participated in these challenges and the number in parenthesis is how many entries they've submitted for all challenges. If anyone notices I missed a code snippet or forgot a person altogether, let me know.

http://zimnox.com/dbcc/

Comrade Robski
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 13th Apr 2007 14:25 Edited at: 13th Apr 2007 14:26
@ Latch

Quote: "I'm having trouble figuring out the logic of making them try and score on the opposing team while having everyone (including the human player) use the same movement routine."


An idea, in (very) pseudo code:



The basic idea is that the if the computer player is lined up with the orb and goal, it will try to hit the ball, otherwise it will try to position itself behind the ball so that it lines up.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 13th Apr 2007 21:16
Phaelax:

Nice site - should prove to be very useful when the code is available too!

Comrade Robski:

Can we keep the threads on-topic with the current text editor challenge please?

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Apr 2007 02:02
Spent another hour or two on the site, everything should be finished now. I used Geshi for code highlighting.

http://zimnox.com/dbcc/


Still haven't really worked on a good theme yet, but I'll be keeping it simple. I don't want to use any images for other than the header to keep downloads at a minimum. My website is also now on the CodersTurf servers, so it should be fairly quick.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Apr 2007 04:26
Well, count me out of this challenge. If I don't find time to work on my code tonight I definitely won't have time from now til the end of the challenge. When I'm not working on my term paper and studying for 2 finals next week I'll be fixing my car. I hate cars.


Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Apr 2007 17:18
@Comrade Robski
Thanks! I'll give that a try!

@NanoGamez
I was planning on entering... the program I was working on turned into a larger project than I expected - I figured out a lot of things I had always been planning on figuring out, but as a result, I probably won't be finished on time.

Enjoy your day.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 16th Apr 2007 18:10
At least post what you've done. You never know, you might just win!


Nothing is impossible...
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Apr 2007 18:38
Instead of my original entry, I put this together in the last half hour. It uses a different method than my original approach, but it works... Bare Bones.



Enjoy your day.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Apr 2007 23:13 Edited at: 16th Apr 2007 23:15
Unfortunately I have to go out unexpectedly and won't be back until late. So I won't be able to do anything more to my entry, (thought I'd get time to tidy it up a bit). I'll just post what I've done so far - bugs and all!

Got the wordwrap working when you are entering text and reach the end of the line, but it doesn't do it when you edit already existing text.

There are also plenty of things that don't quite work right, but I simply ran out of time...



[Edit] Doh! Just checked and the deadline is tomorrow night - not tonight. Might get chance to finish it after all...

TDK_Man

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Apr 2007 07:33
Time is up!

Judge - it's up to you now...

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 18th Apr 2007 10:19
OK, I'll just look over them.


Nothing is impossible...
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 18th Apr 2007 19:00
Ok here's the entrys:



And the winner:


And the runner up is:


Now over to the winner to set the next challenge.


Nothing is impossible...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Apr 2007 23:22
I think supporting the TAB key would've been rather difficult. It would've thrown off positioning the cursor.

Congrats TDK. I'll get these entries inserted into the website.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Apr 2007 03:45 Edited at: 19th Apr 2007 03:48
OK, I've had a good think and I have to admit that thinking of challenges is a challenge in itself! I can think of plenty, but coming up with suitable ones isn't easy.

I want them to be as simple as possible to encourage beginners, keep them educational and teach something new - yet still be interesting to those of us who've been programming a little longer.

Anyway, I've come up with the following:

The new challenge is to write a wordcount program. It should be able to open a plain text file and tell you how many words are in it. That's it!

This is primarily an excercise in file access and text manipulation but if you need any hints to get you started, just shout!

So everyone, if you've seen these challenges and didn't think you were good enough to participate, here's your chance...

Deadline: Midnight Thusday 26th April (1 week's time).

TDK_Man

Sinani201
16
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Apr 2007 04:02
? I don't get it... is it supposed to be an input and when the user presses enter it says how many words?

Cheese and Eggs: What a programmer needs to make the next World of Warcraft

Eggs are better than cheese. Did I mention all Italian foods whatsoever?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Apr 2007 04:53
Quote: "I have to admit that thinking of challenges is a challenge in itself"

I totally agree!

Well, here's my entry. Works fine in DBP but in classic it keeps giving me a "severe exception" on the "read string f, s$" line. Can't figure out why, was thinking maybe my copy is just screwed up.




Sinani201
16
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Apr 2007 06:12
Phaelax:

Nice site you got there. Pretty cool; it makes it A LOT easier to check out the nice codes.
I'm hoping this will be my final signature.

<img src="http://i54.photobucket.com/albums/g110/funkybanana22/TheSinani201Loga.jpg" border="0" alt="I am Sinani201 and you can't stop it =P">
Sinani201
16
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Apr 2007 06:14
Quote: "Well, here's my entry. Works fine in DBP but in classic it keeps giving me a "severe exception" on the "read string f, s$" line. Can't figure out why, was thinking maybe my copy is just screwed up."

I think DBPro has some exceptions with different codes. Things work differently in classic...

<img src="http://i54.photobucket.com/albums/g110/funkybanana22/TheSinani201Loga.jpg" border="0" alt="I am Sinani201 and you can't stop it =P">
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Apr 2007 10:06
Ummm... slight problem in that as Phaelax has shown, it's quite simple to meet the challenge. This will make all entries pretty much the same and very difficult to mark.

So, I'll add a couple of bits to hopefully make the entries a little different and make judging easier...

1. When I said "open a plain text file" I had in mind a program which could open any text file (without altering the program each time).

2. Extra points will be added for presentation and any added features (this one applies to practically all challenges without saying anyway).

Quote: "I don't get it... is it supposed to be an input and when the user presses enter it says how many words?"


Your program should let you enter the name of any text file and tell you how many words there are in it. (You are allowed to copy the program into the folder with the text file in it or vice-versa).

I have a text file which I will use with each program and we'll see which ones give the exact word count (or nearest if no-one's program gets it 100% correct).

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Apr 2007 10:30
Quote: " When I said "open a plain text file" I had in mind a program which could open any text file (without altering the program each time"


So you want an open file dialog or something?


Quote: "I think DBPro has some exceptions with different codes. Things work differently in classic..."

I understand that, but far as I can see I didn't use any DBP-specific commands. "severe exception" doesn't really help me much either. Did the code happen to run for anyone?


Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 19th Apr 2007 17:14
@Phaelax

Could be the 255 character limitation? I don't know if the string will terminate properly in DBC if it doesn't encounter 0d 0a when it reads a string from a file.

@TDK
Nothing too fancy but I think this entry fits your new criteria. It hints at being a de-tokenizer. Not super accurate because it looks for space, return, and tab and a preceding character that is not any of those. So it will count numbers, and punctuation - assuming words could end in either. So, it will read any type of file, even binary - and give back a count.



Enjoy your day.

Login to post a reply

Server time is: 2024-04-16 14:47:42
Your offset time is: 2024-04-16 14:47:42