Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 03:07

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



random Frage??

Discussion on random Frage?? within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 46
Received Thanks: 0
random Frage??

Hi ich wollte irgend ein zufallsgenerator machen aber es werden alle msg´s angezeigt hier der source:
PHP Code:
Dim $zahl
Random
(1,5)
$zahl[1]=Msgbox(0,"Titel","iwas")
$zahl[2]=Msgbox(0,"Titel","iwas")
.......... 
was ist falsch
urasic is offline  
Old 10/05/2010, 14:58   #2
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
du erstellst dir ne variable $zahl, die von autoit ohne wertzuweisung automatisch 1 gesetzt wird.

in der nächsten zeile lässt du eine zufallszahl erstellen, die aber nirgens gespeichert wird.

wenn du damit fertig bist versuchst du aufeinmal auf die vorher definierte $zahl (1) als array zuzugreifen

spätestens da solltest du eigentlich einen fehler vom compiler bekommen. verstehe nicht ganz wie die msgboxen angezeigt werden können, wenn du versuchst einer nicht array varaible, arraywerte zuzuordnen.

Edit:
hier mal ein kleines beispiel wie man ein zufallselement aus einem array nehmen könnte:
Code:
Dim $array[5] = ["Horst", "Walter", "Holger", "Ursula", "Gertrude"]
MsgBox(0, "Zufallsname", $array[Random(0, 4, 1)])
lolkop is offline  
Thanks
1 User
Old 10/05/2010, 15:02   #3
 
elite*gold: 0
Join Date: Aug 2010
Posts: 46
Received Thanks: 0
schreib mal wie du es machen würdest
Nach dem TuT von shadow habe ich alles richtig gemacht
urasic is offline  
Old 10/05/2010, 15:02   #4
 
BlackHybrid's Avatar
 
elite*gold: 52
The Black Market: 101/0/0
Join Date: Oct 2010
Posts: 1,998
Received Thanks: 389
Habs jetzt mal auf die schnelle so gemacht
PHP Code:
$zahl Random(121)

If 
$zahl 1 Then
    $zahl 
MsgBox(0"Titel""1")
ElseIf 
$zahl 2 Then
    $zahl 
MsgBox(0"Titel""2")
EndIf 
BlackHybrid is offline  
Thanks
1 User
Old 10/05/2010, 15:36   #5
 
PenGuin :O's Avatar
 
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
Code:
Dim $Fragen[5] = ["Wie gehts?", "Wo wohnst du?", "Wie heißt du?", "Was machst du?", "Wie geht das?"]
$i = Random(1, UBound($Fragen), 1)
MsgBox(0, "", $Fragen[$i])
Platzsparend ;O

EDIT:
@lolkop (falls er wieder was zu meckern hat :P):
UBound hab ich genommen, damit er nur die Fragen anpassen muss und den Index des Arrays
PenGuin :O is offline  
Old 10/05/2010, 19:14   #6
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
Quote:
Originally Posted by pinguin94 View Post
Code:
Dim $Fragen[5] = ["Wie gehts?", "Wo wohnst du?", "Wie heißt du?", "Was machst du?", "Wie geht das?"]
$i = Random(1, UBound($Fragen), 1)
MsgBox(0, "", $Fragen[$i])
Platzsparend ;O

EDIT:
@lolkop (falls er wieder was zu meckern hat :P):
UBound hab ich genommen, damit er nur die Fragen anpassen muss und den Index des Arrays
zu meckern gibs da nichts =)
frag mich nur grad was darann jetz platzsparender sein soll als bei meinem :P
lolkop is offline  
Old 10/05/2010, 22:15   #7
 
PenGuin :O's Avatar
 
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
Jaaa xD Hab mich an BlackHybrid orientiert, dien Post hatte ich irgendwie gekonnt ignoriert o.O
PenGuin :O is offline  
Reply


Similar Threads Similar Threads
RANDOM
06/05/2009 - Conquer Online 2 - 3 Replies
HOW DO YOU BECOME GAY IN CONQUER???????? PLEASE ANSWER ME????? I REALLY LOVE GAY?????
It is not random!
12/08/2008 - Conquer Online 2 - 19 Replies
I feel very sorry for those who still think lottery, sockets, mets, dbs from monsters are random. It is not! Does somebody learn math at school? Ok, ill explain my theory, that you could understand the pattern of possibilities. Lets say we have a blue, red, and two green balls in a box. You must draw one. What is the possibility you draw a red one? it is 25% , or 1/4 . Becouse a red ball is one of four. How much chances we have to draw a green ball? The chances are 50% = 2/4 = 1/2 ....
Random
10/12/2008 - Guild Wars - 16 Replies
Hi, bin neu im Scripten... Will bei meinen kleinen Bot ein Recconect-Feature einbauen. Nun hab ich aber das Problem: Ich kriegs nicht hin das sich mein Bot nach einer Random Zeit ausloggt. Er loggt sich immer gleich aus.. Cu, N(ext)B(ot)A(rena)
i put this here at random
04/22/2008 - Say Hello - 0 Replies
hi all. I really have nothing better to do, so hi



All times are GMT +1. The time now is 03:08.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.