Jump to content

Need help with InputBox


Zippo89
 Share

Recommended Posts

Hello mates, i have the following Problem. Im trying a long time now to find a possibility to set a varriable Number for use into the InputBox or somewhere else.

Im trying to loop a part of the script X ($Varriable_Number) times.

For Example:

Im using an Excelsheet in Cell x/y is the $Varriable_Number for this example we are using "6". These Number is copied with Send("^c").

Next Step would be Send("^v") into the InputBox or somwhere else to set the number as $Varriable_Number in the code.

The endresoult should be now that the loop runs "6" until the next code after starts.

 

But the Problem is that the script is stopped until InputBox gets an input, thats why i cant use Send("^v").

Is there any other option? Maybe InputBox isnt the right thing anyways because the script needs to automatically continue after the input and i cant use Send("{ENTER}") too.

 

My Code atm

Placeholder()

Func Placeholder()

            Some Code before

                       .

                       .

$Placeholder_Number = InputBox("", "The Loop should run "$Varriable_Number" Times", 0)

For $Loopstart = 1 To $Placeholder_Number


Local $Loopstart = 1

While $Loopstart <= $Placeholder_Number 


;CODE HERE

$Loopstart = $Loopstart + 1

WEnd

Next
EndFunc
                       .

                       .
                       
                Some Code After

If you need any more examples or meanings i could try to explane it more detailed :).

Would be really nice if anyone could help me or give me some more ideas to fix the problem.

Thanks alot!

Link to comment
Share on other sites

  • Developers

Why use an inputbox and paste to it with your script when you can simply read the content of the Clipboard with ClipGet()?

Also might be better to look at the _Excel udf's to manipulate excel file content.

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

When i understand it correctly ... it should be like this?

Placeholder()

Func Placeholder()

            Some Code before

                       .

;Copy the Cell in Excel with Send("^c") / Example "6" to have a the number on the clipboard

$Varriable_Number = ClipGet()
;$Varriable_Number = "6" in this example

For $Loopstart = 1 To $Varriable_Number


Local $Loopstart = 1

While $Loopstart <= $Placeholder_Number 


;CODE HERE

$Loopstart = $Loopstart + 1

WEnd

Next
EndFunc
                       .

                       .
                       
                Some Code After

So now it should loop ;CODE HERE 6 times and when its done start with -> Some Code After. Correct? :)

 

Link to comment
Share on other sites

Your For/Next loop looks odd.  It automatically increments from 1 to $Variable_Number.  You do not need to redefine Local $Loopstart = 1, and you do not need to increment with your line $Loopstart = $Loopstart + 1.  The way you have it, it looks like $Loopstart will be set to 1 in every loop, then incremented to 2 if the While statement is true, then at the Next, it will increment to 3.  Every loop after the first will be loop 3.  You will never reach 6 and end the loop.  Infinite 3rd loop if your While statement is true.

If the While statement is not true, every loop will reset $Loopstart to 1 and the Next will increment it to 2.  So in that case, you have an infinite 2nd loop.

Somebody please correct me if I'm wrong.

Edited by aleph01

Meds.  They're not just for breakfast anymore. :'(

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