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 / Arrays are not working as intended

Author
Message
Clbembry
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 19th Jan 2008 00:31 Edited at: 15th Mar 2008 17:35
I'm having a small problem getting a number saved to an array. What I want to happen is that if it is player one's turn then the keypresses get saved to the array keypresses(). Then when it is player two's turn I want it so that the keypresses are saved to the array keypresses2. My code isn't working and it is all getting saved to the first array.

This is my code:


<a href="http://j3msoft.com">My gaming company's website.</a>
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Jan 2008 06:03
Without proper indentation, it's not easy to follow. You should tidy it up a bit.

You have Gosub Player2 in there. Where is the gosub player1 to initially get to the player1 procedure?

As it works (sort of) you wouldn't think there would be a problem, but at the end of the first procedure there is a Return. Exactly where does it return to?

Without the proper structure you will get stack errors - and that's where proper indentation makes life a lot easier.

If you need any further help on the subject, it's covered in tutorial 2 here.

TDK_Man

Dewi Morgan
16
Years of Service
User Offline
Joined: 16th Jan 2008
Location: London, UK
Posted: 19th Jan 2008 06:04


How does it reach the "do" after the "return"? I think the return is spurious and should be deleted, otherwise you will only never BE player 2.

If you indent your subroutines, and your loops, it makes it a ton easier to read and make out the code structure, and this bug leaps right out at you, impossible to miss.

If this is the bug that is. It's been years since I've played with DBP.

Yet another game programmer

Login to post a reply

Server time is: 2024-11-25 10:33:16
Your offset time is: 2024-11-25 10:33:16