AppleScript, random items in list, without repetitions?

Hello

First of all it is what I have so far:

the value myList {"Bob", "Brian", "Mark", "Joshua", "Sarah", "George"} as list

Repeat

the value of some element of myLIst randomChoice

randomChoice2 the value of some element of myList

display the dialog randomChoice & return & randomChoice2

end repeat

If you run this script, you will notice that sometimes there will be two of the same name (Bob Bob or Mark Mark).

I want to be able to make sure the two random elements are not the same. So that once that a name is chosen as a randomChoice, it can not be chosen for the randomChoice2.

Here:

the value myList {"Bob", "Brian", "Mark", "Joshua", "Sarah", "George"} as list

the value myList2 {"", ""}

Repeat

point 1 of the myList2 the value of some element of myList

point 2 of myList2 the value of some element of myList

Repeat until that point 1 of the myList2 is not point 2 of myList2

point 2 of myList2 the value of some element of myList

end repeat

value {randomChoice, randomChoice2} myList2

display the dialog randomChoice & return & randomChoice2

end repeat

(137457)

Tags: Mac OS & System Software

Similar Questions

  • Vista is adding tags randomly in my list of tag photo gallary.

    Vista is adding tags randomly in my list of tag photo gallary. For each tag that I added, there are several that I did not. None of these tags has pictures with them. How can I fix it? Where are these * tags coming?

    Hello

    see this link:

    http://Windows.Microsoft.com/en-us/Windows-Vista/working-with-digital-pictures

    http://Windows.Microsoft.com/en-us/Windows-Vista/tag-pictures-so-theyre-easier-to-findhttp://windows.microsoft.com/en-US/windows7/Tag-pictures-so-theyre-easier-to-find

  • Adding items to the QNX list without scrolling

    Is it possible to update the items in a list of qnx without scrolling of the list in article 1?

    I have a list of qnx that retrieves its list items in a stream, and if the list item has been scrolled, beyond every time that I update the dataprovider, it automatically reloads the list with 1 point on the screen.

    HM sounds quite interesting. what I would do is to find something to defines a set of data apart from others and makes every single tweet. There is probably an ID of the API or something. then id have a separate table, keep track of all the IDS in your current list. from there whenever u 'referesh' you can check if you got the identifiers in the new list differ from your current table of ID. If they are separately add each individual tweet of the new incoming list using the addItem() method instead of reset your entire dataprovider. hope that helps some. Good luck!

  • 6 random numbers without repetition

    I'm doing a generator of 6 random numbers between 1 and 48. When the user clicks a button randomly 6 numbers appear in 6 different textFeilds. The problem is that I don't want the same number twice. How can I generate 6 different random numbers without using back and out of the service?

    import flash.events.Event;

    Stop();

    btn.addEventListener (MouseEvent.CLICK, random1);

    function random1 {(evt:Event)}

    display1. Text = "";

    Display2.text = "";

    Display3.text = "";

    display4. Text = "";

    display5. Text = "";

    display6. Text = "";

    var r1 = Math.floor (Math.random () *(1+48-1)) + 1;

    var r2 = Math.floor (Math.random () *(1+48-1)) + 1;

    var A3 = Math.floor (Math.random () *(1+48-1)) + 1;

    var r4 = Math.floor (Math.random () *(1+48-1)) + 1;

    var A5 = Math.floor (Math.random () *(1+48-1)) + 1;

    var A6 = Math.floor (Math.random () *(1+48-1)) + 1;

    If (r2 = r1 | r3 == r2 | r4 == r3 | r5 == r4 | r6 = r5) {}

    return;

    }

    var list: Array = new Array();

    Liste.push (R1, R2, R3, R4, R5, R6);

    Liste.sort (Array.Numeric);

    display1. Text = String (list [0]);

    Display2.Text = String (list [1]);

    Display3.Text = String (list [2]);

    display4. Text = String (list [3]);

    display5. Text = String (list [4]);

    display6. Text = String (list [5]);

    }

    Here is the code for the approach mentioned with your included textfields

    btn.addEventListener (MouseEvent.CLICK, random1);

    function random1 {(evt:Event)}

    var nums:Array = new Array();

    Complete the table of numbers

    for (var i: uint = 1; i<=48;>
    Nums.push (i);
    }

    Shuffle (NUMS);

    Take the first six of the mixed table

    var list: Array = nums.splice (0.6);

    assign values to the textfields

    for (var j: uint = 1; j<=6;>
    This ["Display" + String (j)] .text = String (list [j]);
    }
    }

    function shuffle(a:Array) {}
    var p:int;
    var t: *;
    var ivar:int;
    for (ivar =. Length-1; Ivar > = 0; Ivar-) {}
    p = Math.Floor ((Ivar+1) * Math.Random ());
    t = a [ivar];
    a [ivar] = a [p];
    a [p] = t;
    }
    }

  • A problem list: (choose in rear &amp; amp; random items)

    Hi all

    I have a problem to list that I need your help. Here is my code:

    option list is loaded with the following: [1,2,3,4]
    on whichaccessoryload

    TPO = accessoriesList.getPos (linetext)
    n = accessoriesList.count)

    If apt = 1 then
    Window ("Haptek_player"). Movie.Sprite (1). "[[Hypertext =" \load [queue = ["& accessoriesPath &" "& accessoriesList [1] &"]] "]]".
    -charge the first item in the list (that is, number 1)
    on the other
    If apt < = n then
    whattodelete = accessoriesList [OPC - 1]
    Window ("Haptek_player"). Movie.Sprite (1). Hypertext = "\delperson[figure=" & whattodelete & "]" "
    -remove the previous support question (i.e., number 1)
    Window ("Haptek_player"). Movie.Sprite (1). "[[Hypertext =" \load [queue = ["& accessoriesPath &" "& linetext &"]] "]]".
    -loads a new element into the list (IE., number 2)

    Whenever this handler is called: given a list with 4 digits [1,2,3,4], check if the position of the value of linetext is 1 in the list, and so true load this value (number 1) in the 3D engine... otherwise it deletes the previous value (in our example number 1) and load a new value instead (number 2)... then deletes the number 2 and charges of the order of the day (number 3) and so on... The above code works 100% if my user selects items in the list (1,2,3,4) sequencially.

    Now... what I would like to add, is to select the elements backwards (4,3,2,1) but also at random (for example, 4, if you select Remove from article 2 4 and load 2 in the engine, or 3 If you select 1 Delete 3 and 1 in the engine load..). I hope that we don't know what I'm asking... Any help will be greatly appreciated...

    Problem solved... Here is the code (I am simply remove ALL items in the list before you load the new value). Thanks for your tent...

    Global linetext, accessoriesList

    on whichaccessoryload

    TPO = accessoriesList.getPos (linetext)
    Re = "(\.\htr)$".

    accessoriesPath = the moviepath & "Haptek_Resources\Accessories\".
    n = accessoriesList.count)
    v_sprite_ref = window("Haptek_player").movie.sprite (1)

    -forward

    If apt = 1 then

    v_sprite_ref. Hypertext = "\delperson[figure= hair7_exp_brown]" - remove the original hair
    v_sprite_ref. "[[Hypertext =" \load [queue = ["& accessoriesPath &" "& accessoriesList [1] &"]] "]]".

    on the other

    If apt<= n="">

    Repeat with i = 1 to n
    accessoriesList = RegExp_Replace (accessoriesList, re, "", "g")
    v_sprite_ref. Hypertext = "\delperson[figure=" & accessoriesList & "]".
    end repeat

    v_sprite_ref. Hypertext = "\load [queue = [" & accessoriesPath & "" & lineText & "" "]]".

    end if
    end if
    end

  • ADF MOBILE: how to add an item in the list without refresh the entire list

    Hello

    I am using this method to add an item to a list (I've already added the item to the data model):


    providerChangeSupport.fireProviderCreate (String providerKey, int newRowKey, object newValue);


    I don't want refresh the entire list, rather, I want to just add a new item to the list, that's why I want to use this method.


    I want to know, what value should I use for the second argument? i.e. 'int newRowKey '.


    Thank you


    Hello

    the event of change of provider in your case seems to actually create a new line. So the int is the rowKey (index PK or line) of the new line. There is no other choice to simply add an element to a list (ADF Mobile provides no component handles)

    See: Embedded Java/ADF for beginners: ADF Mobile: refresh your valuable data

    Frank

  • Get random items, no repetitive table

    Hello!

    I'm doing a 20-question, multiple-choice quiz. Each question is chosen at random in a table, and whenever the user clicks on the right answer, another random question comes up. I was not able to find a way to make sure not to repeat issues already selected. I tried to push the selected items in a table, then using $.grep and an if statement to check if the other randomly chosen question is already in the new table or not, but I couldn't get that to work.

    My code in the Panel of compositionReady is:

    var arr is ["Symbol_1", 'Symbol_2', 'Symbol_3', 'Symbol_4', 'Symbol_5', 'Symbol_6', 'Symbol_7', 'Symbol_8', 'Symbol_9', 'Symbol_10', 'Symbol_11', 'Symbol_12', 'Symbol_13', 'Symbol_14', 'Symbol_15', 'Symbol_16', 'Symbol_17', 'Symbol_18', 'Symbol_19', 'Symbol_20'];.

    sym.setVariable ("arr", arr);

    arr.sort (Function () {return 0.5 - Math.random ()});

    arr. Length = 20;

    var c = Math.floor (Math.random () * 100) %arr.length;

    for (i = 0; i < 20; i ++) {}

    SYM.$(arr[i]). Hide();

    SYM.$(arr[ques]). Show();

    };

    and whenever you click on the right answer, I run this:

    sym.getComposition () .getStage ().$("try_again1").hide ();

    sym.getComposition () .getStage ().$("correct1").show ();

    sym.getComposition () .getStage ().getSymbol("correct1").play ();

    var arr = sym.getComposition () .getStage () .getVariable ("arr");

    var c = Math.floor (Math.random () * 100) %arr.length;

    for (i = 0; i < = 20; i ++) {}

    sym.getComposition () .getStage ().$(arr[i]).hide ();

    sym.getComposition () .getStage ().$(arr[ques]).show ();

    }

    An overview of this would be much appreciated!


    Hi, bettiesac212-

    Well, I took a quick glance to your project (including project files was very useful, which is said by the way).  So what happens, is that you have included my code snippet in the middle of all the other things happening in your file.  There are a lot of questions I had looking at your code, like:

    • What is 'e '?  Where did this come from?
    • Why did you an array.sort initially?
    • Why do you attribute arr.length?  It is a property of arr already, so there is no reason to assign this

    Anyway, I cleaned up the code a bit to my snippet in.  I left some of her "as an exercise to the student", to paraphrase some of my old books, but I hope the console log will show you that usedArr is now a random picture that you can save.  If you save a variable that has the index, (aka "what question am I on?"), then you can get where you are now, add one, save this variable and are looking for the next item in usedArr and know that it is properly randomized.

    For those who are looking for an answer, this is the code I ended up using:

    var usedArr = new Array();

    var currentIndex = 0;

    While (currentIndex< 20)="">

    var randNum is Math.floor ((Math.random () * 100)) % 20;.

    If (usedArr [randNum] == undefined) {}

    We can place an object!

    usedArr [randNum] = arr [currentIndex];

    currentIndex ++;

    }

    by do not increment the currentIndex, we force basically he draw again

    }

    for (i = 0; i< usedarr.length;="" i++)="">

    Console.log ("index usedArr" + i + ":" + usedArr [i]);

    }

    You can save your new table and just browse each time

    you say "next question."

    I think that's more or less what I posted in my previous answer.  Bettie, I'll send you a link to your project files via private message in a few minutes.

    Thank you

    -Elaine

  • go to random frame without repetition

    Hi I have the code below on my mc, I would it gotoandPlay a random frame instead of a specific image, as I put it in place now.  Can anyone help? I wish that he not go twice to the same period.

    on (release) {}

    _root.circle_mc._visible = false;

    //Movieclip GotoAndPlay behavior

    this._parent.gotoAndPlay("2");

    //End behavior

    }

    THX

    Place the numbers of images in a table then choose randomly one of them and then remove that table with the splice() method.

    Alternatively, you can put in a table then mix the table and through the mixed table from end to end.

  • Is there a way to change the names of folders in waiting lists without changing the name of the original file?

    Hello

    I was curious to know if there was a way I could change the name of a folder on my list of added items leaving the name of the original file untouched. I work in an accounting firm that shares all of our records on a single server, and we can't rename an any of them like all the world has its own shortcuts and what not on their individual computers. For example, some of our files are separated into folders by file type, exercises and billing periods, like this:

    Billing applications

    EXERCISE 14-15

    Period 1

    Digitized invoice copies

    EXERCISE 14-15

    Period 1

    If I have two folders period 1 has performed the fallen on my desk, they are both the same labeled, but I would like to I know not what specific folder, I work in rename them. Is there a way I can rename the folder on my list of items added on my desktop without changing the name of the file in its original location? I know that I can hover over the name of the folder to get the exact location of the file, but when I work quickly, it becomes a bit cumbersome to do this for every file, especially when I need to have several folders (at least 10) pinned.

    Thank you!

    Hello

    You can create the path of the shortcut for them and name it as you want.

  • Ornament between items of list in CSS

    Helllo Dreamweavers.

    I'm working on a site that has a menu in it.

    Not a menu like the one you have in your site regularly, but one you will find in a restaurant.

    Between courses, I want an ornament floral heart as separator, as follows:

    floralheart.png

    Now, I could easily add the symbol in HTML between list items, as follows:

    < ul >

    the grill < li > van Kreeft, quinoasalade met blokjes augurk, ansjovisdressing in limoencreme. < /li > & #x2766;

    < li > in good gegaarde zeeduivel, ter plekke getrancheerd zijn. < /li > & #x2766;

    < li > tarbotfilet Gegrilde met ovengegaarde en restaurant, anijschampignons in waterkersjus Zucchini. < /li > & #x2766;

    < /ul >

    which is what you see in the picture.

    But the content is editable by the customer more later in a CMS, I'dd add rather ornament in CSS so it still works.

    I tried this:

    Li: after {}

    content: '\2766 ';

    }

    That works, but adds the floral heart after the list item, where I want to be between list items, while it is always centered.

    So, how this could be done?

    Make a non-repetitive background image to the

  • tag.  Add padding to the bottom of the tag to place the element.  Background-position allows you to center the floral heart.  Should work fine.

  • How can I move in my email back to my Inbox list without having to scroll to the left on my tab bar. I couldn't find anything in the keyboard shortcuts.

    I don't know there is a simple toggle to put in my list of emails in my Inbox, and the list of files. But I'm not. Any help will be greatly appreciated. 8.1 user to win.

    Thank you

    Terry

    I keep multiple tabs open because I'm collecting items that I want to send my brother at a later date.

    I guess I could "tag" them. I'll have to read on the tags function to see if it will work better for me.

    Or I could create a directory for him and move the mail, a message at the same time as I read them.

    The method I use won't cut it.

    Thanks for the help, I actually had my problem solved.

    Terry

  • Junk folder is missing, and I'm unable to send emails to the addresses of the list without contact

    Summary of the issue
    Send/receive email problem

    Please provide your address affected:
    E-mail address is removed from the privacy *.
    Additional details

    I recently set up my X - Box Live ID girls and attached it to my profile as a child account.  For some reason, I had to create a new account, for its xbox live and link it to a hotmail account.  I put in place that e-mail as a child and linked to my email account * address email is removed from the privacy * I think was the name of the child account * address email is removed from the privacy * or live.com.  I don't know if what I feel is due to this link/link.
    What I feel is the following: my junk e-mail folder is no longer visible in my folder list.  I get a lot of spam, but I've been at some point receive unwanted emails from an email address that said of * address email is removed from the privacy *, which is of course MY e-mail address.  When I opened the email there is a link, but it wasn't an email I sent.  I'm not stupid enough to click on this link, then I looked at the headers.  But I just looked to see if I saved them to my computer or not.  I can't locate copy this email, because they are stored in my spam box, and I don't have the option more to click on it.  I regularly send myself emails with reminders to myself, so I don't know if I've inadvertently admitted someone access to spoil my account, or if I made a mistake in the process, I took.
    Basically when I try to send email he gave me an error message that says that I could not send to sources outside my list of contacts, because of settings parents.  However, this has been my email for a long time now, and I'm 30 years old and never had this problem before.  I looked under related accounts, thinking somehow that connection could be causing it.  I deleted my account my e-mail girls.  After that I am more able to see my box of junk e-mail, or send email to anyone outside of my lists of contacts.
    I looked through all the settings that I could and connected with my info, but it had no effect.  I need to know what is happening with my account, and I need to have this resolved.  I'm not able to receive emails, so if I don't hear from you, please use email from my wife who is * address email is removed from the privacy *, or call me at the 623-418-7466.  If this can be resolved without further communication, it would be better, but I'll check everything that I need to in order to get this resolved.

    Thank you very much for your support,
    Andrew M. Jones

    ADDED: I've already entered my settings and provide my date of birth 29/09/1981.  I took this step because of a closely similar thread that had this step for a fix.  There was still no change after this action. I could check my emails, because I can send one to the internet provider of the e-mail, I found in the header.  So I found the file headers and I tried to add to this email, but he crossed the line.

    Hi, Andrew Jones,.

    After reviewing your question and account again, I checked that your e-mail address, is the story of the child of email from your daughter. You can remove it by following these steps:

    1. go to the Family Safety Web Site with your daughter account (as is the current parent account).
    2. under family summary, click Remove a member of the family.
    3. check or tick the box next to the account name.
    4. click on Remove.
    5. a dialog box appears, click Remove.
    6 sign out. you of the Family Safety website.

    In case that the website redirects you to download the parental control, please download and install on your computer. Then, access the website again.

    Thank you
    B. Litton

  • BBUI.js how to have the item id list-arrow-text to a detail screen

    I use BBUI.js and on my screen, I have a text-arrow-list with the elements.

    How to pass the data bb-item value to a window of details to retrieve and display more details there?
    This may be really obvious, but I don't see how do and any help would be appreciated.

    Excerpt from the list screen. He is firing onclick of the item in the list.
    openListItem: function() {}
    var value = this.getAttribute('data-bb-value');
    bb.pushScreen ("detail.html" + "?") ID = "(+ value, 'detail');"
    }

    It's the charge of the detail screen where the Iwoudl like access id
    detailScreen = {}
    load: {function (element)}
    How do I access the query string of the url in the pushScreen or the id of the list?
    }

    Please let me know if my question is not clear enough. Thank you.

    I don't think that we have added the ability to pass parameters through pushScreen().

    You'll need follow the overall status in your own public variable/object.  Now click the element, you will need to save the value in an object / a global variable.

    There is an bb.onscreenready event which you can subscribe to which fires before the new screen is treated by the Toolbox... It will pass the part of the screen you can handle until the style is applied.

    There are details in the Readme that give more information on how this works... Just do a search on the page of "onscreenready".

  • As a component of item in list box

    Hello

    I have created a ListView with components list item as a label and a checkbox control.

    When I check the box on a list item, I will not get an onTrigger event in the list.  Thus, there is no way to check if the box is checked or unchecked.  I don't need a single checkbox to be in a State of "verified" in both listview.

    I tried to get the row of the box that is checked and call a function to browse the path to the index. Now I want to uncheck all of the boxes other than the one that is checked today.

    CheckBox {
                   id: checkBoxId
                   horizontalAlignment: HorizontalAlignment.Right
                   verticalAlignment: VerticalAlignment.Center
                    onCheckedChanged: {
                     var rowNum = rootContainer.ListItem.indexPath;
                     count = articlesDataModel.size();
                      toggleCheckBox();
                                       }
              }
    
                function toggleCheckBox()
                        {
                          for (var i=0 ; i< count ; i++)
                           {
                            if(rootContainer.ListItem.indexPath[i]!= rowNum)
                             {
                              ????????
                              }
    
                             }
    
                          }
    

    This is the code that I have tried. But I don't know how to get the control box here inside...

    Could someone please look into this?

    Thank you

    SJ

    Hello..

    http://supportforums.BlackBerry.com/T5/Cascades-development/RadioButton-in-list-view-problem/TD-p/24...

    This link helped me to solve this problem. Thank you

  • Can not type 'url-list' without client Anyconnect VPN setup

    Hi I am trying set Anyconnect VPN client based on Cisco documents below. There is a command like below. When I typed 'url-list', I can't enter.

    Here is example of Cisco:

    WebVPN
    allow outside
     list of URLS ServerList "WSHAWLAP" cifs://10.2.2.2 1
     list of URLS ServerList "FOCUS_SRV_1" https://10.2.2.3 2
     list of URLS ServerList "FOCUS_SRV_2" http://10.2.2.4 3

    Here's my ASA:

    VPNFW-70/PRI/Act(config-WebVPN) # url -?

    set up the mode commands/options:
    URL-block url-url-cache server

    My ASA has no choice of the list of URLs when you type '?

    Can anyone give me some suggestions? Thank you.

    http://www.Cisco.com/c/en/us/support/docs/security/ASA-5500-x-series-NEX...

    Hello

    In the 7.x code all customizations without client was included in the running configuration.
    However, referring to this document from cisco:- http://goo.gl/XRkrcO, you can see that this command has been deprecated in 8.X ASA codes.

    The best way to configure the bookmarks will use the ASDM or create them on a server and then bring import them to ASA.

    Why we can not create bookmarks CLI?

    With the introduction of 8.x many more options have been added, allowing greater flexibility.  These new options would make the running configuration passes, so they were moved into separate xml files.  Indeed, it eliminated the ability to configure a list of bookmark via the CLI.

    For more information on this discussion, please refer to this thread: -.
    https://supportforums.Cisco.com/discussion/11010546/how-do-i-create-URL-bookmark-WebVPN-Portal-CLI

    Kind regards
    Dinesh Moudgil

    PS Please rate helpful messages.

Maybe you are looking for