Hello again!
I've done a bug bunch of testing, but i got some issues, and it does not work nicely yet. Im not sure if im writing code correctly.
First, questions to sintax and
code meaning:
A) About "createscript": there is no mention to this sintax (with the little arrow, like <subroutine : subroutine >: ) in the create script page (
https://hotkeyit.github.io/v2/docs/comm ... Script.htm)
A.1) Does all the code need to be inside the same ahk.file? i made a #include inside the thread code, as i would need other functions and subs for data processing. can i do it with no issues? i looks like it works.
threads:=[]
Loop 4
threads[A_Index]:=AhkThread("
(
# include subroutines.ahk ; <---------------
#Persistent
Alias(mondaytime," getvar(mondaytime) ")
Alias(tuesdaytime," getvar(tuesdaytime) ")
Alias(thursdaytime," getvar(thursdaytime) ")
Alias(worktime," getvar(worktime) ")
Alias(sumtime," getvar(sumtime) ")
Alias(testvar," getvar(testvar) ")
Alias(testvar2," getvar(testvar2) ")
" CreateScript("<subroutines:subroutines>") "
)")
B) About the "#persistent" : why is it there? and why is this necessary?
i've couldnt note a difference by removing this. after i run scripts, they wont close anymore. maybe it's because my main script has already the "persistent" parameter?
C) The sintax you sent me looks like it opens a copy of the currently running script, is it correct? For instance, when i run it, it displayes 4 extra "main.ahk" icons on my system tray
D) Instead of using the "done:=1" variable to check if the thread is over, can i use ahkReady()? i assume not, as they are persistent, so they never finish. but that was a question i had.
E)
In this code, you wrote:
threads[A_Index]:=AhkThread
so, to "call" the functions, should you not write this way?
threads[1].ahkLabel("readtime")
threads[2].ahkLabel("sumweektime")
threads[3].ahkLabel("RESTapicallA")
threads[4].ahkLabel("RESTapicallB")
Instead of the way you used, with the dots?
threads.1.ahkLabel("readtime")
threads.2.ahkLabel("sumweektime")
threads.3.ahkLabel("RESTapicallA")
threads.4.ahkLabel("RESTapicallB")
Still about this sintax, in the docs. (
https://hotkeyit.github.io/v2/docs/comm ... kLabel.htm), you used this sintax:
dll.ahkLabel["MyLabel"] (with the [])
But in you answer to me, u used () instead, like this -> dll.ahkLabel("MyLabel").
Are they equivalent?
F) About the Alias function: i should do the running of the threads, with the alias before using my main program variables? or does not matter? you started the thread before the "actual code". is it necessary?
F.1) If i get it right, when i use the alias inside a thread, like you did, for instance, if inside my thread i create a msgbox with the value of the variable alias, it would display it correctly? i am passing the value from my main thread, to the newly created threads, am i right? or not? because i notice when i try to use the variables inside the threads, they are empty. I've seen a post from someone saying he/she couldnt ever use the alias function with success. maybe its not working or am i wrong in how using it?
Still about it, in documentation (
https://hotkeyit.github.io/v2/docs/commands/Alias.htm) the sintax is done without " " , like this:
Alias(refvar, getvar(var)) <- documentation
Alias(refvar, " getvar(var) ") <- your example to me
which one is correct?
G) About this : " CreateScript("<subroutines:subroutines>")
I understand you are adding some code with this comand, right?
But the thing is: the labels inside this are already in my code. when i include my files, it gives me "duplicate labels" error.
so i removed this comand, and only added the #include in the initiation of the threads. it worked i think, but i would like to know if you have any thoughts on it.
ABOUT EXECUTION
H) Now there is an issue i'm not really sure why it's happening, and not sure how to solve it as well.
When i run the script, for some reason it looks like one of the threads runs a lot of times, then the other threads run one time each.
I'm not sure actually if the following is working correctly.
threads.1.ahkLabel("timereport") <-- actual code of my script
For instance, i have 4 labels. each one displays a msg when starting (so i can know if they are starting at the same time or almost).
label1:
msgbox 1
....
return
label2:
msgbox 2
....
return
label3:
msgbox 3
....
return
label4:
msgbox 4
....
return
so, when i run script, i get a lot of messageboxes with 1, at the same time.
Then the 2, 3 and 4 comes one each time, when i click "OK" on the already existing msgboxes.
the curious things:
1: it happens even when i dont have the threads.1.ahkLabel("timereport") code. in my understanding, im not calling anything inside the start of the thread. so no msgbox should show. but it does, like it was doing the subroutine. but i didnt call it.
2: it get a particular label to execute a lot of times, and i dont know why. if there is a value somewhere in memory that is "static", so it gets always the same label to execute
3: looks like that ALL threads execute this label first, then the start to get the other labels to execute.
for instance:
create thread 1, thread 2, thread 3, thread 4
FIRST: all of them execute label 1. (so i get 4 msgboxes with "1" text). looks like when there are 4 "main.ahk" running, and i call a label, it calls the label on the 4 main.ahk processess. but the same does not happen to other labels, which i don't understand.
then, i dont know why, ONE of the threads get responsible for the other numbers.
So it displays a 2 on the screen, and wait until i hit "OK". then displays 3, and wait. then 4. then wait. just then the script moves forward.
my actual code:
threadD:= AhkThread(" <- this is the fourth thread. there are more 3 of them, being threadA, B, C.
(
#Include %A_ScriptDir%/Jira.ahk
Alias(project1," getvar(project1) ")
Alias(version1," getvar(version1) ")
Alias(datainicio," getvar(datainicio) ")
Alias(horacorrente," getvar(horacorrente) ")
Alias(jirapassword," getvar(jirapassword) ")
)")
threadD.ahkLabel("timereport") ; <--- here i "call" the label
so, im not sure what i am doing wrong, but does not feel (or work) right.
inside my labels, i make http calls (post, get, and stuff). dont know if changes anything.
if it got too complicated i can make a video, so its easier to explain!
thanks again for your time!