Source language: Translate to:

Question about Random function.

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

Moderator: Neosoft Support

Question about Random function.

Postby Harakiri » Tue Nov 02, 2010 4:00 pm

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:
User avatar
Harakiri
 
Posts: 75
Joined: Fri Aug 13, 2010 2:07 pm
Location: Mars

Postby Neosoft Support » Wed Nov 03, 2010 11:05 am

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
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Harakiri » Wed Nov 03, 2010 4:59 pm

thanks a lot :wink:

it works great
User avatar
Harakiri
 
Posts: 75
Joined: Fri Aug 13, 2010 2:07 pm
Location: Mars


Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 1 guest