Zippo89 Posted January 23, 2018 Share Posted January 23, 2018 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 More sharing options...
Developers Jos Posted January 23, 2018 Developers Share Posted January 23, 2018 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 Xandy 1 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 More sharing options...
Zippo89 Posted January 23, 2018 Author Share Posted January 23, 2018 Hey Jos thanks for your answer so far. I didnt really understand what you mean with the _Excel udf's to manipulate excel file content or how to use ClipGet. But i will check the function first and try to understand. Link to comment Share on other sites More sharing options...
Zippo89 Posted January 23, 2018 Author Share Posted January 23, 2018 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 More sharing options...
aleph01 Posted January 24, 2018 Share Posted January 24, 2018 (edited) 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 January 24, 2018 by aleph01 Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now