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 / Free digital e-book for newcomers

Author
Message
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 7th Jun 2006 20:31 Edited at: 7th Jun 2006 20:32
Hi, I'm working on a free digital e-book for new users to DarkBASIC Professional covering the basics of the language. I've just produced a first draft (not finished yet) covering variables. I'd like to know if it is easy to understand, and if not, if you have any suggestions on improving it. I'd also like to know any common questions you might want to know that have not been covered, and any suggestions for future installments. The next section will cover decision making, and a couple of small text games.

The work is covered by Creative Commons, and legal to share. Just don't alter it, try and pass it off as your own or try to sell it.

It is in PDF format so you will need acrobat reader version 4 and upwards.

http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=902456

Your signature has been erased by a mod because it's larger than 600x120...

Attachments

Login to view attachments
Jaded Gamer
18
Years of Service
User Offline
Joined: 19th Apr 2006
Location: Iceland
Posted: 7th Jun 2006 22:55
Very well done so far, and just the kind of thing someone like me needs =). You go into depth to explain things and are quite precise, the wording is easy to understand.

You go into detail about different types of variables, and give examples of when they might be used, and why. However, the text doesn't actually explain how except for floats and integers.

For example if I have a line: x=1
how can it be set up to be boolean, byte, dword, etc. for my purposes, instead of having it count only as an integer which takes up more memory? x as boolean?

For future installments, something I would like to see are things like a simple menu and maybe some common errors and how to avoid them.

Anyway, it looks great so far, and I look forward to seeing future installments
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 8th Jun 2006 00:04 Edited at: 8th Jun 2006 00:04
I've added your suggestions to draft 2, and included Datatypes and #Constants.

I'll be covering simple text based menu's in the next IF and CASE statements. I'll prob write it tomorrow depending on how much time I have, and if this headache goes away.

Enjoy!

http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=902700

Your signature has been erased by a mod because it's larger than 600x120...

Attachments

Login to view attachments
Jaded Gamer
18
Years of Service
User Offline
Joined: 19th Apr 2006
Location: Iceland
Posted: 8th Jun 2006 00:38
Oooh! You did that so fast and were very thorough with the additions. Thank you for providing us with this excellent work!

Also thank you for having more than one example of doing things. Its nice to know there are choices and understanding it well enough to make the right one for a given situation.
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 9th Jun 2006 17:01 Edited at: 9th Jun 2006 17:22
That document is looking good Kenjar. The only thing I can suggest at this point is to say something about using meaningful variable names and constant names.
[edit]

You could also build a small game. At the end of each chapter, you could put in some code summing up what has been learned so far. By the end of the book, the user would have a functioning program and know how it works.

[edit 2]

The bottom of Pg 9 says:
For X =1 to 100, but then it refers to storing 400 variables.

Keep up the good work!

Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 9th Jun 2006 19:11
The second volume will provide examples using the core commands of DarkBASIC, at this point I'm going to use game source code to provide examples of usage for all core commands. This will mainly involve a text adventure. I'll also be covering some game design theory, and the usage of flow charts in game design. I feel a text adventure is the best way to demonstrate this.

Thanks for pointing out the error in the last arrays program, I've adjusted the code accordingly. I've also started on boolean and decision making, I'll upload it once the first draft is done.

I warn you though it's hot, and I don't deal with heat very well, so if you see any mistakes please point them out to me!

Your signature has been erased by a mod because it's larger than 600x120...
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 10th Jun 2006 00:49
Oh, and you could add the character limit for strings. Is it 256?

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 10th Jun 2006 12:40 Edited at: 10th Jun 2006 12:57
Character limit for strings??? There had better not be one! I've been loading 296 length strings into my text adventure program as a test and it has worked. I'll just go and increase the strings a bit and see!

Okay..test results have come back...
I was reading my string froma text file, and have discovered there is a limit to strings being read in: 1337 characters for some reason!
However, creating a huge string in memory by concatenating "a" 999,999 times (took 30 minutes to run!) seems to prove that there is no limit length for strings. Yippee!
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 10th Jun 2006 13:54 Edited at: 10th Jun 2006 13:56
Agreed, however there is a point where it becomes unusable, realistically speaking. I managed 4,510,000 "Z"'s and gave up at that point because it too 58 seconds on my machine to add them, and to count them. Here's my test program, it prints out the number of seconds taken to complete each program loop.



