Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some more questions
#1
1. the spe trick

i have nested macros. does it to be activated on the top macro or in each subsequent ones?

Macro 1:
spe 0
macro 2
macro 3
spe -1
end
or
Macro 1:
Macro 2: spe 0 code... spe -1
Macro 3: spe 0 code... spe -1
Macro 4: spe 0 code... spe -1
end

2. i don't understand the "wait for another thread" structure.. any links?

3. for global variables:

int+ i=10 declared in macro 1
in macro2 is all i have to do is type int+ i too? changes in i variable made in macro2 will be seen in macro1 too?

macro 1:
int+ i=10
call macro2
out i ;; i=11
macro2:
int+ i
i=i+1
return to macro1

thanks
#2
1. In each.

spe -1 is not always necessary. It restores default speed. Use it if the macro has more commands that use speed. Command that use it are listed in Help, spe topic.

2. What is the context? Wait until another thread STARTS, or until ENDS? Does your thread launch that another thread?

3. Yes.

In most cases, declaration can be only in single macro. Declare in multiple macros only when you don't know which macro will be used first.
#3
1. ok, i did that

2. i'm still struggling with the "wait for download completed before going on" stuff..your did work
but i'm sure i can do better.

so
Macro 1 :
...
Downloadfile(....) to be done in macro2
wait for thread in macro2 to end -> Macro 2:IntGetFile(....) ... in new thread and when over say it to macro1
macro1 continues <---------------------------------------------------------------------------------------------------------------|
some more code

3. i must do something wrong then...most testing required because some varaibles don't share properly
#4
Do you run Macro2 from Macro1 using mac?
#5
yes

macro1 --> macro2 does intGetFile
when macro2 has finished the download -> notifies macro1
macro1 does code with the downloaded file when the download is *really*over and the file completely
downloaded
#6
Macro1
Macro Macro1462
Code:
Copy      Help
str f="$desktop$\file_1MB.txt"
wait 0 H mac("DownloadFile" "" "http://www.quickmacros.com/test/file_1MB.txt" f)
run f

;mac() returns thread handle, and then wait() waits for it.

Macro2
Function DownloadFile
Code:
Copy      Help
;\
function $url $localFile

str s=localFile
IntGetFile url s 16
#7
Yes works perfectly now.

Is it a common method suitable for any task?
#8
Yes, if you want to launch other thread (not simply call function) and wait for it.
#9
OK

Now:

i have a toolbar, with 4 macros in it

item1 :mac "1"
item2 :mac "2"
item3: mac "3"
item4: mac "4"
int+ GlobalVariable

item4 is a menu macro

item4:
int- MenuVariable
sub1: mac "5"
sub2: mac "6"
sub3: mac "7"


1. i tried to declare a variable common to ALL macros (1 to 7). So i put i in the toolbar declaration.
Problem it appears in the toolbar. How to avoid that?
Is the "+" sign correct here : int+ GlobalVariable

2. i want to declare a variable only visible in item4 macro, so only for macros 4 to 7
is int- MenuVariable correct? And i don't want it in the menu too

So if MenuVariable=0 at declaration in item4, and mac 5 adds 5, etc,
out MenuVariable should be 5, 6 or 7 depending on the menu macro played, right?
but in macro 3 it should raise an exception as it is unknow.
Correct?
#10
Variables cannot be declared in menu or toolbar like you do. Can be declared only in code. A menu item is label followed by code that runs when you click the item.

label :code
label :code
...

Global variables are visible in all macros. Currently QM does not have namespaces or something similar to make them visible only in some macros.

Thread variables probably cannot be used in your case.
#11
If you want to declare/set a global variable before showing the toolbar, you can run the toolbar from a function:

Function toolbar_launcher
Code:
Copy      Help
int+ GlobalVariable=0
mac "Toolbar547"
;;or
;mac "toolbar" win("window to which the toolbar will be attached")

Toolbar Toolbar547
Code:
Copy      Help
item1 :mac "1"
item2 :mac "2"
item3 :mac "3"
item4 :int+ MenuVariable=0; mac "4"


Forum Jump:


Users browsing this thread: 3 Guest(s)