Dan_555 Posted September 27, 2023 Share Posted September 27, 2023 (edited) Hi, it would be nice if you gave us a specific example of how it should behave. let say you have a text file with following content: hi there how are you my old friend when you call the function, do you want it to return "hi, there" then next time "how, are" and so on, always the next 2. here is an example of that one: Global $file="example.txt" for $x=1 to 3 ReadFiletoClip($x*2) MsgBox (270336,"Clipboard holds",ClipGet()) Next ;Send("^v") func ReadFiletoClip($st) local $tmp="" For $i = $st to $st+1 $tmp=$tmp & FileReadLine($file, $i) & @crlf Next Clipput($tmp) EndFunc Edited September 27, 2023 by Dan_555 Lakers 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted September 29, 2023 Author Share Posted September 29, 2023 On 9/27/2023 at 9:49 PM, Dan_555 said: Hi, it would be nice if you gave us a specific example of how it should behave. let say you have a text file with following content: hi there how are you my old friend when you call the function, do you want it to return "hi, there" then next time "how, are" and so on, always the next 2. here is an example of that one: Global $file="example.txt" for $x=1 to 3 ReadFiletoClip($x*2) MsgBox (270336,"Clipboard holds",ClipGet()) Next ;Send("^v") func ReadFiletoClip($st) local $tmp="" For $i = $st to $st+1 $tmp=$tmp & FileReadLine($file, $i) & @crlf Next Clipput($tmp) EndFunc Hi, I have tried your coding and it runs like this: "hi, there" then next time "hi, there, how, are" then next time "hi,there,how,are,you,my" It still keep the results of previous function call and not skipping it. Any idea how to fix it? Thanks in advanced! Link to comment Share on other sites More sharing options...
Dan_555 Posted September 30, 2023 Share Posted September 30, 2023 Small correction to my previous code: for $x=1 to 3 ReadFiletoClip(($x*2)-1) MsgBox (270336,"Clipboard holds",ClipGet()) Next Now it should read the 1st and the second line first, then 3rd+4th, then 5th and 6th. Lakers 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted October 3, 2023 Author Share Posted October 3, 2023 Thanks for the advice! I´ll definitely try it out. I still have a small issue. I'm testing 3 examples function : a,b,c. Func a() $i = 0 to 3 Step 1 a() Next EndFunc Func b() $i = 0 to 4 Step 1 a() Next EndFunc Func c() $i = 0 to 5 Step 1 a() Next EndFunc For $i = 0 to 10 Step 1 a() b() c() Next I want funcitons running a then b then c 10 times and each function stay with the variable like mentioned above. It means function a runs 1 time then jumps next function b then jumps next function c for continiously 10 times. but each function stays only in variable listed in the function. What I recieved are funciton a run 3 times then function b runs 4 times and function c runs 5 times. I´m messing over 3 days and still cant find any solutions. Thanks for advanced! Link to comment Share on other sites More sharing options...
Dan_555 Posted October 4, 2023 Share Posted October 4, 2023 (edited) To run the function a,b and c 10 times you need to do this Quote For $i = 0 to 10 Step 1 a() b() c() Next you can leave step 1 out. In your script, the IF is missing and the function a() would call itself and auto it prevents this. I still do not know what you are trying to do. Edited October 4, 2023 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted October 5, 2023 Author Share Posted October 5, 2023 I want the functions a,b,c running in a loop like mentioned in the coding., like this, a->b->c->a->b->c->a->b->c and continously. Function A will runs only in variable 0-3, Function b will run in variable 0 to 4, and Function c will run in variable 0 to 5. I hop its clearify now. Thanks in advanced Link to comment Share on other sites More sharing options...
Dan_555 Posted October 5, 2023 Share Posted October 5, 2023 There are many ways to do it. here is one example compressed into one function. Func a($st,$en) ConsoleWrite ("Running from " & $st & " to " & $en & @CRLF) for $i = $st to $en Step 1 ConsoleWrite ($i & @crlf) Next ConsoleWrite (@CRLF) EndFunc For $i = 0 to 10 Step 1 ConsoleWrite (@CRLF & "New loop " & $i & " ") a(0,3) a(0,4) a(0,5) Next Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted October 5, 2023 Author Share Posted October 5, 2023 54 minutes ago, Dan_555 said: There are many ways to do it. here is one example compressed into one function. Func a($st,$en) ConsoleWrite ("Running from " & $st & " to " & $en & @CRLF) for $i = $st to $en Step 1 ConsoleWrite ($i & @crlf) Next ConsoleWrite (@CRLF) EndFunc For $i = 0 to 10 Step 1 ConsoleWrite (@CRLF & "New loop " & $i & " ") a(0,3) a(0,4) a(0,5) Next So it means I have to put 2 start and end variable near the function. Example Func a($sta,$ena) For $i = $sta to $ena Step 1 function coding NExt Func b($stb,$enb) For $i = $stb to $ebn Step 1 function coding NExt Func c($stc,$enc) For $i = $stc to $enc Step 1 function coding NExt For $i = 0 to 10 Step 1 a($sta,$ena) b($stb,$enb) c($stc,$enc) Next Is it the right directions? Thanks in advanced and happy holidays. Link to comment Share on other sites More sharing options...
Dan_555 Posted October 6, 2023 Share Posted October 6, 2023 Func a() for $i = 0 to 3 next EndFunc Func b() for $i = 0 to 4 next EndFunc Func c() for $i = 0 to 5 next EndFunc For $i = 1 to 10 a() b() c() Next This is doing what you have asked to. Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted October 7, 2023 Author Share Posted October 7, 2023 20 hours ago, Dan_555 said: Func a() for $i = 0 to 3 next EndFunc Func b() for $i = 0 to 4 next EndFunc Func c() for $i = 0 to 5 next EndFunc For $i = 1 to 10 a() b() c() Next This is doing what you have asked to. Its not running like I meant. Its basically 3 functions running in loop and each function runs in desired $i I choosen. I hope its clear enough to understand now. Thanks for your reading and understanding. Link to comment Share on other sites More sharing options...
Dan_555 Posted October 7, 2023 Share Posted October 7, 2023 (edited) Sorry, but People in this thread have told you, multiple times, that that what you are asking is not clear. You have stated that you want to (and that is what i have understood) : Run functions a,b,c 10 times each after another. Function a running 0-3 times, function b running 0-4, function c running 0-5. That is my last code doing. Whatever else you want to do - you have to insert your code into that. Look, usually others here do not write code for other people. They say "Go write your own, if you encounter errors, give us your code and we will see where the error is". I'm ,sometime, willing to help, regardless. But it appears to me that you do not know what you are doing. Talking to you is like talking to the Chat GPT. If you want further help, write step by step instructions of what you want to achieve. Edited October 7, 2023 by Dan_555 Some of my script sourcecode 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