Sign in to follow this  
Followers 0
rec0il

Problem witch _StringRepeat

12 posts in this topic

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?

Share this post


Link to post
Share on other sites



you are calling a string repeat on the return of a function that returns nothing... am I missing something here?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


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

Share this post


Link to post
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¥À ÅÕ½Ðí¹ÅÕ½Ðì°À°À

Share this post


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

Share this post


Link to post
Share on other sites

Damn aquatic, flightless birds keep beating me to the punch. LOL

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ok, now work :) thx :blink:

btw: this is my first script :P

Edited by rec0il

Share this post


Link to post
Share on other sites

We all started somewhere. You are doing well :) Keep up the good autoit

Share this post


Link to post
Share on other sites

Damn aquatic, flightless birds keep beating me to the punch. LOL

Has Paulie been picking on you again?

:)


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

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
Sign in to follow this  
Followers 0