Jump to content
Sign in to follow this  
rec0il

Problem witch _StringRepeat

Recommended Posts

rec0il

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
DW1

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
PsaltyDS

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
PsaltyDS

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
rec0il

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
DW1

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
rec0il

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.