Remember though, it won't nessassarily be consistant with each character. The machine doesn't remember the letter itself, but it's position on the ASCII table, and a Captial Z is much higher then a little a.

Your signature has been erased by a mod because it's larger than 600x120...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 10th Jun 2006 14:02
Yeah, I was just adding a single 'a' each time, simply to find a limit, and left it running while I did other stuff.

I could have kept going, but as you said, beyond a certain limit, long strings become unusable. I was just trying to prove strings of 255 are not the max

Kenjar, any ideas on why there is a 1337 max read from text files?

cheers!
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 10th Jun 2006 19:13 Edited at: 10th Jun 2006 19:25
OK, good news about the string lengths. I guess I'm stuck back in the quick basic days

I did find another small problem with the array loops. The array index starts at 0, not 1. So when you say Dim a(1), you actually have 2 elements in the array. It wouldn't matter in most cases, but if you start using the dynamic array commands like "array insert at bottom", it can lead to subtle logic errors.

Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 10th Jun 2006 23:22
yes, I keep forgetting to go 0 to 255 instead I keep typing in 1 to 256, a bad habbit of mine.

Your signature has been erased by a mod because it's larger than 600x120...
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 11th Jun 2006 22:26
I've uploaded the updated version of the book. It covers IF statements and boolean functions. I've covered a random number guessing game as well as Russian Roulette.

Your signature has been erased by a mod because it's larger than 600x120...

Attachments

Login to view attachments
Jaded Gamer
18
Years of Service
User Offline
Joined: 19th Apr 2006
Location: Iceland
Posted: 15th Jun 2006 23:15
Kenjar, you have really put a lot of time and effort into this and it shows! It seems as though your finished "little book" will end up being quite lengthy and indepth!

I have a couple of suggestions if you don't mind. One is, you have an inconsistancy in the indents on the code portions, ranging from somewhere like 2 characters to 6 or more. If this is intended, I am not sure why. Also, it seems as though you are spacing for the indents instead of tabbing, so it makes them look even more inconsistant. It would make the code look neater if the indents were consistant. Secondly, you use a lot of blank spaces between lines of code that really spread it out. I think it would be neater and easier to read if there weren't blank spaces so frequently.

I think this is going to be an impressive work when its completed!

"So it goes."
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 16th Jun 2006 16:53
I don't want to nitpick because I think this manual is a great resource for beginners. But I want to make sure they don't get confused to to small errors:

Pg 12:
Question:Is my slice of cake and my friends slice of cake combined,larger then my mothers slice of
cake,and my dads slice of cake combined?

Boolean Expression, should be:
(CakeSliceA + CakeSliceB)>(CakeSliceC + CakeSliceD)


Another variation of this question would be:
Question:Is my slice of cake,or my friends slice of cake,smaller than my mothers slice of cake,or
my fathers slice of cake?
Not positive on this one, but I think you need to break up the expression to get a correct result:

(CakeSliceA<CakeSliceC) OR (CakeSliceA<CakeSliceD) OR (CakeSliceB<CakeSliceC) OR (CakeSliceB<CakeSliceD)



pg 13:
IF A#>B#then Print “A is Bigger than B!” Else Print “A is Less than B!”
will give wrong result if a=b. You could say "A is less than or equal to b"


pg 14,15:
IF Answer$="No" OR Answer$="no" OR "N" OR Answer$="n" OR Answer$=“NO ”
will always evaluate to true. should be:
IF Answer$="No" OR Answer$="no" OR Answer$="N" OR Answer$="n" OR Answer$=“NO ”


Keep up the good work!

Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 16th Jun 2006 20:33 Edited at: 16th Jun 2006 20:38
for strings really the limit is 4gb because of 32bit address space but for them to be usable it shouldn't be more than ram cause then it goes into pagefile and variables in pagefile=bad

