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 / Beginner's Guide To Dark Basic Exercise: Directory Manager

Author
Message
VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 15th Mar 2012 19:13
Hello Fellow Game Developers

I have just finished typing out the exercise code from the Beginner's Guide To Dark Basic book. When I go to compile the code, this line is said to be causing a syntax error: startA = (currentpage(1)*pagesize(1))+1 . If someone could go through my code and check it, that would be great.



When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Mar 2012 07:31
I think you forgot to declare the current page array at the top of your code.

VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 26th Mar 2012 19:20
Huh????

When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 26th Mar 2012 19:23
Okay, I found one of my errors. I forget to put the code: DIM currentpage(1), so that took care of one problem. However now I have a new problem. Another syntax error occurs at the line: posy = ((x-startA)*filespacing(1))+pagestartY(1). If someone could take a look at it and tell why this syntax error is occurring, that would be great. Thanks!

When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 27th Mar 2012 01:40 Edited at: 27th Mar 2012 01:42
You'll kick yourself for this one:

In both these lines there is an "e" between the "c" and "ing"

DIM filespaceing(1)

filespaceing(1) = 16

The "e" is now missing from "filespacing" in this line:

posy = ((x-startA)*filespacing(1))+pagestartY(1).

You've just misspelt the variable name in the "posy = " line compared to the declared array name and it's coming up as a syntax error. Your code runs fin once this and the other error that was mentioned are fixed.
VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 27th Mar 2012 19:27
Your right 29 games. I will be kicking myself.


*Goes and kicks himself till anger is cured*

Okay thanks for spotting my error. By any chance is there a place where you can submit your code and a computer will check for syntax errors? I was just wondering since sometimes it takes a while until I get feedback on problems. Anyways, Thanks 29 games for spotting my error and helping me finish this exercise.

When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Mar 2012 20:19 Edited at: 28th Mar 2012 20:20
Quote: "is there a place where you can submit your code and a computer will check for syntax errors"


Technically DBP has already done this for you but, in this particular instance, what DBP can't tell you is how to fix the problem.

What the error says is:

Cannot find structure 'DISPLAYFILES:&filespacing' in local declaraton at line 50

This basically translates as "you haven't declared the array". As far as DBP is concerned filespaceing (with an "e") and filespacing (without an "e") are two completely different variables, and the latter hasn't been declared. I only assumed that you made a typo with the spelling of the variable but you could have equally made a mistake by not declaring the variable to begin with. DBP highlighted a mistake but isn't clever enough to connect the dots, as it where, to point you to a solution.

Debugging is part of the skill of coding, admittedly not the most glamourous part, and you will get better at it the more you code. It just takes practice.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 28th Mar 2012 22:56
99.9% of the time a syntax error is due to a typo
Try reading the line backwards. This helps read word by word. If that doesn't help then move on to check #2 - confirm that you spelled your variables the same way when declared.

Another method that might help you out with this is to test each function as you build them. It is a pain in the butt, but it is less than a pain in the butt than trying to find the error in a big heap of code. The major advantage of functional programming. I believe it is called unit testing.

Hope that helps.

Login to post a reply

Server time is: 2024-11-23 21:00:48
Your offset time is: 2024-11-23 21:00:48