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 / Sync and RND???

Author
Message
Razarati
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 1st Aug 2004 04:00
I've been wondering what the Sync and RND then followed by a number in brackets means and when u have to use it in a piece of code.
Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 1st Aug 2004 04:06
Erm, like: SYNC RND(40)?

It wouldn't actually do anything, its not valid DBPro code.

"I am not young enough to know everything."
- Oscar Wilde
MrBlack
20
Years of Service
User Offline
Joined: 17th Jun 2004
Location: Switzerland
Posted: 1st Aug 2004 04:08
RND means 'Random'.
for example x = RND(20) will randomly assign a value between 0 and 20 to x.

SYNC is used to refresh the displayed picture. If you don't use it, DarkBASIC will control that. If you want to use it to manually refresh your screen, you have to first tell the compiler you are going to do that yourself.

Write this at the beginning of your code to use the manual sync :
SYNC ON

Then, in your main loop, for example, use the SYNC command each time you want to refresh your screen :

DO
`some actions
SYNC
LOOP

Hope this helps...

You have failed me for the last time
Razarati
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 1st Aug 2004 04:20
What do these mean also?

n = 1 or n = 0 and Numdata = 0 and near the end of the code u write next n???
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 1st Aug 2004 06:42 Edited at: 1st Aug 2004 06:43
N is a variable. Ok, check this out.

For n = 1 to 5
print "I am going to say hello five times!"
next x

end


Ok, now what this does is when the program uses this code, it will go over the center code 5 times. The first time it will be n = 1, and it will print "I am going to say hello five times". Then when it hits, "Next x", it will go back to the top code and n = 2 this time. It will then print the "I am going to say hello fivr times" again. Then it will hit "Next x" again and go back to the top, and this time, n = 3. Get it? Then, when n = 5 and the program hits "Next x", there will be no more "X"s to go through, and it will continue to "End". What you will see on the screen will be "I am going to say hello five times" printed on the screen...you guessed it...five times!

OK, this might be totally confusing, but I am not good at explaining very simple things. I would suggest to read some tutorials, and really think about picking up "The Beginner's Guide to DarkBASIC Programming", as I can see you are just beginning. You need to get a foundation before asking questions here, because there are way too many commands needed in DB to ask about them all here. The book is a great starting place, as I am just starting in Db too! Hope this helped a little!

Fraggles where quite the scary lot...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 1st Aug 2004 11:55
Small typo...

For n = 1 to 5
print "I am going to say hello five times!"
next n

Your FOR variable needs to match your NEXT variable unless you have nested FOR/NEXT loops.

For n = 1 to 5
for x = 0 to 3
print "Adding numbers: "+str$(n) + "+" + str$(x) + "=" + str$(n+x)
next x
next n

--
TAZ

"Do you think it is wise to provoke him?" "It's what I do." -- Stargate SG-1
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 1st Aug 2004 15:02
Oops, yeah. Typo. I was talking on the phone at work at the same time I was writing that

Fraggles where quite the scary lot...
Razarati
20
Years of Service
User Offline
Joined: 26th May 2004
Location:
Posted: 1st Aug 2004 19:18
THNX alot every1

Login to post a reply

Server time is: 2024-09-22 18:31:11
Your offset time is: 2024-09-22 18:31:11