-1

私のGUIとプログラムは機能しますが、期待どおりではありません。

このプログラムは、3つのカテゴリに対して1〜10の例の単語の形式でユーザー入力を受け取るように作成しました。

その目的は、すべてのトライアド順列を含むテキストファイルを出力することです。

残念ながら、トライアドではない順列を出力しています。

それはあまりコードではありません、なぜこれが起こっているのですか?

元。

GUI:

色番号ギリシャ文字

レッドワンアルファブルーツーベータ

出力:

レッドワンアルファレッドワンベータレッドツーアルファレッドツーベータブルーワンアルファブルーワンベータブルーツーアルファブルーツーベータ

////////////////////////////////////////////////// //////////////////////////////////

#include <GUIConstantsEx.au3>

$windowWidth = 600
$windowHeight = 430

$textFieldVertSpacing = 30

GUICreate("Semantic Intuition/Idea Naming Tool", $windowWidth, $windowHeight) 

GUISetBkColor (0xB0E2FF)

GUICtrlCreateLabel("Category A", 80, 10)
GUICtrlCreateLabel("Category B", 260, 10)
GUICtrlCreateLabel("Category C", 450, 10)

$categoryA = GUICtrlCreateInput("", (150*0)+(150/4)*1, 40, 150)
$categoryB = GUICtrlCreateInput("", (150*1)+(150/4)*2, 40)
$categoryC = GUICtrlCreateInput("", (150*2)+(150/4)*3, 40)

$example0 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80)
$example1 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*1)
$example2 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*2)
$example3 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*3)
$example4 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*4)
$example5 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*5)
$example6 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*6)
$example7 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*7)
$example8 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*8)
$example9 = GUICtrlCreateInput("", (150*0)+(150/4)*1, 80+$textFieldVertSpacing*9)

$example10 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80)
$example11 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*1)
$example12 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*2)
$example13 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*3)
$example14 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*4)
$example15 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*5)
$example16 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*6)
$example17 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*7)
$example18 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*8)
$example19 = GUICtrlCreateInput("", (150*1)+(150/4)*2, 80+$textFieldVertSpacing*9)

$example20 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80)
$example21 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*1)
$example22 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*2)
$example23 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*3)
$example24 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*4)
$example25 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*5)
$example26 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*6)
$example27 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*7)
$example28 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*8)
$example29 = GUICtrlCreateInput("", (150*2)+(150/4)*3, 80+$textFieldVertSpacing*9)

$generateTriadButton = GUICtrlCreateButton("Generate", ($windowWidth-100)/2, $windowHeight-40, 100)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Global $examplesA[10] = [$example0, $example1, $example2, $example3, $example4, $example5, $example6, $example7, $example8, $example9]
Global $examplesB[10] = [$example10, $example11, $example12, $example13, $example14, $example15, $example16, $example17, $example18, $example19]
Global $examplesC[10] = [$example20, $example21, $example22, $example22, $example24, $example25, $example26, $example27, $example28, $example29]

GUISetState(@SW_SHOW)                     


While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
         Case $generateTriadButton
            permutate()

            Exit
    EndSwitch

WEnd

Func permutate()

    $a = 0
    $b = 0
    $c = 0
    $x = 1

    $empty = ""

    $output = FileOpen(@ScriptDir & "\TriadOutput.txt", 2)

    While $a < 10
       while $b < 10
          while $c < 10


               ;MsgBox(0, "String length is:", StringLen($examplesA[$a]))
               If (StringStripWS(GUICtrlRead($examplesA[$a]), 8) <> "") AND (StringStripWS(GUICtrlRead($examplesB[$b]), 8) <> "") AND (StringStripWS(GUICtrlRead($examplesA[$a]), 8) <> "") Then

               FileWrite($output, $x)
               FileWrite($output, ")")
               FileWrite($output, " ")
               FileWrite($output, GUICtrlRead($examplesA[$a]))
               FileWrite($output, " ")
               FileWrite($output, GUICtrlRead($examplesB[$b]))
               FileWrite($output, " ")
               FileWrite($output, GUICtrlRead($examplesC[$c]))
               FileWrite($output, " ")
               FileWrite($output, @CRLF)

               $x = $x + 1

               EndIf

             $c = $c + 1
          WEnd
          $c = 0
          $b = $b + 1
       WEnd
       $b = 0
       $a = $a + 1
    WEnd

    FileClose($output)
EndFunc
4

1 に答える 1

1

典型的なコピペエラー。

最後の If ステートメント (94 行目) の 2 番目の $a を $c に置き換えるだけで、期待どおりに動作します...

これは、出力を検証することでわかります。問題は、3 つおきのテキスト フィールドが考慮されるが、他の 2 つの単語は問題なく機能することです。したがって、エラーは 3 番目のフィールドを担当する式 (条件) にある必要があります。そして、これはちょうど94行目です...

于 2012-12-05T08:25:03.707 に答える