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 / RND could not understand line

Author
Message
Donlan
7
Years of Service
User Offline
Joined: 8th Feb 2013
Location:
Posted: 4th Apr 2013 23:29
Whenever I try to use RND(3) It says that it can't understand command at line 14.


RND(3)


Thankyou

p.s I'm new to darkbasic
Ortu
DBPro Master
12
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 5th Apr 2013 07:32
the line numbers it gives can sometimes be misleading, and there is not really enough information here, can you post a bit more of the code, before and after the rnd so we can see how exactly you're trying to use it?

Chris Tate
DBPro Master
11
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 5th Apr 2013 12:16
Judging by your post, the command was used incorrectly.

Result = Rnd(3)

It's an expression so it must have an assignment or be a parameter.

Donlan
7
Years of Service
User Offline
Joined: 8th Feb 2013
Location:
Posted: 5th Apr 2013 13:08
Ahh, thanks for the reply, is it possible to use RND to print a word from the ones I have chosen. If so would this work:


RND(3)
IF RND = "3" THEN PRINT "TEST"
IF RND = "2" THEN PRINT "TEST"
IF RND = "1" THEN PRINT "TEST"
IF RND = "0" THEN PRINT "TEST"
chafari
Valued Member
14
Years of Service
Recently Online
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Apr 2013 16:03
Try this...



I'm not a grumpy grandpa
Donlan
7
Years of Service
User Offline
Joined: 8th Feb 2013
Location:
Posted: 5th Apr 2013 16:40
Thank you very much Chafari, chris tate and ortu you have been a great
help!
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Apr 2013 16:49
You should probably do this though.



RND() will always return something different whenever you call it. Calling it once and storing the result in a variable (x) means that x can only be one thing.

If you used chafari's code, it'd randomly print "TEST". Maybe that's what you want though.

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
chafari
Valued Member
14
Years of Service
Recently Online
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Apr 2013 19:57 Edited at: 5th Apr 2013 19:59
Quote: "If you used chafari's code, it'd randomly print "TEST""


That was the minimun code I've got

Cheers

I'm not a grumpy grandpa
Chris Tate
DBPro Master
11
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 5th Apr 2013 21:57
The above code is sufficient; but what I do is:

Print "TEST" + Str$(Rnd(3)+1)

Or

Dim Result$(3) : Result$(0) = "First" : Result$(1) = "Second"
Result$(2) = "Third" : Result$(3) = "Forth"
Print Result$( Rnd(3) )

TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Apr 2013 00:23
As you can see the sky's not the limit. Here's another way.



Taumatawhakatangihangakoauauotamateapokaiwhenuakitanatahu is a hill
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is a town
Chargoggagoggmanchauggagoggchaubunagungamaugg is a lake
Phaelax
DBPro Master
17
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Apr 2013 01:56
But 4 can't be reached in your code Comet!

"You're all wrong. You're all idiots." ~Fluffy Rabbit
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 8th Apr 2013 18:06
Oh crap, nice catch.

TheComet

Taumatawhakatangihangakoauauotamateapokaiwhenuakitanatahu is a hill
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is a town
Chargoggagoggmanchauggagoggchaubunagungamaugg is a lake

Login to post a reply

Server time is: 2020-08-03 19:18:53
Your offset time is: 2020-08-03 19:18:53