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 / can somone explane functions?

Author
Message
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 17th Feb 2003 05:56
my code is looking really messy, i think I could clean it up a bit If I stuck in a few functions, can somone explain how these work? do they need to be in the loop? ect...
As I walk through the vally of the shadow of death, I will fear no evil.
- Psalms 23:4
Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 17th Feb 2003 13:10
Declare functions at the bottom of your code (not inside loop).

A function can be made to perform a task or return data (or both).

e.g.

that should work
xmen
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 17th Feb 2003 22:33
try this example hope it helps

`..................Drawing.............

Morales
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: - Please Select -
Posted: 17th Feb 2003 22:41
sync on : sync rate 40
do

x=x+1
z=z-1

re(x,z)

sync
loop
`the re(n,p) could be any word you just give it name
function re(n,p)
set cursor 0,0
print n
print p
endfunction re(n,p)
Morales
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: - Please Select -
Posted: 17th Feb 2003 22:43
pleas tell me if it helped you
PiratSS
22
Years of Service
User Offline
Joined: 18th Oct 2002
Location:
Posted: 17th Feb 2003 23:07
Ok, I will take the time to write u some explanation

Let's say you are writing a program for IBM. They want you to print out any message if you hold any key.

Now you think, ok, it would be pretty easy if i do this:

sync on



but that's too messy.

Here come functions! And we are going to make our own function that will work 100% like "text X,Y,string$"

we start off by declaring a function:

Function text2(X,Y,string$)

that is great! but what does it do?

well, nothing rightnow, not until we complete it.

you final function will look like this:

Function text2(X,Y,string$)
set cursor X,Y,String$
endfunction

now to quickly explain:

this function works just like a text command. In fact, we will have a text vs out text2

try this code:



Specs: Dual Amd Athlon 2Ghz(1Ghz x 2), 40GB 15000 Rpm SCSI Hard Drive, 640 Mb 266Mhz DDR, 12x8x32 CDRW, ATI Rage Fury Pro 32Mb SD Video, 17' Monitor

Login to post a reply

Server time is: 2024-11-24 01:21:49
Your offset time is: 2024-11-24 01:21:49