only thing I see so far in the book is in variables you don't cover the advanced types like DWORD's and BOOL's or well nvm(didn't read enough)
you might want to add the fact that if you have a variable in the main thing(not in a function) then its automatically global
I think you might say "next most used" too much in the commands part(not that it not readable just don't look good)

edit:
and on the notes for float variables might want to say this is because of the x86 FPU or something(or maybe not)

edit2:
and on goto's you might want to say why they aren't used much

JouleOS and friends
great thanks to http://galekus.com for FREE HOSTING!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 16th Jun 2006 21:27
Quote: "if you have a variable in the main thing(not in a function) then its automatically global"


Er, since when?

Isn't that why we have the GLOBAL keyword?

As in
GLOBAL c AS INTEGER

c can now be seen by functions??
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 16th Jun 2006 21:59
hmmm lemme test

that printed 23 on the screen so... (ignore font stuff)

JouleOS and friends
great thanks to http://galekus.com for FREE HOSTING!
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 16th Jun 2006 22:03
@Three Score: that's not much of a test, since you declared testa as a global variable on the first line.

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 16th Jun 2006 22:44
Yep, if you leave off the global it fails!

Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 16th Jun 2006 23:16
ahh crap; sorry I jsut had global on my mind and wasn't thinking ok then

your right

JouleOS and friends
great thanks to http://galekus.com for FREE HOSTING!
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 20th Jun 2006 17:36 Edited at: 20th Jun 2006 17:40
Globals are not automatic. When you create large programs with multiple source code files, numberous functions and subroutines, you will discover that variables suddanly stop working if you don't declair them as a global. I've seen this on Open MMORPG, Star Trek Trader and the RTS Framework project.

Quote: "One is, you have an inconsistancy in the indents on the code portions, ranging from somewhere like 2 characters to 6 or more. If this is intended, I am not sure why."


Not intended, the drafts will be a little messy, I'll need to go through everythiung with a fine tooth comb afterwards you are just seeing first generation source code written on the fly.

Quote: "I think it would be neater and easier to read if there weren't blank spaces so frequently."


I'll get on that, thanks. I put the different styles in there to get feedback. I'll aim for denser code now.

Quote: "I don't want to nitpick because I think this manual is a great resource for beginners. But I want to make sure they don't get confused to to small errors:"


Thanks, I'll read through your comments and apply them. As a first draft, I'm sure there will be a ton of mistakes. If I where selling this I'd write it, come back to it a week or two later, rewrite, then wait another week and repeat, then test it on people. As it is, I'm not dedicating that much time to it. So in short, any more mistakes you see in future editions, please point them out!

I'll upload the lastest version sometimes next week, I have a flat inspection, and some more stujdy to do to make sujre I know what I'm talking about in the next section.

Also if anyone is interested. I'm going to be uploading the pdf documents to cafepress.com, so you can buy printed versions of the first four books. I'm making NO profit at all, it will cost, whatever cafepress charge per print of each book. Each one should average 60 - 100 A4 Pages.

Your signature has been erased by a mod because it's larger than 600x120...
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 22nd Jun 2006 04:33 Edited at: 22nd Jun 2006 04:35
A printed version?
Always good to have a hard copy.

When I dream,
I carry a sword in one hand,
a gun in the other...
Euphoria
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: United Kingdom
Posted: 22nd Jun 2006 16:40 Edited at: 22nd Jun 2006 16:42
Only bits I could find (nowt big) are:

Quote: "In DarkBASIC Professional it is easy to tell if it does, if the text turns blue, then that name is already assigned to a command."


Maybe need a disclamer in the preface or introduction mentioning that this book assumes you are using the DBP IDE without any settings changed?

Quote: "If however there is data in the program that will be used
many times across many different subroutines and functions then it is called a global variable."


Not sure if I'm wrong here, but I thought subroutines shared the same variable scope as the main program, and that its only functions that have local variables, therefore a variable can only be called global if it defined to work across functions.....think I've confused myself now....

Lastly I would expect datatypes and arrays to appear after such things as Decision making and the print command. Potentially arrays could have their own section to include multidimensional arrays as well..and possibly stacks/queues etc... although maybe thats taking things a little to far for the purpose of a beginners book

Over all it was a good read. Great work Kenjar!

Login to post a reply

Server time is: 2024-11-26 17:16:39
Your offset time is: 2024-11-26 17:16:39