Register for your free account! | Forgot your password?

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

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

Advertisement



beliebiege variable aus array

Discussion on beliebiege variable aus array within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2009
Posts: 2
Received Thanks: 0
beliebiege variable aus array

hallo zusammen.
ich arbeite zur zeit an einem kleinen programm und dafür ist es nötig, dass autoit vergleicht, ob eine bestimmte variable innerhalb eines array vorhanden ist.
das array enthält zum bsp variabeln mit den werten: 1, 2 und 3.
jetzt soll überprüft werden, ob die variable a im array ist (a=1, z.B.).

das array hab ich natürlich schon erstellt (1dimensional), nur der abgleich ist knifflig. ich habs mit
Code:
if $a= $array_items Then
$score= $score+1
EndIf
probiert, das funzt aber nicht, ich denke dann müsste wirklich a=1, 2 und 3 sein..
am besten wäre es natürlich, wenn das ganze mit mehreren variablen funktionieren würde, die dann aber nicht doppelt gezählt werden dürften. vllt könnte man dafür die entsprechende variable nach erfolgreichem abgleich aus dem array löschen?

hoffe ich habe mich nicht zu wirr ausgedrückt, und danke im vorraus!
mfg
luddi
luddi is offline  
Old 04/21/2010, 03:12   #2
 
elite*gold: 2
Join Date: Oct 2006
Posts: 218
Received Thanks: 138
Am besten ist es du zeigst den kompletten Quellcode oder zumindest einen eindeutigen
Ausschnitt, da kann man besser helfen.

Code:
For $i = 0 to Ubound($Array) - 1
If $a = $Array[$i] then
$score = $score+1
Exitloop
EndIf
else
Next
Mankana is offline  
Old 04/21/2010, 14:21   #3
 
| Moep |'s Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 1,079
Received Thanks: 438
Code:
#include <Array.au3>

Local $avArray[5] = [0, 1, 2, 1, 0]
Local $aiResult = _ArrayFindAll($avArray, 0)
_ArrayDisplay($avArray, "$avArray")
_ArrayDisplay($aiResult, "Ergebnis der Suche des Wertes 0 in $avArray")
oder
Code:
#include <Array.au3>

;===============================================================================
; Beispiel 1 (verwendet ein 1D Array)
;===============================================================================
Local $avArray[6] = [ _
        "String0, SubString0", _
        "String1, SubString1", _
        "String2, SubString2", _
        "String3, SubString3", _
        "String4, SubString4", _
        "String5, SubString5"]

_ArrayDisplay($avArray, "$avArray")

$sSearch = InputBox("_ArraySearch() Demo", "Welcher String soll gesucht werden?")
If @error Then Exit

$iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1)
If @error Then
    MsgBox(0, "Nicht gefunden", '"' & $sSearch & '" wurde in dem Array nicht gefunden.')
Else
    MsgBox(0, "Gefunden", '"' & $sSearch & '" wurde in dem Array an Stelle ' & $iIndex & " gefunden.")
EndIf
| Moep | is offline  
Old 04/21/2010, 17:30   #4
 
elite*gold: 0
Join Date: Jan 2009
Posts: 2
Received Thanks: 0
ok, das sieht doch schonmal vielversprechend aus. werde mich mal einlesen und es ausprobieren wenn ich zeit hab. danke!

den ganzen code hier reinzuklatschen wäre etwas viel, was für einen ausschnitt meinst du denn? wo ich das array erstelle?


edit:

ok, ich habe jetzt folgende codes:

array erstellen:
Code:
Dim $array_recallitems[15]; recall-items:
$array_recallitems[0] = FileReadLine ($file_recallitems, 1)
$array_recallitems[1] = FileReadLine ($file_recallitems, 2)
$array_recallitems[2] = FileReadLine ($file_recallitems, 3)
;geht eigtl bis [15]
gesuchte variabele setzen:
(text aus input)
Code:
$recall1 = GUICtrlRead (21)
$recall2 = GUICtrlRead (22)
$recall3 = GUICtrlRead (23)
;geht auch eigtl bis 15
und jetzt möchte ich vergleichen, ob eine der eingegebenen wörter in einem der 3 (eigtl 15) input-feldern übereinstimmt mit einem der 3 (eigtl 15) strings aus dem array:
Code:
Local $aiResult = _ArrayFindAll ($array_recallitems, $recall1)
if $recall1 = $aiResult Then ; ?!
$recallscore = $recallscore+1
EndIf
;hier erstmal nur fürs erste wort..


das ganze funktioniert so aber leider nicht. ich sollte vllt dazu sagen, dass ich noch nicht soo viel ahnung habe vom programmieren/coden..




zweiter versuch:
alles ganu wie oben, außer die abfrage der übereinstimmung. die sieht jetzt so aus:
Code:
For $i = 0 to Ubound($array_recallitems) - 1
If $recall1 = $array_recallitems[$i] then
$recallscore = $recallscore+1
Exitloop
EndIf
Next
klappt aber auch nicht. in der ausgabe
Code:
MsgBox (0, "test", $recallscore & "correct")
zeigt der mir jetzt immer 1correct an, egal, was ich eingebe..

was komisch ist, weil es meiner meinung nach eigtl das selbe ist wie
Code:
Dim $Array[3]
$Array[0]=1
$Array[1]=2
$Array[2]=3

$a=2
$score=0

For $i = 0 to Ubound($Array) - 1
If $a = $Array[$i] then
$score = $score+1
MsgBox (0, "test", $score)
Exitloop
EndIf
Next
und das funktioniert super mit a=1,2 und/oder 3..
luddi is offline  
Reply


Similar Threads Similar Threads
Problem error: Subscript used whit non-Array variable "
08/26/2010 - Last Chaos - 1 Replies
hey leute, seitdem mein laptop ein windows update gemacht hat funktioniert der ultra bot nicht. es dann kommt immer die fehlermeldung " error: Subscript used whit non-Array variable " vor diesem update ging der bot noch.
Array of Bytes
10/02/2009 - Dekaron - 1 Replies
Hi, could someone please post the array of bytes needed for: -Vac -Non-Agro -Speed -Map Hack -Far Eye -Zoom -Auto Pots And if anyone is even more generous, could you PM me the AoB for the skill hacks as well. I don't have much to give back seeing as this is a forum, but i will give you my thanks.
Variable und down/up befehl
09/23/2009 - AutoIt - 0 Replies
Hallo! Also ich habe folgendes Problem: Ich will meine variable ($taste1) und den "{down}" tastendruck ausführen aber wie krieg ich das hin also möchte das die variable taste1 runtergedrückt wird bis ich sie wieder mit "{up}" loslasse. Allerdings weis ich es bei up auch nicht Mein script sieht bisher so aus Send($taste1 "{down}") Thx schonmal in vorraus:confused::( ok habs jetzt nach langer zeit =) ich hab es einfach über eine if schleife gemacht Ok Funktioniert doch net hat keiner...
How do I add a variable
08/21/2009 - CO2 Private Server - 4 Replies
Couldn't find a guide when I searched. I want to make a variable so it will check how many times the player has already used unknown man. I know how to use the variable, but just don't know how to make it. Oh yea this is LOTF
1D bzw. 2D Array mit Processlist
12/31/2008 - Guild Wars - 3 Replies
Die Frage ist ganz simpel. Wie kann ich in einer ListBox ein 1D bzw. 2D Array mit Processlist anzeigen? Das Bsp. in der Hilfe bringt mich auch nicht wirklich weiter.



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


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.