Question about Random function.

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Locked
User avatar
Harakiri
Posts: 75
Joined: Fri Aug 13, 2010 2:07 pm
Location: Mars
Contact:

Question about Random function.

Post by Harakiri »

I wanna make a program that after a clic display some random text.

like I have these texts:

"text one"
"text two"
"text three"
"text four"
"text five"

So once y press a button it take me to a new page were it displays:

"{random}"

where "random" can be any of the five texts I have at random.

How?

Thanks! :oops:
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Post by Neosoft Support »

First create an array of variables for the text:

SetVar "[T0]" "text one"
SetVar "[T1]" "text two"
SetVar "[T2]" "text three"
SetVar "[T3]" "text four"
SetVar "[T4]" "text five"

Then you can choose one of the text strings at random like this:

Random "4" "[Rnd]"
SetVar "[RandomText]" "[T[Rnd]]"

The selected text will be stored in the variable [RandomText].
NeoSoft Support
User avatar
Harakiri
Posts: 75
Joined: Fri Aug 13, 2010 2:07 pm
Location: Mars
Contact:

Post by Harakiri »

thanks a lot :wink:

it works great
Locked