hallo zusammen,
bevor die familie gleich mein ganzes wochenende belagert, habe ich noch schnell fragen zu map coding und moeglichkeiten hierin.
ich poste ein voll funktionsfaehiges script. es laeuft und tut genau das was es soll, aber es ist viel zu lang und bislang sind alle versuche es irgendwie zu kuerzen gescheitert. ich habe viel zeit mit versuchen das irgendwie in einer 'map' zu verschachteln verbracht und dann damit regeln zu verfassen womit die map arbeiten soll. das ganze scheiterte daran, dass ich die map von Kanashius aus einem meiner letzten thema weiter getestet habe, aber irgendwie gar nicht verstehe wo ich was genau aendern muss damit ich es erweitern oder veraendern kann. damit ich aber nicht ungluecklich werde habe ich es dann manuell geschrieben, so das es genau das tut was es tun soll gemaess den regeln die ich dem ganzen mitgegeben habe.
es handelt sich um die verwendung eines sog. magischen quadrates (das einfachste was es gibt) ... zu finden in youtube unter dem suchbegriff:
"12 x 12 Magic Square! Easiest Method ! Don't miss !" ( youtube.com/watch?v=HBd8ZM6aEOw )
also das ist meine ini datei die ich mittels einer map verwenden moechte. ich habe also einen text geschrieben mit 144 woertern und habe ihn dann gemaess diesem magischen quadrat von den worten her angeordnet, damit ich dann durch das script den richtigen text wieder anzeigen lassen kann. (ja, es sind alles nur spielereien)
auf jeden fall habe ich versucht die felder abzurufen und an der entsprechenden stelle wieder einzufuegen. klappt alles prima, aber sind halt 144 zeilen in einer For-To-Next-Schleife und jegliche versuche irgendwo einen zaehler einzubauen sind gescheitert, weil es auch unregelmaessig ist, aber seht selbst:
ini datei:
[DATA]
key01=1.2.3.141.140.139.138.137.136.10.11.12
key02=13.14.15.129.128.127.126.125.124.22.23.24
key03=25.26.27.117.116.115.114.113.112.34.35.36
key04=108.107.106.40.41.42.43.44.45.99.98.97
key05=96.95.94.52.53.54.55.56.57.87.86.85
key06=84.83.82.64.65.66.67.68.69.75.74.73
key07=72.71.70.76.77.78.79.80.81.63.62.61
key08=60.59.58.88.89.90.91.92.93.51.50.49
key09=48.47.46.100.101.102.103.104.105.39.38.37
key10=109.110.111.33.32.31.30.29.28.118.119.120
key11=121.122.123.21.20.19.18.17.16.130.131.132
key12=133.134.135.9.8.7.6.5.4.142.143.144
Alles anzeigen
AutoIT-script:
#include <MsgBoxConstants.au3>
#include <Array.au3>
#comments-start
als erstes holen wir uns die einzig _richtige_ loesung aus einer ini datei zum spaeteren vergleich:
#comments-end
Global $ini = @ScriptDir & "\magic.ini"
Global $iniOutput[1][1]
Global $sections = IniReadSectionNames($ini)
For $a = 1 To UBound($sections) - 1
$keys = IniReadSection($ini, $sections[$a])
Redim $iniOutput[UBound($keys)][12]
For $b = 1 To UBound($keys) - 1
$data = StringSplit($keys[$b][1], '.')
$iniOutput[$b][0] = $data[1]
$iniOutput[$b][1] = $data[2]
$iniOutput[$b][2] = $data[3]
$iniOutput[$b][3] = $data[4]
$iniOutput[$b][4] = $data[5]
$iniOutput[$b][5] = $data[6]
$iniOutput[$b][6] = $data[7]
$iniOutput[$b][7] = $data[8]
$iniOutput[$b][8] = $data[9]
$iniOutput[$b][9] = $data[10]
$iniOutput[$b][10] = $data[11]
$iniOutput[$b][11] = $data[12]
Next
Next
_ArrayDisplay($iniOutput) ; dies ist nur ein test zur kontrolle der daten!
_ArrayDelete($iniOutput, 0) ; wir loeschen die leere zeile am anfang des arrays
_ArrayDisplay($iniOutput) ; dies ist nur ein test zur kontrolle der daten!
Global $text
$text = "dieses kleine aber ihr und testen zu scripte kleine einen total konfus " & @CRLF & _
"gewirbelten satz durch sortieren. zu woerter ganzen die dabei lesbaren string bzw. " & @CRLF & _
"array verwandeln. es auch es damit muss stehen eigentlich mal zwoelf rasters " & @CRLF & _
"wort richtige das magisches quadrat dar. es ist das dann um muss " & @CRLF & _
"stehen wort welches es im internet zu finden gibt. in vorher ganze " & @CRLF & _
"das habe ich in jeweils zwoelf reihen und zwoelf somit spalten. zwoelf " & @CRLF & _
"jeweils in worten sind es dann insgesamt 144 worte. worten zwoelf aus " & @CRLF & _
"also besteht es libre office calc ausrechen lassen wo was quadrat magische " & @CRLF & _
"simpelste bzw. einfachste eine ini datei zu schreiben wo ein stellt und " & @CRLF & _
"aus dem text zwoelf eines prinzip dem auf basiert einen sinn ergibt. " & @CRLF & _
"AutoIT hilft dann einen in wieder map ini eine ich finde das " & @CRLF & _
"immer so toll soll script test AutoIT feine durchaus hoffentlich dann auch!" & @CRLF
;ConsoleWrite($text)
$arr_text = StringSplit($text, " ")
_ArrayDisplay($arr_text, "text jumble")
#comments-start
jetzt folgt der manuelle versuch die daten zu sortieren. ... soviel vorab, es klappt!
#comments-end
Local $result[UBound($arr_text)]
;ConsoleWrite("-----------"&"ini Array lookup"&"-----------"&@crlf)
For $i = 0 To UBound($iniOutput) - 1 Step 1
For $j = 0 To UBound($iniOutput, 2) - 1 Step 1
;ConsoleWrite("Access $iniOutput["&$i&"]["&$j&"]: "&$iniOutput[$i][$j]&@crlf)
;>>>>>>>>>>>>>>>>> If $iniOutput[$i][$j] = "5" Then $result[2] = $arr_text[140] ; <<<<<<<<<<<<<<<< syntax zur manuellen funktion
If $iniOutput[$i][$j] = "1" Then $result[1] = $arr_text[1]
If $iniOutput[$i][$j] = "2" Then $result[2] = $arr_text[2]
If $iniOutput[$i][$j] = "3" Then $result[3] = $arr_text[3]
If $iniOutput[$i][$j] = "4" Then $result[4] = $arr_text[141]
If $iniOutput[$i][$j] = "5" Then $result[5] = $arr_text[140]
If $iniOutput[$i][$j] = "6" Then $result[6] = $arr_text[139]
If $iniOutput[$i][$j] = "7" Then $result[7] = $arr_text[138]
If $iniOutput[$i][$j] = "8" Then $result[8] = $arr_text[137]
If $iniOutput[$i][$j] = "9" Then $result[9] = $arr_text[136]
If $iniOutput[$i][$j] = "10" Then $result[10] = $arr_text[10]
If $iniOutput[$i][$j] = "11" Then $result[11] = $arr_text[11]
If $iniOutput[$i][$j] = "12" Then $result[12] = $arr_text[12]
If $iniOutput[$i][$j] = "13" Then $result[13] = $arr_text[13]
If $iniOutput[$i][$j] = "14" Then $result[14] = $arr_text[14]
If $iniOutput[$i][$j] = "15" Then $result[15] = $arr_text[15]
If $iniOutput[$i][$j] = "16" Then $result[16] = $arr_text[129]
If $iniOutput[$i][$j] = "17" Then $result[17] = $arr_text[128]
If $iniOutput[$i][$j] = "18" Then $result[18] = $arr_text[127]
If $iniOutput[$i][$j] = "19" Then $result[19] = $arr_text[126]
If $iniOutput[$i][$j] = "20" Then $result[20] = $arr_text[125]
If $iniOutput[$i][$j] = "21" Then $result[21] = $arr_text[124]
If $iniOutput[$i][$j] = "22" Then $result[22] = $arr_text[22]
If $iniOutput[$i][$j] = "23" Then $result[23] = $arr_text[23]
If $iniOutput[$i][$j] = "24" Then $result[24] = $arr_text[24]
If $iniOutput[$i][$j] = "25" Then $result[25] = $arr_text[25]
If $iniOutput[$i][$j] = "26" Then $result[26] = $arr_text[26]
If $iniOutput[$i][$j] = "27" Then $result[27] = $arr_text[27]
If $iniOutput[$i][$j] = "28" Then $result[28] = $arr_text[117]
If $iniOutput[$i][$j] = "29" Then $result[29] = $arr_text[116]
If $iniOutput[$i][$j] = "30" Then $result[30] = $arr_text[115]
If $iniOutput[$i][$j] = "31" Then $result[31] = $arr_text[114]
If $iniOutput[$i][$j] = "32" Then $result[32] = $arr_text[113]
If $iniOutput[$i][$j] = "33" Then $result[33] = $arr_text[112]
If $iniOutput[$i][$j] = "34" Then $result[34] = $arr_text[34]
If $iniOutput[$i][$j] = "35" Then $result[35] = $arr_text[35]
If $iniOutput[$i][$j] = "36" Then $result[36] = $arr_text[36]
If $iniOutput[$i][$j] = "37" Then $result[37] = $arr_text[108]
If $iniOutput[$i][$j] = "38" Then $result[38] = $arr_text[107]
If $iniOutput[$i][$j] = "39" Then $result[39] = $arr_text[106]
If $iniOutput[$i][$j] = "40" Then $result[40] = $arr_text[40]
If $iniOutput[$i][$j] = "41" Then $result[41] = $arr_text[41]
If $iniOutput[$i][$j] = "42" Then $result[42] = $arr_text[42]
If $iniOutput[$i][$j] = "43" Then $result[43] = $arr_text[43]
If $iniOutput[$i][$j] = "44" Then $result[44] = $arr_text[44]
If $iniOutput[$i][$j] = "45" Then $result[45] = $arr_text[45]
If $iniOutput[$i][$j] = "46" Then $result[46] = $arr_text[99]
If $iniOutput[$i][$j] = "47" Then $result[47] = $arr_text[98]
If $iniOutput[$i][$j] = "48" Then $result[48] = $arr_text[97]
If $iniOutput[$i][$j] = "49" Then $result[49] = $arr_text[96]
If $iniOutput[$i][$j] = "50" Then $result[50] = $arr_text[95]
If $iniOutput[$i][$j] = "51" Then $result[51] = $arr_text[94]
If $iniOutput[$i][$j] = "52" Then $result[52] = $arr_text[52]
If $iniOutput[$i][$j] = "53" Then $result[53] = $arr_text[53]
If $iniOutput[$i][$j] = "54" Then $result[54] = $arr_text[54]
If $iniOutput[$i][$j] = "55" Then $result[55] = $arr_text[55]
If $iniOutput[$i][$j] = "56" Then $result[56] = $arr_text[56]
If $iniOutput[$i][$j] = "57" Then $result[57] = $arr_text[57]
If $iniOutput[$i][$j] = "58" Then $result[58] = $arr_text[87]
If $iniOutput[$i][$j] = "59" Then $result[59] = $arr_text[86]
If $iniOutput[$i][$j] = "60" Then $result[60] = $arr_text[85]
If $iniOutput[$i][$j] = "61" Then $result[61] = $arr_text[84]
If $iniOutput[$i][$j] = "62" Then $result[62] = $arr_text[83]
If $iniOutput[$i][$j] = "63" Then $result[63] = $arr_text[82]
If $iniOutput[$i][$j] = "64" Then $result[64] = $arr_text[64]
If $iniOutput[$i][$j] = "65" Then $result[65] = $arr_text[65]
If $iniOutput[$i][$j] = "66" Then $result[66] = $arr_text[66]
If $iniOutput[$i][$j] = "67" Then $result[67] = $arr_text[67]
If $iniOutput[$i][$j] = "68" Then $result[68] = $arr_text[68]
If $iniOutput[$i][$j] = "69" Then $result[69] = $arr_text[69]
If $iniOutput[$i][$j] = "70" Then $result[70] = $arr_text[75]
If $iniOutput[$i][$j] = "71" Then $result[71] = $arr_text[74]
If $iniOutput[$i][$j] = "72" Then $result[72] = $arr_text[73]
If $iniOutput[$i][$j] = "73" Then $result[73] = $arr_text[72]
If $iniOutput[$i][$j] = "74" Then $result[74] = $arr_text[71]
If $iniOutput[$i][$j] = "75" Then $result[75] = $arr_text[70]
If $iniOutput[$i][$j] = "76" Then $result[76] = $arr_text[76]
If $iniOutput[$i][$j] = "77" Then $result[77] = $arr_text[77]
If $iniOutput[$i][$j] = "78" Then $result[78] = $arr_text[78]
If $iniOutput[$i][$j] = "79" Then $result[79] = $arr_text[79]
If $iniOutput[$i][$j] = "80" Then $result[80] = $arr_text[80]
If $iniOutput[$i][$j] = "81" Then $result[81] = $arr_text[81]
If $iniOutput[$i][$j] = "82" Then $result[82] = $arr_text[63]
If $iniOutput[$i][$j] = "83" Then $result[83] = $arr_text[62]
If $iniOutput[$i][$j] = "84" Then $result[84] = $arr_text[61]
If $iniOutput[$i][$j] = "85" Then $result[85] = $arr_text[60]
If $iniOutput[$i][$j] = "86" Then $result[86] = $arr_text[59]
If $iniOutput[$i][$j] = "87" Then $result[87] = $arr_text[58]
If $iniOutput[$i][$j] = "88" Then $result[88] = $arr_text[88]
If $iniOutput[$i][$j] = "89" Then $result[89] = $arr_text[89]
If $iniOutput[$i][$j] = "90" Then $result[90] = $arr_text[90]
If $iniOutput[$i][$j] = "91" Then $result[91] = $arr_text[91]
If $iniOutput[$i][$j] = "92" Then $result[92] = $arr_text[92]
If $iniOutput[$i][$j] = "93" Then $result[93] = $arr_text[93]
If $iniOutput[$i][$j] = "94" Then $result[94] = $arr_text[51]
If $iniOutput[$i][$j] = "95" Then $result[95] = $arr_text[50]
If $iniOutput[$i][$j] = "96" Then $result[96] = $arr_text[49]
If $iniOutput[$i][$j] = "97" Then $result[97] = $arr_text[48]
If $iniOutput[$i][$j] = "98" Then $result[98] = $arr_text[47]
If $iniOutput[$i][$j] = "99" Then $result[99] = $arr_text[46]
If $iniOutput[$i][$j] = "100" Then $result[100] = $arr_text[100]
If $iniOutput[$i][$j] = "101" Then $result[101] = $arr_text[101]
If $iniOutput[$i][$j] = "102" Then $result[102] = $arr_text[102]
If $iniOutput[$i][$j] = "103" Then $result[103] = $arr_text[103]
If $iniOutput[$i][$j] = "104" Then $result[104] = $arr_text[104]
If $iniOutput[$i][$j] = "105" Then $result[105] = $arr_text[105]
If $iniOutput[$i][$j] = "106" Then $result[106] = $arr_text[39]
If $iniOutput[$i][$j] = "107" Then $result[107] = $arr_text[38]
If $iniOutput[$i][$j] = "108" Then $result[108] = $arr_text[37]
If $iniOutput[$i][$j] = "109" Then $result[109] = $arr_text[109]
If $iniOutput[$i][$j] = "110" Then $result[110] = $arr_text[110]
If $iniOutput[$i][$j] = "111" Then $result[111] = $arr_text[111]
If $iniOutput[$i][$j] = "112" Then $result[112] = $arr_text[33]
If $iniOutput[$i][$j] = "113" Then $result[113] = $arr_text[32]
If $iniOutput[$i][$j] = "114" Then $result[114] = $arr_text[31]
If $iniOutput[$i][$j] = "115" Then $result[115] = $arr_text[30]
If $iniOutput[$i][$j] = "116" Then $result[116] = $arr_text[29]
If $iniOutput[$i][$j] = "117" Then $result[117] = $arr_text[28]
If $iniOutput[$i][$j] = "118" Then $result[118] = $arr_text[118]
If $iniOutput[$i][$j] = "119" Then $result[119] = $arr_text[119]
If $iniOutput[$i][$j] = "120" Then $result[120] = $arr_text[120]
If $iniOutput[$i][$j] = "121" Then $result[121] = $arr_text[121]
If $iniOutput[$i][$j] = "122" Then $result[122] = $arr_text[122]
If $iniOutput[$i][$j] = "123" Then $result[123] = $arr_text[123]
If $iniOutput[$i][$j] = "124" Then $result[124] = $arr_text[21]
If $iniOutput[$i][$j] = "125" Then $result[125] = $arr_text[20]
If $iniOutput[$i][$j] = "126" Then $result[126] = $arr_text[19]
If $iniOutput[$i][$j] = "127" Then $result[127] = $arr_text[18]
If $iniOutput[$i][$j] = "128" Then $result[128] = $arr_text[17]
If $iniOutput[$i][$j] = "129" Then $result[129] = $arr_text[16]
If $iniOutput[$i][$j] = "130" Then $result[130] = $arr_text[130]
If $iniOutput[$i][$j] = "131" Then $result[131] = $arr_text[131]
If $iniOutput[$i][$j] = "132" Then $result[132] = $arr_text[132]
If $iniOutput[$i][$j] = "133" Then $result[133] = $arr_text[133]
If $iniOutput[$i][$j] = "134" Then $result[134] = $arr_text[134]
If $iniOutput[$i][$j] = "135" Then $result[135] = $arr_text[135]
If $iniOutput[$i][$j] = "136" Then $result[136] = $arr_text[9]
If $iniOutput[$i][$j] = "137" Then $result[137] = $arr_text[8]
If $iniOutput[$i][$j] = "138" Then $result[138] = $arr_text[7]
If $iniOutput[$i][$j] = "139" Then $result[139] = $arr_text[6]
If $iniOutput[$i][$j] = "140" Then $result[140] = $arr_text[5]
If $iniOutput[$i][$j] = "141" Then $result[141] = $arr_text[4]
If $iniOutput[$i][$j] = "142" Then $result[142] = $arr_text[142]
If $iniOutput[$i][$j] = "143" Then $result[143] = $arr_text[143]
If $iniOutput[$i][$j] = "144" Then $result[144] = $arr_text[144]
Next
Next
_ArrayDisplay($result)
_ArrayDelete($result, 0) ; wir loeschen die leere zeile am anfang des arrays
_ArrayDisplay($result) ; dies ist nur ein test zur kontrolle der daten!
$corrected_text = _ArrayToString($result, " ")
MsgBox(0, "output", $corrected_text)
Alles anzeigen
also, ich hatte ein wert $k versucht als zaehler, aber es aenderte nicht wirklich etwas an der laenge, denn der auszugebene text springt ja wirklich durch die zeilen wie ein osterhase auf drogen. also ist zunaechst die erste frage:
1. kann der code durch clevere zaehler verkuerzt werden? wenn ja, wie und wo?
die zweite frage ist dann die nutzung einer map. also das ist fuer mich so undurchsichtig, dass ich nocht nicht mal weiss wie wo was ich genau brauche um eine verbindung der zeilennummern zur ini herzustellen um dann eine korrekte ausgabe zu erhalten. also zweite frage:
2. map? - ja gerne, aber wie? mit lerneffekt gerne gewuenscht.
leider muss ich nun das restliche wochenende aufs internet verzichten, denn wir bekommen gleich familien besuch und die bleiben das ganze osterfest. aber was macht man nicht alles fuer die familie.
das thema hier hat also keine eile, ich kann eh nicht vor montag/dienstag checken ob jemand geantwortet hat.
geniesst alle das osterfest.
bis bald.
bankesbusters
PS: eines meiner sachen habe ich selbst geregelt bekommen von meiner to-do-liste: zahlen mit ini einlesen, werte veraendern je spalte und dann weiterverwenden. hat erstaunlich einfach mehr oder weniger auf anhieb geklappt. also stueck fuer stueck lerne ich fleissig weiter.