AutoHotkey Community

It is currently May 27th, 2012, 3:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: this loop cannot stop?
PostPosted: June 6th, 2010, 3:16 pm 
Offline

Joined: November 24th, 2008, 2:31 pm
Posts: 252
i need help to stop this loop.....it send the data..but after the last array..it begins again...
Code:
#SingleInstance, force
SetKeyDelay, 25

plotone =1.1 2.2 3.3 4.4 5.5   ;plot area of flower(1)

plottwo =6.6 7.7 8.8 9.9  ;plot area of flower(2)

StringSplit, pa, plotone, `.%A_Space%

StringSplit, pb, plottwo, `.%A_Space%

a :=111   ;nutrient
b :=222   ;water
c :=333   ;bud
d :=444   ;cm
e :=555   ;condition

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

`::

WinActivate, a  ; <------ office excel page
loop, %pa0%
loop, %pb0%
{

   if Mod(A_Index,2)
   {
   ControlClick, x777 y161,a
   inputbox1 .= pa%A_Index%
   Send, % "{Del 3}{BS 3}"pa%A_Index% "{tab}"
   ControlClick, x777 y161,a
   inputbox1 .= pb%A_Index%
   Send, % "{Del 3}{BS 3}"pb%A_Index% "{tab}"
   }
   else
   {
   inputbox2 .= pa%A_Index%
   Send, % pa%A_Index%
   Send, {tab}%a%{tab}%b%{tab}%c%{tab}%d%{tab}%e%
   inputbox2 .= pb%A_Index%
   Send, % pb%A_Index%
   Send, {tab}%a%{tab}%b%{tab}%c%{tab}%d%{tab}%e%{enter}
   }
         
}

Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2010, 4:05 pm 
have u checked the value of pa0 and pb0?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2010, 4:07 pm 
u can debug by:
Code:
`::
msgbox, %pa0% %pb0%
loop, %pa0%
loop, %pb0%
{
a++   
}
msgbox, % a
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2010, 4:30 pm 
I don't think there is anything wrong with your loop, it performs as expected (and terminates when finished). I wonder if you really want to split the plotone and plottwo variables with both . and A_Space). I simplified your code and replaced most of your actions with outputdebug statements to see what is really happening. Here is the simplified code:
Code:
#SingleInstance, force

plotone =1.1 2.2

plottwo =2.2 3.3

StringSplit, pa, plotone, `.%A_Space%

StringSplit, pb, plottwo, `.%A_Space%
outputdebug pa0 %pa0%    pb0 %pb0%
listvars
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

