Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 3:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Random number in OpusScript (opus pro 04)
PostPosted: February 20th, 2006, 12:10 pm 
Offline

Joined: February 20th, 2006, 12:00 pm
Posts: 1
Location: Wales
We need to generate random numbers between 1 - 12 inclusive, each number being ultimately used only once.
We have looked into creating a variable that would store each of the used numbers, and when after randomly selecting a number our programme would check the variable to see if this number has already been used, and if it has, repeat from the random "number action". Our problem is that we would need to use opus script in order to repeat the sequence of actions.


For this message m & b barrett has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Random number in OpusScript (opus pro 04)
PostPosted: February 20th, 2006, 5:04 pm 
Offline

Joined: November 5th, 2004, 6:54 am
Posts: 130
Location: Hengelo, The Netherlands
Opus: 8.5/9.0
OS: Windows 7 64-bits, Android 2.1, Android 4.1.2, iOS 7
System: Pentium 7i, 6GB RAM, 750GB HD, DVD-RW (+/-), DV, 3TB EHD, 3D monitor without glasses
Hi,

There is all a discussion with an example attached in this forum.
You can find it here.

http://www.digitalgrapevine.info/viewtopic.php?t=34&highlight=random

When you search yourself on the forum, you didn't have to post this problem :wink:.

Kind regards,

_________________
Oscar Nijst
ON Education & Consultancy
Hengelo, The Netherlands
OPUS Pro 9.5
Pentium 7i, 16GB RAM, 1 TB HD, DVD-RW (+/-), DV, 3TB EHD, 3D monitor without glasses


For this message osni has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Non repeating random numbers
PostPosted: February 21st, 2006, 11:48 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
You may be able to make use of this script which I generically use for what you want to achieve. I got it from the forum some time ago.

//=======================

function RandomList(number)// Random number Generator (actually mixes numbers up with no repeats)


{
numberlist = new Array()

for (count = 1; count <= number; count++) //Fills array up to number

{
numberlist[count] = count
}

RandomNumbers = new Array() // use these arrays

for (count = numberlist.length - 1; count > 0; count--)

{
picked = Math.floor(Math.random()*count)+1

RandomNumbers[count-1] = numberlist[picked]

numberlist[picked] = numberlist[count]

}

}

//=================================


This is a function that I use when I want random (non Repeated) numbers.

The variable "number" could be hard coded as the max random number that you want.

The array is used to store the random numbers so that as you sequence throught the array you get a non repeated number each time.

It is specific to what I need and therefore you would need to modify it.

Hope this helps.

Clive Cartmel


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Random numbers
PostPosted: February 21st, 2006, 11:51 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
Having looked at Oscars post the random number funtion that I use is obviously based on the one in his link.

Thanks to those contributors concerned

Clive Cartmel


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: May 5th, 2007, 7:50 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Please Clive I tried to use your script ,but I didn't get anything.
Please explain more or anyone else help.
My target that I have 10 numbers I want them to be displayed in a variable ,but without repetition.


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group