Scripts RND

Multimedia Builder (Legacy Forum)
Post Reply
cvespecialista
Posts: 8
Joined: Tue Apr 23, 2019 9:37 am

Scripts RND

Post by cvespecialista »

Hello, I'm new and my question is for MMB project.
I need to do a scripts lists and with the RightKey select one scripts from the list, is to random many data and select just one.
Excuse for bad english.
Thanks

dgilmour
Posts: 535
Joined: Fri Oct 22, 2010 11:29 am
Location: Moskva, Rusko
Contact:

Re: Scripts RND

Post by dgilmour »

It's really hard to understand what you mean.

cvespecialista
Posts: 8
Joined: Tue Apr 23, 2019 9:37 am

Re: Scripts RND

Post by cvespecialista »

dgilmour wrote:It's really hard to understand what you mean.
I need to select from several scripts 1, at random

dgilmour
Posts: 535
Joined: Fri Oct 22, 2010 11:29 am
Location: Moskva, Rusko
Contact:

Re: Scripts RND

Post by dgilmour »

Code: Select all

n = RND(9) + 1
label$ = 'Script ' + CHAR(n)
RunScript("label$")
This will run one of ten script objects with object name "Script n" where n is number from 1 to 10.

cvespecialista
Posts: 8
Joined: Tue Apr 23, 2019 9:37 am

Re: Scripts RND

Post by cvespecialista »

dgilmour wrote:

Code: Select all

n = RND(9) + 1
label$ = 'Script ' + CHAR(n)
RunScript("label$")
This will run one of ten script objects with object name "Script n" where n is number from 1 to 10.
Thank you for the code, but I could not to do with your specifications, could you to do an sample for me in .mbd, please.
Thank again.

Nigg
Posts: 57
Joined: Thu Apr 14, 2011 2:10 pm

Re: Scripts RND

Post by Nigg »

If you dont understand this example, I recommend to take a look at the (very good) MMB documentation.

Code: Select all

n = RND(9) + 1
define an integer variable "n" containing a number, using the random/rnd-function (see doc -> RND)

Code: Select all

label$ = 'Script ' + CHAR(n)
define a string variable "label" that returns the text "Script" and the random number from the integer variable "n" after it . "CHAR" makes it possible to use the integer value of "n" in the context of a string.

Code: Select all

RunScript("label$")
Run the script defined by the label$ variable ("Script" + the random number)... this could be "Script1", "Script2", "Script3" etc.

Post Reply