random name picker thingy

Discussion in 'Code Snippets and Tutorials' started by Underground_Secrets, May 23, 2007.

  1. Underground_Secrets

    Joined:
    Dec 22, 2006
    Messages:
    626
    Likes Received:
    1
    Gender:
    Female
    Location:
    West Coast in USA
    how do u use scar to make tha randome name picker thng they use in the daily giveaway? i could use a script like that for something else.
     
  2. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    Its perl nand I think it searches the meberlist or uses an sql query
     
  3. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    you would be able to do it, but it wouldnt be like the daily giveaway because it wouldnt use the internet to get the list, it would need a pre-loaded list. if thats ok i can tell you the code you need to use, otherwise you could use vb or perl like the neofriends one
     
  4. Underground_Secrets

    Joined:
    Dec 22, 2006
    Messages:
    626
    Likes Received:
    1
    Gender:
    Female
    Location:
    West Coast in USA
    yeh the pre-loaded list is wat i had in mind. i can add & remove ppl that way on the list. yes the scar code would be excellent if u can pm it to me :D
     
  5. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    i might make something like this and release the code
    the only thing i can say is that you'll need a recent scar (3.0+) to use it with unless you have already got srl
     
  6. Underground_Secrets

    Joined:
    Dec 22, 2006
    Messages:
    626
    Likes Received:
    1
    Gender:
    Female
    Location:
    West Coast in USA
    doesnt 3.0 have a problem that messes up windows really bad? i keep seeing that in my old version that i have now.
     
  7. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    only if you use a certain function in it
    3.06 works fine though

    Code (Text):
    1. program NamePicker;
    2. {include.SRL/SRL.scar}
    3. procedure Pickname;
    4. begin
    5.   Case Random(7) of
    6.   0: writeln('Abba');
    7.   1: writeln('Acca');
    8.   2: writeln('Adda');
    9.   3: writeln('Arra');
    10.   4: writeln('Agga');
    11.   5: writeln('Ahha');
    12.   6: writeln('Awwa');
    13.   end;
    14. end;
    15.  
    16. begin
    17. pickname;
    18. end.
     
  8. pandahorde

    pandahorde Level IV

    Joined:
    Dec 17, 2006
    Messages:
    2,249
    Likes Received:
    17
    Location:
    "MANILA ZOO"
    thx chelsea1 now im gonna try it ..
    i see it works.. it picks random to desire name you put every writeln..

    I used this an example:
    Code (Text):
    1.  
    2. program NamePicker;
    3. {include.SRL/SRL.scar}
    4. procedure Pickname;
    5. begin
    6.   Case Random(7) of
    7.   0: writeln('Expon');
    8.   1: writeln('Chelsea1');
    9.   2: writeln('PandaHorde');
    10.   3: writeln('SonOfChilly');
    11.   4: writeln('Billy_bob_joe');
    12.   5: writeln('Marlene');
    13.   6: writeln('Joe_kick_ass');
    14.   end;
    15. end;
    16.  
    17. begin
    18. pickname;
    19. end.

    and the result is this..

    Code (Text):
    1. Successfully compiled
    2. Billy_bob_joe
    3. Successfully executed

    so yeah ... billy_bob_joe wins my example give away.
     
  9. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    glad you like it
    you can add others to the bottom as long as you change the number in the
    Code (Text):
    1. random(7)
     
  10. pandahorde

    pandahorde Level IV

    Joined:
    Dec 17, 2006
    Messages:
    2,249
    Likes Received:
    17
    Location:
    "MANILA ZOO"
    well if i do the give away...lol
    it is easy for me to do in scars if i have all list of members.
     
  11. tac123

    tac123 Level I

    Joined:
    Apr 29, 2007
    Messages:
    124
    Likes Received:
    0
    I don't really like using a case statement for something like what he wants. Suppose he has 200 entries, and then he wants to delete entry 100. I don't know how SCAR works, but the best change would then be to make the last entry (200) changed to 100 to fill the gap. Then, suppose some more random entries in the middle get deleted, then you will have a lot of random numbers at the end of your case statement, and it will get really confusing as to what numbers are taken and which ones are free.

    The best solution is to read in the entries from a file, but I do not know if SCAR supports that.

    The next best solution would be to use an array, and add each entry without specifying an index so that they are allocated at compile / runtime. Then choose a random number between 0 and the array length minus one.

    Like I said though, I don't really know SCAR so they may not support these features.