01-25-2007, 04:18 AM

Hi I am new to QM, and have been working on this macro for a while. I have pieced it together from reading other's posts.

What I am trying to do is repeatedly run a macro which has a function that randomly chooses some variables, inserts those variables into the running macro. Then waits the specified time and runs another macro before repeating the whole process over again.

The randomization part works great. The copy and paste part works great. But I wont the program to pick the wait time, then pick a macro name, then run the specified macro. Then repeat the whole process over again.

What is happening right know is that it picks a wait time, then the macro name, it inserts these variables fine, but doesn't run the macro until it goes through that process the specified repeat times.

PS I have tried converting the last macro into a function but it doesn't work. I was thinking that there must be some way of, prioritizing the macros so that when the running macro comes across the embedded macro it pauses then continuous to run.

Any help would be great!!

Uniform Funiction

;;Uniform: L'Ecuyer Random number generator

;Global (or thread specific) integer variables s1 and s2

;hold the current state of the generator and must be

;initialised with values in the range [1-2147483562]

;and [1-2147483398] respectively. The generator has a

;period of ~ 2.3 x 10^18.

function^ [mn] [mx]

int z k

dll msvcrt clock

int+ s1 s2

if(!s1 || !s2)

,s1 = clock() / (1 << 16)

,s2 = clock() % (1 << 16)

,if(s1 <= 0 || s1 > 2147483562) s1 = 1

,if(s2 <= 0 || s2 > 2147483398) s2 = 2147483398

k = s1/53668

s1 = 40014*(s1-(k*53668))-(k*12211)

if(s1 < 0) s1+2147483563

k = s2 / 52774

s2 = 40692 * (s2-(k*52774))-(k*3791)

if(s2<0) s2=s2+2147483399

z = s1 - s2

if(z<1) z=z+2147483562

double random = z * 4.65661305956E-10

if(mx)

,ret (mn+ ((mx-mn+1)*random))

else ret random

What I am trying to do is repeatedly run a macro which has a function that randomly chooses some variables, inserts those variables into the running macro. Then waits the specified time and runs another macro before repeating the whole process over again.

The randomization part works great. The copy and paste part works great. But I wont the program to pick the wait time, then pick a macro name, then run the specified macro. Then repeat the whole process over again.

What is happening right know is that it picks a wait time, then the macro name, it inserts these variables fine, but doesn't run the macro until it goes through that process the specified repeat times.

PS I have tried converting the last macro into a function but it doesn't work. I was thinking that there must be some way of, prioritizing the macros so that when the running macro comes across the embedded macro it pauses then continuous to run.

Any help would be great!!

`rep 100`

,max "Quick Macros"

,ClearOutput

,ARRAY(str) a1 a2 a3 a4

,a1="1[]2[]3[]4"

,a2="0[]1[]2[]3[]4[]5[]6[]7[]8[]9"

,a3="0[]1[]2[]3[]4[]5[]6[]7[]8[]9"

,a4="MacroName1[]MacroName1[]MacroName2[]IMacroName3[]MacroName4"

,str s.from(a1[Uniform(0 a1.ubound)] a2[Uniform(0 a2.ubound)] a3[Uniform(0 a3.ubound)])

,str t.from(a4[Uniform(0 a4.ubound)])

,dou 78 340 id(2203 "Quick Macros")

,outp s

,wait 1

,dou 90 345 id(2203 "Quick Macros")

,outp t

,wait 1

,wait 136

,mac "MacroName#"

Uniform Funiction

;;Uniform: L'Ecuyer Random number generator

;Global (or thread specific) integer variables s1 and s2

;hold the current state of the generator and must be

;initialised with values in the range [1-2147483562]

;and [1-2147483398] respectively. The generator has a

;period of ~ 2.3 x 10^18.

function^ [mn] [mx]

int z k

dll msvcrt clock

int+ s1 s2

if(!s1 || !s2)

,s1 = clock() / (1 << 16)

,s2 = clock() % (1 << 16)

,if(s1 <= 0 || s1 > 2147483562) s1 = 1

,if(s2 <= 0 || s2 > 2147483398) s2 = 2147483398

k = s1/53668

s1 = 40014*(s1-(k*53668))-(k*12211)

if(s1 < 0) s1+2147483563

k = s2 / 52774

s2 = 40692 * (s2-(k*52774))-(k*3791)

if(s2<0) s2=s2+2147483399

z = s1 - s2

if(z<1) z=z+2147483562

double random = z * 4.65661305956E-10

if(mx)

,ret (mn+ ((mx-mn+1)*random))

else ret random