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 / I want to share my buttons

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 17th Oct 2004 16:24
Ok this is really doing my head in, how in the world can you share a button?? for example say i want to go to object 1 and press E to get a discription but then i want to go to object 2 and again press E for a discription of that?? every time i have tried it never works for more than one object, i'd assume that i just can't get the programming right, i'm not even really sure how to go about it do i use "If object collision(x,x)=x and inkey$()="e" or if x#=>x and x#=<x and y#=>x and y#=<x and inkey$()="e" ?? both are probably wrong which is why i need your help PLEASE!!! Oh yeah i am using DBC and i have NO idea how to use functions so if that ends up the case is there any chance of a really detailed explaination... thank you..

I can see from your smile, you're not here for the sunset.
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 17th Oct 2004 18:05
well, don't know quite what you mean about your original inquiry, but I can probably help with functions. They are VERY important aspects of a language so are good to know and know well.

Functions have very easy syntax. Here's an example of a very basic function:



What that does is gives you a basic function template. When you type:



All the code where "Rem You would insert code here" is would get called (as you would have guessed probably). Parameters are what give power to a function. Say you want to pass in an integer value, you would type in this when making your function (using the same function as above for this example).



I said parameters give a function power, but being able to return information is what truely makes a function a function. That can be done in one of two ways. For the sake of space I'll show both in the same function.



The first way you return data in this case is with the "ExitFunction" command. This command doesn't have to have a parameter so you could just call "ExitFunction", but with a parameter, that value gets passed. For instance, if I called this function like so:



x would now be 6 because you passed in a 4 (myParam) and the result (which will be myResult) equals myParameter + 2.

The other way to return a value is basically by slapping it on the end of your 'EndFunction' the same way you would with 'ExitFunction'. 'ExitFunction' and 'EndFunction' do not require parameters (read that return values), and you also are not required to use 'ExitFunction'. It is good for leaving a function early, for example:



This function is a safe function if you have no idea what value myObject is. In Dark Basic, passing a handle to an object less than 0 will result in a runtime error. This function would make sure that wouldn't happen by exiting early before I manipulated the object. Notice also that you can attatch more than one parameter by adding commas to sperate them.

Here's a shot at your main answer, though. See if you can figure out how it works:



I hope that helps, and if it feels like I was belittling your knowledge of DB, forgive me, I had no intent. I just have no idea how knowledgeable you are with DB so I brought it down the elemental levels as much as I could so I didn't miss anything important. Good luck with your project!

Finally, object oriented programming using Dark Basic with a new C++ style translator - DOOP. You can get it here for free (BETA):
http://www.geocities.com/djpeterson83/projects.html

Login to post a reply

Server time is: 2024-11-27 13:02:33
Your offset time is: 2024-11-27 13:02:33