gottygolly

For Loops and array

7 posts in this topic

#1 ·  Posted (edited)

Just making something for fun planning on making something cool with it (like a game) but I need to get this basic part down first.

It wants to keep stopping 1 short and not getting the last letter/number in the password and I know it's a simple task but I am too tired right now and won't have time tomorrow since it's my birthday.

Wondering if someone could help me out with this, appreciate it if you could!

#include <ButtonConstants.au3>
$gui = GUICreate("",640,480,-1,-1)
Opt("GUIOnEventMode",1)
GUISetOnEvent(-3,"_Exit")
$mo_p = "PasSwoRd?"
$mo = GUICtrlCreateLabel("Actual Password: "&$mo_p,5,5)
$check = GUICtrlCreateButton("Check",5,445,100,30)
GUICtrlSetOnEvent($check,"_Check")
$lt = ""
$test = GUICtrlCreateLabel("Current Letters: "&$lt,5,35)
$start = GUICtrlCreateButton("Start",535,445,100,30)
GUICtrlSetOnEvent($start,"_Start")
$gots = ""
$gottygolly = GUICtrlCreateLabel($gots,500,5,135,440,$BS_MULTILINE)
$state = "Idle..."
$st = GUICtrlCreateLabel($state,500,5,200)
GUISetState()
While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

Func _Start()
    $state = "Thinking..."
    GUICtrlSetData($st,$state)
    _Get_ER_Done()
EndFunc

Func _Get_ER_Done()
    $p = 1
    $pot = ""
    $ss = StringSplit($mo_p,"")
    $ti = ""
    $pi = $ss[0] + 1
    For $i = 0 To 255
        If $ss[$p] == Chr($i) And $p < $ss[0] Then
            $pot = $pot & Chr($i)
            $p += 1
            $i = 0
            Sleep(100)
        EndIf
        Sleep(10)
    Next
    $state = "Idle..."
    GUICtrlSetData($st,$state)
    MsgBox(0,"",$pot)
EndFunc

Func _Check()
    MsgBox(0,"","Work in progress")
EndFunc

 

Edited by gottygolly

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

gottygolly,

#include <ButtonConstants.au3>
#include <array.au3>
$gui = GUICreate("", 640, 480, -1, -1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "_Exit")
$mo_p = "PasSwoRd?"
$mo = GUICtrlCreateLabel("Actual Password: " & $mo_p, 5, 5)
$check = GUICtrlCreateButton("Check", 5, 445, 100, 30)
GUICtrlSetOnEvent($check, "_Check")
$lt = ""
$test = GUICtrlCreateLabel("Current Letters: " & $lt, 5, 35)
$start = GUICtrlCreateButton("Start", 535, 445, 100, 30)
GUICtrlSetOnEvent($start, "_Start")
$gots = ""
$gottygolly = GUICtrlCreateLabel($gots, 500, 5, 135, 440, $BS_MULTILINE)
$state = "Idle..."
$st = GUICtrlCreateLabel($state, 500, 5, 200)
GUISetState()
While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Start()
    $state = "Thinking..."
    GUICtrlSetData($st, $state)
    _Get_ER_Done()
EndFunc   ;==>_Start

Func _Get_ER_Done()
    $p = 1
    $pot = ""
    $ss = StringSplit($mo_p, "")
    _arraydisplay($ss)
    $ti = ""
    $pi = $ss[0] + 1
    For $i = 0 To 255
        If $p <= $ss[0] and $ss[$p] == Chr($i) Then  ; <----------------- note changes
            $pot = $pot & Chr($i)
            $p += 1
            $i = 0
            ;Sleep(100)
        EndIf
        ;Sleep(10)
    Next
    $state = "Idle..."
    GUICtrlSetData($st, $state)
    MsgBox(0, "", $pot)
EndFunc   ;==>_Get_ER_Done

Func _Check()
EndFunc   ;==>_Check
MsgBox(0, "", "Work in progress")

kylomas

Edited by kylomas
misread OP

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

I am not sure what this will be used for...with both the game tag and the password tag.

But since someone else gave their try...I will give mine.

#include <ButtonConstants.au3>
#include <array.au3>
$gui = GUICreate("", 640, 480, -1, -1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "_Exit")
$mo_p = "PasSwoRd?"
$mo = GUICtrlCreateLabel("Actual Password: " & $mo_p, 5, 5)
$check = GUICtrlCreateButton("Check", 5, 445, 100, 30)
GUICtrlSetOnEvent($check, "_Check")
$lt = ""
$test = GUICtrlCreateLabel("Current Letters: " & $lt, 5, 35)
$start = GUICtrlCreateButton("Start", 535, 445, 100, 30)
GUICtrlSetOnEvent($start, "_Start")
$gots = ""
$gottygolly = GUICtrlCreateLabel($gots, 500, 5, 135, 440, $BS_MULTILINE)
$state = "Idle..."
$st = GUICtrlCreateLabel($state, 500, 5, 200)
GUISetState()
While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Start()
    $state = "Thinking..."
    GUICtrlSetData($st, $state)
    _Get_ER_Done()
EndFunc   ;==>_Start

Func _Get_ER_Done()
    $p = 1
    $pot = ""
    $ss = StringSplit($mo_p, "")
    $ti = ""
    ;$pi = $ss[0] + 1
    For $i = 0 To 255
        If $p > UBound($ss) - 1 Then ExitLoop
        If $ss[$p] == Chr($i) Then
            ConsoleWrite('<!' & $ss[$p] & ' ' & $p & @CRLF)
            $pot = $pot & Chr($i)
            $p += 1
            $i = 0
            Sleep(100)
        EndIf
        Sleep(10)
    Next
    $state = "Idle..."
    GUICtrlSetData($st, $state)
    MsgBox(0, "", $pot)
    ConsoleWrite($pot)
EndFunc   ;==>_Get_ER_Done

Func _Check()
    MsgBox(0, "", "Work in progress")
EndFunc   ;==>_Check

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@‌nitekram - Could be password validation, regardless the code is to nonsensical to be of any use other than a learning exercise. 

Edited by kylomas
spelling

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Agreed. @kylomas, did you test your code that you posted, as I tried yours and it is now missing two characters not just the last one.

 

Edit

I see you changed it...

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

@nitekram - Yes, misread the OP...


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Thanks for the help guys!

Share this post


Link to post
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