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.

Newcomers DBPro Corner / Programming advice request

Author
Message
CalliahS
18
Years of Service
User Offline
Joined: 30th Mar 2006
Location:
Posted: 14th Apr 2006 05:27
Hello everyone!

I've posted a couple of times before, about a few different things. Thanks for any help there with those problems. I've been fooling around with a bunch of programming (text based stuff only, so far), and I've learved a few things.

I made a small program that allows you to move around in a text based area. There aren't any real descriptions yet, but it does what is necessary. I know that there are a few things I am doing the long way, but I'm still too new to realize it. I was wondering if someone here would be willing to go through the code and tell me what I could do different/better than what i'm doing now. Any help would be greatly appreciated!

The code:


The text file:


The text file reads like this: room number, description, north link, south link, east link, west link, up link, and down link. The array in the program takes care of sorting them into their own spots.

Thanks again,
Calliah
Evil Booger
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: My evil lair
Posted: 14th Apr 2006 07:05
You might not get many responses because to run this file we have to create a new project and open Notepad and save the textfile and put it in the same directory as the project and then have to select and retype computer-specific stuff like "C:\Documents and Settings\Calliahs\Desktop\db\db\Text".

I guess it's a pretty good program but that's just my opinion. My advice is to make it easier for other people so you can get more opinions.


boogers will take over the world
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 14th Apr 2006 09:59 Edited at: 14th Apr 2006 10:01
It's looking good so far. I like how you had some error handling in there too. I noticed you had massive functions like
This can be reduced in size to about 6 lines probably. Try some use of for loops and while loops. I'll take a look at this tomorrow, but give a few shots at reducing the code and making it more efficient.

To make the array rooms$ global so that the command's scope can see it, place this over your old code
This will make it available in your entire program. I noticed that when you hit a dead end it says "alas" and thats all i have time to read before it disappears. Replace that line of code with something like
This prints the message, then syncs it so the user can see the message. The program then goes on pause until the user presses a key.

By the way, are you using dark basic classic or pro? I'll be checking on this tomorrow to actually help you a little more. Good Luck!


Check out Penguin in the Projects Section!!!
http://www.prodigyarts.5gigs.com
CalliahS
18
Years of Service
User Offline
Joined: 30th Mar 2006
Location:
Posted: 14th Apr 2006 14:12
Sorry, I should have mentioned the language I was using. I'm using DBC at the moment. I haven't really seen the need for me to upgrade to pro yet.
CalliahS
18
Years of Service
User Offline
Joined: 30th Mar 2006
Location:
Posted: 14th Apr 2006 14:52
Since I don't have DBP, I can't do the GLOBAL DIM like you suggested, so I had to read the array into each individual function that uses it. Other than that, I changed the was the command function works. First, I read a second text file into an array with this:


I put that under the same label as the other file.

The text file looked as simple as this:


Then, finally, the new code for the command function looks like this



How does this all look now?

The function would have been about 8 lines if I were able to use the GLOBAL DIM command. Maybe I should consider getting DBP now.

Calliah
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 15th Apr 2006 02:33
Ya, thats already looking way better. I have Dark Basic Classic and Pro, so I ran the code I gave you and I guess there is no global. I'm sure there is a way to pass a function into an array but I can't seem to find out how. A good work around for now is to just use gosubs. Here is an example
I'll post back if I find out how to pass it into your function. Good luck in keep it up!


Check out Penguin in the Projects Section!!!
http://www.prodigyarts.5gigs.com
CalliahS
18
Years of Service
User Offline
Joined: 30th Mar 2006
Location:
Posted: 16th Apr 2006 09:50
Ok, I've gone just a step further, and used your suggestiong. I've gotten the code from 122 lines down to 83, just by using two new for loops and new label. Thank you so much for the advice. I've realized a few things thanks to that.



My next small step is to make the error function print either "you cannot go that way" if you put in a direction that is invalid, or to print "HUH?!" for a command that isn't recognized at all.

After that, I'll start working on character creation and status screens. Again, thanks for the help!

Calliah
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 16th Apr 2006 21:22
Looking good Keep it up and let me know if you need any help. Good luck!


Check out Penguin in the Projects Section!!!
http://www.prodigyarts.5gigs.com
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th Apr 2006 21:28
Arent arrays automatically global anyways? Or is that just in DBC?

Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 16th Apr 2006 22:02
Quote: "Arent arrays automatically global anyways? Or is that just in DBC?
"


Im using dbpro, and the arrays are automatically global there.
Evil Booger
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: My evil lair
Posted: 16th Apr 2006 22:17
Wow! I'm glad you got so much help.
There are so really nice people here.

boogers will take over the world
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 16th Apr 2006 23:21 Edited at: 16th Apr 2006 23:22
Yeah they are global, didn't realize that because I'm used to c++ n' java. Glad you pointed that out. This code ran fine on Dark Basic Classic
You could go back to your function or continue using subroutines.


Check out Penguin in the Projects Section!!!
http://www.prodigyarts.5gigs.com
CalliahS
18
Years of Service
User Offline
Joined: 30th Mar 2006
Location:
Posted: 17th Apr 2006 03:14
You're aboslutely right. I thought that I had a problem in a previous program with the array not being readable in a function. Turns out that it was a mistake on my part. I'll change it back to functions now, because I think that'd be a bit easier.
Thanks again everyone!
Calliah

Login to post a reply

Server time is: 2024-09-24 21:34:16
Your offset time is: 2024-09-24 21:34:16