Jump to content

Help on a script


Recommended Posts

Why doesn't this work?

#include <array.au3>
#include <string.au3>
#include <GUIConstants.au3>


GUICreate ( "title" , 800 , 600 ); will create a dialog box that when displayed is centered
$RESULT = GUICtrlCreateInput("", 110, 40, 100, 20)

$Start = GUICtrlCreateButton ("OK",  60, 70, 50)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
GUISetState (@SW_SHOW)

Global $LETTERS[6]
$LETTERS[0] = "a"
$LETTERS[1] = "b"
$LETTERS[2] = "c"
$LETTERS[3] = "d"
$LETTERS[4] = "e"
$LETTERS[5] = "f"

$END_RESULT = ""

For $x = 1 to StringLen($RESULT)
    $i = StringMid($RESULT,$x,1)
    $a = Asc ($i)
       If $a = 97 Then
        $a_i = $LETTERS[5]
        $END_RESULT = $END_RESULT & $a_i
       EndIf
Next

While 1
    $msg = GUIGetMsg()
       Select
           Case $MSG = $GUI_EVENT_CLOSE
            Exit
           Case $msg = $Start
               MsgBox(0, '', $END_RESULT)
       EndSelect
Wend

I have changed the original code a bit. What I want is when I press ok it shows END_RESULT

Edited by eekhoorn12
Link to comment
Share on other sites

#include <array.au3>
#include <string.au3>
#include <GUIConstants.au3>


GUICreate("title", 800, 600); will create a dialog box that when displayed is centered
$RESULT = GUICtrlCreateInput("", 110, 40, 100, 20)

$Start = GUICtrlCreateButton("OK", 60, 70, 50)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
GUISetState(@SW_SHOW)

Global $LETTERS[6]
$LETTERS[0] = "a"
$LETTERS[1] = "b"
$LETTERS[2] = "c"
$LETTERS[3] = "d"
$LETTERS[4] = "e"
$LETTERS[5] = "f"

$END_RESULT = ""

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $Start
            $s_Result = GUICtrlRead($RESULT)
            For $x = 1 To StringLen($s_Result)
                $i = StringMid($s_Result, $x, 1)
                $a = Asc($i)
                If $a = 97 Then
                    $a_i = $LETTERS[5]
                    $END_RESULT = $END_RESULT & $a_i
                EndIf
            Next
         MsgBox(0, '', $END_RESULT)
   EndSelect
WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I took a stab at what you were trying to do..

#include <array.au3>
;#include <string.au3>
#include <GUIConstants.au3>


GUICreate("title", 800, 600); will create a dialog box that when displayed is centered
$RESULT = GUICtrlCreateInput("", 110, 40, 100, 20)
$Start = GUICtrlCreateButton("OK", 60, 70, 50)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
GUISetState(@SW_SHOW)

Global $LETTERS[6]
$LETTERS[0] = "a"
$LETTERS[1] = "b"
$LETTERS[2] = "c"
$LETTERS[3] = "d"
$LETTERS[4] = "e"
$LETTERS[5] = "f"

$END_RESULT = ""


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Start
            $data = GUICtrlRead($RESULT)
            $END_RESULT = $data & compute($data)
            MsgBox(0, '', $END_RESULT)
    EndSelect
WEnd
Func compute($var)
    For $x = 1 To StringLen($var)
        $i = StringMid($var, $x, 1)
        $a = Asc($i)
        If $a = 97 Then
            $a_i = $LETTERS[5]
            Return $a_i
        EndIf
    Next
EndFunc  ;==>compute

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...