Scripts RND

Multimedia Builder

Scripts RND

Postby cvespecialista » Tue Apr 23, 2019 9:42 am

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
cvespecialista
 
Posts: 5
Joined: Tue Apr 23, 2019 9:37 am

Re: Scripts RND

Postby dgilmour » Wed Apr 24, 2019 2:03 pm

It's really hard to understand what you mean.
dgilmour
 
Posts: 523
Joined: Fri Oct 22, 2010 11:29 am
Location: Moskva, Rusko

Re: Scripts RND

Postby cvespecialista » Wed Apr 24, 2019 3:03 pm

dgilmour wrote:It's really hard to understand what you mean.


I need to select from several scripts 1, at random
cvespecialista
 
Posts: 5
Joined: Tue Apr 23, 2019 9:37 am

Re: Scripts RND

Postby dgilmour » Wed Apr 24, 2019 6:18 pm

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.
dgilmour
 
Posts: 523
Joined: Fri Oct 22, 2010 11:29 am
Location: Moskva, Rusko

Re: Scripts RND

Postby cvespecialista » Thu Apr 25, 2019 8:24 pm

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.
cvespecialista
 
Posts: 5
Joined: Tue Apr 23, 2019 9:37 am

Re: Scripts RND

Postby Nigg » Fri Apr 26, 2019 5:21 am

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.
Nigg
 
Posts: 54
Joined: Thu Apr 14, 2011 2:10 pm


Return to MMB

Who is online

Users browsing this forum: Google [Bot] and 2 guests