Jump to content

Problem witch _StringRepeat


 Share

Recommended Posts

Hi. This is my first post in AutoIt Forum. I hope will my English is not bad :)

To The Problem:

I have this simple code:

WinActivate ("AutoIt Help")
            $powt = _StringRepeat (omg(), GuiCtrlRead($Input2))
            Func omg()
                    If WinActive ("AutoIt Help") Then
                        Sleep (1000)
                        Send ("{enter}")
                        Send (GuiCtrlRead($Input1))
                        Send ("{enter}")
                        Sleep (2000)
                    EndIf
            EndFunc

And i do not know why "_StringRepeat" not work.

The action repeats herself only once, even if in $Input2 is written 2 or another number. Why?

Link to comment
Share on other sites

Hi. This is my first post in AutoIt Forum. I hope will my English is not bad :P

To The Problem:

I have this simple code:

WinActivate ("AutoIt Help")
            $powt = _StringRepeat (omg(), GuiCtrlRead($Input2))
            Func omg()
                    If WinActive ("AutoIt Help") Then
                        Sleep (1000)
                        Send ("{enter}")
                        Send (GuiCtrlRead($Input1))
                        Send ("{enter}")
                        Sleep (2000)
                    EndIf
            EndFunc

And i do not know why "_StringRepeat" not work.

The action repeats herself only once, even if in $Input2 is written 2 or another number. Why?

An Input control returns a string vice a number. Try this:

$powt = _StringRepeat (omg(), Number(GuiCtrlRead($Input2)))oÝ÷ Ù*&z)íz¹Ú­ _ºw-쩽ªâi¹^·*^rïz»"¢{¢¼¨¹»­©òP1_ºw-ìv÷öÛ(Ýý²Æz»hë-jË.쨺ÈhºWZ²±·ÁªÞ¡ûazö«¦åzÜ©{*.­ªÞ¥«,xH:²}ýµªiyªí¡·­êk¡¹^«y«­¢+Ø¥¹±Õ±ÐíÍÑÉ¥¹¹ÔÌÐì)
½¹Í½±]ɥѡ}MÑÉ¥¹IÁÐ ÅÕ½ÐíQÍÐÅÕ½Ðì°Ô¤µÀì1¤)
½¹Í½±]ɥѡ}MÑÉ¥¹IÁÐ ÅÕ½ÐíQÍÐÅÕ½Ðì°ÅÕ½ÐìÔÅÕ½Ð줵Àì1¤

Since omg() returns nothing as danwilli said, what exactly got repeated once? Did you mean _StringRepeat() to actually run the omg() funtion repeatedly (it doesn't do that).

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Did you see the edit at the bottom of my post? The _StringRepeat() will not call omg() more than once to get the string to be repeated. Use a For/Next loop if you need to repeat the function.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Now i see :)

i try For/Next and this too not work.

WinActivate ("AutoIt Help")
            For $s = 5 to 1 Step -1
            Func omg()
                    If WinActive ("AutoIt Help") Then
                        Sleep (1000)
                        Send ("{enter}")
                        Send (GuiCtrlRead($Input1))
                        Send ("{enter}")
                        Sleep (2000)
                    EndIf
            EndFunc
            Next
            ToolTip ("End",0,0)oÝ÷ Ú+kÊ«¨´Û¦mêƺ ­®T^7èéºÝªºZÛh¢z-Âä6"±çÚòÿ5ìmjwm+-¢è·
+«­¢+Ø]¥¹Ñ¥ÙÑ ÅÕ½ÐíÕѽ%Ð!±ÀÅÕ½Ðì¤($$%½ÈÀÌØíÌô9յȡե
ÑɱI ÀÌØí%¹ÁÕÐȤ¤¤Ñ¼ÄMÑÀ´Ä(Õ¹½µ ¤(%]¥¹Ñ¥Ù ÅÕ½ÐíÕѽ%Ð!±ÀÅÕ½Ðì¤Q¡¸(M±À ÄÀÀÀ¤(M¹ ÅÕ½Ðíí¹ÑÉôÅÕ½Ðì¤(M¹¡Õ¥
ÑɱI ÀÌØí%¹ÁÕÐĤ¤(M¹ ÅÕ½Ðíí¹ÑÉôÅÕ½Ðì¤(M±À ÈÀÀÀ¤(¹%(¹Õ¹($$%9áÐ($$%Q½½±Q¥À ÅÕ½Ðí¹ÅÕ½Ðì°À°À
Link to comment
Share on other sites

Are you looking to repeat the function X times like this?

WinActivate("AutoIt Help")
For $s = Number(GUICtrlRead($Input2))) To 1 Step - 1
    omg()
Next
    Func omg ()
        If WinActive("AutoIt Help") Then
            Sleep(1000)
            Send("{enter}")
            Send(GUICtrlRead($Input1))
            Send("{enter}")
            Sleep(2000)
        EndIf
    EndFunc   ;==>omg
Next
ToolTip("End", 0, 0)

You don't want to declare the function in a Next loop like you were.

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...