`::

loop, %pa0%
{
  outputdebug, A_Index (outer loop) %A_Index% pa
   loop, %pb0%
   {
   
      if Mod(A_Index,2)
      {
        outputdebug `tif Mod(A_Index,2) is TRUE A_Index = %A_Index%
      }
      else
      {
        outputdebug `tif Mod(A_Index,2) is FALSE A_Index = %A_Index%
      }
            
   }
}
Return
And here is a trace of the loops executions (look correct to me, given the stringsplit parameters):
Code:
pa0 4    pb0 4
A_Index (outer loop) 1 pa
 if Mod(A_Index,2) is TRUE A_Index = 1
 if Mod(A_Index,2) is FALSE A_Index = 2
 if Mod(A_Index,2) is TRUE A_Index = 3
 if Mod(A_Index,2) is FALSE A_Index = 4
A_Index (outer loop) 2 pa
 if Mod(A_Index,2) is TRUE A_Index = 1
 if Mod(A_Index,2) is FALSE A_Index = 2
 if Mod(A_Index,2) is TRUE A_Index = 3
 if Mod(A_Index,2) is FALSE A_Index = 4
A_Index (outer loop) 3 pa
 if Mod(A_Index,2) is TRUE A_Index = 1
 if Mod(A_Index,2) is FALSE A_Index = 2
 if Mod(A_Index,2) is TRUE A_Index = 3
 if Mod(A_Index,2) is FALSE A_Index = 4
A_Index (outer loop) 4 pa
 if Mod(A_Index,2) is TRUE A_Index = 1
 if Mod(A_Index,2) is FALSE A_Index = 2
 if Mod(A_Index,2) is TRUE A_Index = 3
 if Mod(A_Index,2) is FALSE A_Index = 4


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2010, 4:35 pm 
Offline

Joined: November 24th, 2008, 2:31 pm
Posts: 252
dear guest.....if you try the code on "office excel"...it just keep looping....how can i stop the loop after it reach the last array...?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2010, 4:38 pm 
Offline

Joined: November 24th, 2008, 2:31 pm
Posts: 252
guest 3456...i will try your code...

i will give the feedback later......and thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:23 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
I believe you are using delimiters incorrectly.
How many entries do you expect in plotone and from plottwo.
I thought 5 & 4 respectively.

Please insert the 3 lines indicated below into your script and run.
Look at the resulting pa0 and pb0 and the arrays that stringsplit creates.

Is that what you intended?
Code:
#SingleInstance, force
SetKeyDelay, 25

plotone =1.1 2.2 3.3 4.4 5.5   ;plot area of flower(1)

plottwo =6.6 7.7 8.8 9.9  ;plot area of flower(2)

StringSplit, pa, plotone, `.%A_Space%

StringSplit, pb, plottwo, `.%A_Space%

a :=111   ;nutrient
b :=222   ;water
c :=333   ;bud
d :=444   ;cm
e :=555   ;condition

listvars                           ; <---Leef_me
msgbox pa0 is %pa0%`npb0 is %pb0%  ; <---Leef_me
return                             ; <---Leef_me

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:26 am 
Offline

Joined: November 24th, 2008, 2:31 pm
Posts: 252
guest 3456, i ran your code...i see the return in debugging.......but when i tried my code...it still keep looping?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:36 am 
Offline

Joined: November 24th, 2008, 2:31 pm
Posts: 252
leef_me....i added the code as instructed.....
Code:
#SingleInstance, force
SetKeyDelay, 25

plotone =1.1 2.2 3.3 4.4 5.5   ;plot area of flower(1)

plottwo =6.6 7.7 8.8 9.9  ;plot area of flower(2)

StringSplit, pa, plotone, `.%A_Space%

StringSplit, pb, plottwo, `.%A_Space%

a :=111   ;nutrient
b :=222   ;water
c :=333   ;bud
d :=444   ;cm
e :=555   ;condition

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

`::

WinActivate, a  ; <------ office excel page
loop, %pa0%
loop, %pb0%
{

   if Mod(A_Index,2)
   {
   ControlClick, x777 y161,a
   inputbox1 .= pa%A_Index%
   Send, % "{Del 3}{BS 3}"pa%A_Index% "{tab}"
   ControlClick, x777 y161,a
   inputbox1 .= pb%A_Index%
   Send, % "{Del 3}{BS 3}"pb%A_Index% "{tab}"
   }
   else
   {
   inputbox2 .= pa%A_Index%
   Send, % pa%A_Index%
   Send, {tab}%a%{tab}%b%{tab}%c%{tab}%d%{tab}%e%
   inputbox2 .= pb%A_Index%
   Send, % pb%A_Index%
   Send, {tab}%a%{tab}%b%{tab}%c%{tab}%d%{tab}%e%{enter}
   }
         
}

listvars                           ; <---Leef_me
msgbox pa0 is %pa0%`npb0 is %pb0%  ; <---Leef_me
return                             ; <---Leef_me

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

esc::exitapp


my problem is that ......the loop cannot stop


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:44 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
leehong1 wrote:
leef_me....i added the code as instructed.....

my problem is that ......the loop cannot stop


No. :x The problem is that you DO NOT READ.

Please, re-read my post.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 7:09 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
Code:
plotone =1.1 2.2 3.3 4.4 5.5   ;plot area of flower(1)
plottwo =6.6 7.7 8.8 9.9  ;plot area of flower(2)
StringSplit, pa, plotone, `.%A_Space%
StringSplit, pb, plottwo, `.%A_Space%
gives 10 for pa0 and 8 for pb0, so the inner loop is called 10 times doing always the same.

Code:
Send, % "{Del 3}{BS 3}"pa%A_Index% "{tab}"
Do you mean A_Index of the outer loop?

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 9:09 am 
Offline

Joined: November 24th, 2008, 2:31 pm
Posts: 252
Leef_me... so sorry ...well i tried the code again...

this was shown..
Quote:
Global Variables (alphabetical)
--------------------------------------------------
0[1 of 3]: 0
a[3 of 3]: 111
b[3 of 3]: 222
c[3 of 3]: 333
d[3 of 3]: 444
e[3 of 3]: 555
ErrorLevel[1 of 3]: 0
f[3 of 3]: 666
g[3 of 3]: 777
h[3 of 3]: 888
i[3 of 3]: 999
inputbox1[72 of 259]: 162738162738162738162738162738162738162738162738162738162738...
inputbox2[72 of 259]: 162738162738162738162738162738162738162738162738162738162738...
j[3 of 3]: 000
pa0[1 of 3]: 6
pa1[1 of 3]: 1
pa2[1 of 3]: 1
pa3[1 of 3]: 2
pa4[1 of 3]: 2
pa5[1 of 3]: 3
pa6[1 of 3]: 3
pb0[1 of 3]: 6
pb1[1 of 3]: 6
pb2[1 of 3]: 6
pb3[1 of 3]: 7
pb4[1 of 3]: 7
pb5[1 of 3]: 8
pb6[1 of 3]: 8
plotone[11 of 63]: 1.1 2.2 3.3
plottwo[11 of 63]: 6.6 7.7 8.8


nick....if you try this on "office excel"
Code:
#SingleInstance, force
;SetKeyDelay, 25

plotone =1.1 2.2 3.3  ;plot area of flower(1)

plottwo =6.6 7.7 8.8  ;plot area of flower(2)

StringSplit, pa, plotone, `.%A_Space%

StringSplit, pb, plottwo, `.%A_Space%

a :=111   ;nutrient
b :=222   ;water
c :=333   ;bud
d :=444   ;cm
e :=555   ;condition

f :=666   ;nutrient.....(control sample)
g :=777   ;water........(control sample)
h :=888   ;bud..........(control sample)
i :=999   ;cm...........(control sample)
j :=000   ;condition....(control sample)

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

`::

WinActivate, a  ; <------ office excel page
loop, %pa0%
loop, %pb0%
{

   if Mod(A_Index,2)
   {
   ControlClick, x777 y161,a
   inputbox1 .= pa%A_Index%
   Send, % "{Del 3}{BS 3}"pa%A_Index% "{tab}"
   ControlClick, x777 y161,a
   inputbox1 .= pb%A_Index%
   Send, % "{Del 3}{BS 3}"pb%A_Index% "{tab}"
   }
   else   
   {
   inputbox2 .= pa%A_Index%
   Send, % pa%A_Index%
   Send, {tab}%a%{tab}%b%{tab}%c%{tab}%d%{tab}%e%
   inputbox2 .= pb%A_Index%
   Send, % pb%A_Index%
   Send, {tab}%f%{tab}%g%{tab}%h%{tab}%i%{tab}%j%{enter}
   }
         
}

listvars                           ; <---Leef_me
msgbox pa0 is %pa0%`npb0 is %pb0%  ; <---Leef_me
return                             ; <---Leef_me

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

esc::exitapp


the loop ends after (18)eighteen rows of data.....am i not suppose to get only (3)three rows....
that should be....
Quote:
-----Experiment-------xxxxx------Control------

1 1 111 222 333 444 555 6 6 666 777 888 999 000
2 2 111 222 333 444 555 7 7 666 777 888 999 000
3 3 111 222 333 444 555 8 8 666 777 888 999 000


what i need is for the loop to end after sending the last array(8.8 from array plottwo)...but is it repeating the data (6)six times

How do i paste capture excel image(bmp) in the forum?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 10:48 am 
I'm trying to wrap my head around this, but I don't see how the result supposed to be only three rows, since
pb0=6
pa0=6
the number of total iterations is pa0*pb0=36
and the number of the total rows inserted is pa0*(pb0/2)=18
:?:
To insert an image you could upload it somewhere and use the img tag: [ img ]url-comes-here[ /img ] (without spaces).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:23 pm 
Offline

Joined: January 29th, 2009, 9:50 pm
Posts: 483
Location: Belgium
Quote:
but is it repeating the data (6)six times

ofcourse it is reapeating six times, u are using
Code:
plotone =1.1 2.2 3.3  ;plot area of flower(1)
StringSplit, pa, plotone, .%A_Space%   
wich result in pa0=6.
so it is doing what you asked. unless your saying the loop goes till infinity.
and that it can never do.
so you need to show a example of the result you really want
you are also posting with different exemples then in your first code, wich is confusing becouse there pa0 would be 10

PS i dint have excel, i have OpenOffice

_________________
Stopwatch emdkplayer
the code i post falls under the: WTFYW-WTFPL license


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:33 pm 
Offline

Joined: January 29th, 2009, 9:50 pm
Posts: 483
Location: Belgium
and why would you do these?
Code:
inputbox1 .= pa%A_Index%
inputbox2 .= pa%A_Index%
they are never used.
and this:
Code:
WinActivate, a
why would u activate the active window ?
and this:
Code:
ControlClick, x777 y161,a
what does it do? is that clicking on a cell? becouse 2 lines down your doing the same thing
you also using:
Code:
pa%A_Index%
in your innerloop so A_Index is not representing the outerloop index.

_________________
Stopwatch emdkplayer
the code i post falls under the: WTFYW-WTFPL license


Last edited by emmanuel d on June 7th, 2010, 6:55 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group