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 / code snippit help?

Author
Message
manta01
17
Years of Service
User Offline
Joined: 20th Dec 2007
Location:
Posted: 29th Dec 2007 02:42
Hi, Below is my first attempt at coding in DBC can someone take a gander at it and see if the syntax is right? It's a basic AI function to determine if a npc is going to attack and what strength it will have. Feel free to point out mistakes in the code. any comments are greatly appreciated.
I also added this to the codebase area of the forum asking for help butr realized this is probably a better place to ASK a review.
Thanks again for your comments.
Manta01



Signature? Signature? we dont need no stupid Signatures.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Dec 2007 10:00
Hey!

I read through your code and I`m not sure about this part:



Shouldn`t you take away the "" ?
Like this:



Or it also works with a $ sign:




The rest is fine. Nice coding, mate!

Oooooops!!! I accidentally formated drive c.
manta01
17
Years of Service
User Offline
Joined: 20th Dec 2007
Location:
Posted: 30th Dec 2007 05:27
Thanks for all the input.
Yeah i wasnt sure if you could return multiple values from a function, but now i know its only one, gotcha. and thanks for all the help. And ill use the strings format above.. Not sure about the Bracket comment, If you mean the variables passed in, thats because of a limitation of the Website, the closing bracket is at the end of the next line, In the true code the closing bracket is on the same line If you have another location I missed a bracket Please feel free to point out the location.
Again great response, I really appreciate it..

Signature? Signature? we dont need no stupid Signatures.
manta01
17
Years of Service
User Offline
Joined: 20th Dec 2007
Location:
Posted: 30th Dec 2007 05:45
DOH, Thanks WindowsKiller, I see what your talking about, I did put the bracket in the wrong place, it should be on the first line. Thats what I get for programming at 3AM... thanks again. that Bracket goes up one level.. Here's the new code fixed per the comments. 3 mistakes thats not too bad for a First attempt i guess, not as good as 0 though *smiles* And thanks 'theComet' I meant them to be strings. oops thats 4 mistakes drat!!
One question, is it possible to return an complete Array from a function? or is it one and only one return variable? IE can you return an array that your Dim'd in your function like this

would that work or would i get an undefined error


Thanks again.
Manta01

updated code below renamed to accurately describe function.




Signature? Signature? we dont need no stupid Signatures.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Dec 2007 16:42 Edited at: 31st Dec 2007 16:46
Quote: "is it possible to return an complete Array from a function?"


In Dark Basic Classic, arrays are global. This means that an array defined and used in the main part of your program can be accessed in a function.

Likewise, any changes made to arrays inside functions remain when you exit from them. As such, you don't need to return anything.

TDK_Man

Login to post a reply

Server time is: 2025-06-02 09:52:13
Your offset time is: 2025-06-02 09:52:13