# a little help with this code

## Recommended Posts

Hello! a little new to autoit and am in need of some help with condensing the below code into a loop.

i need the code to be looped 100 times (\$1 \$2 \$3 to.. \$100) and have had no luck in understanding how to use a loop function with this code. can someone guide me, thank you

Send("^{c}")

\$1 = ClipGet()

\$1 = StringTrimRight(\$1, 2)

Send("{down}")

Send("^{c}")

\$2 = ClipGet()

\$2 = StringTrimRight(\$2, 2)

Send("{down}")

Send("^{c}")

\$3 = ClipGet()

\$3 = StringTrimRight(\$3, 2)

Send("{down}")

##### Share on other sites

Hello! a little new to autoit and am in need of some help with condensing the below code into a loop.

i need the code to be looped 100 times (\$1 \$2 \$3 to.. \$100) and have had no luck in understanding how to use a loop function with this code. can someone guide me, thank you

Send("^{c}")

\$1 = ClipGet()

\$1 = StringTrimRight(\$1, 2)

Send("{down}")

Send("^{c}")

\$2 = ClipGet()

\$2 = StringTrimRight(\$2, 2)

Send("{down}")

Send("^{c}")

\$3 = ClipGet()

\$3 = StringTrimRight(\$3, 2)

Send("{down}")

the code you're looking for would be something like: *untested

```\$a = 1
While \$a
Send("^{c}")
Assign(\$a, ClipGet())
If NotStringLen (Eval(\$a)) Then ExitLoop
Assign(\$a, StringTrimRight(Eval(\$a), 2))
WEnd```

but if this is for excel (as it looks to be) we may have better ways to do what you want...

##### Share on other sites

```While 1 to 100
Send("^{c}")
\$1 = ClipGet()
\$1 = StringTrimRight(\$1, 2)
Send("{down}")
WEnd```

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

##### Share on other sites

thanks for the replys, just popin out but bookmark this thread and test the code tommorow.

thanks again! deano

##### Share on other sites

```While 1 to 100
Send("^{c}")
\$1 = ClipGet()
\$1 = StringTrimRight(\$1, 2)
Send("{down}")
WEnd```
good call, i didn't read thoroughly enough to see that he wanted a fixed number of iterations, so i just set mine up to go till it hit a black copy...
##### Share on other sites

just cant figure this one out, thanks for the replys you guys, here is what i find...

```\$a = 1
While \$a
Send("^{c}")
Assign(\$a, ClipGet())
If NotStringLen (Eval(\$a)) Then ExitLoop
Assign(\$a, StringTrimRight(Eval(\$a), 2))
WEnd```

NotStringLen causes an error

```While 1 to 100
Send("^{c}")
\$1 = ClipGet()
\$1 = StringTrimRight(\$1, 2)
Send("{down}")
WEnd```

while 1 to 100 causes an error

summary

i'm using excel in open office. my objective is to save 100 cells of data (int) (vertical cells) and then call up this data 1 entry at a time in a msgbox. The data must be gathered from all 100 cells first before it then proceeds to the msgbox stage.

anyhelp or advice at all appreciated.

##### Share on other sites

• Developers

NotStringLen causes an error

Yes ... try a space between Not and StringLen()

while 1 to 100 causes an error

Did you try to open the helpfile and read about any of this or are you just doing a Cut/Paste job and run the script ?

Think a for..next loop was intended in this example....

SciTE4AutoIt3 Full installer Download page Â  -Â Beta filesÂ  Â  Â  Â  Â  Â
Â
Live for the present,
Dream of the future,
Learn from the past.
Â

##### Share on other sites

If I were doing it, I would use an array and a for loop.

```Global \$Array[101]
For \$i = 1 to 100
Send("^{c}")
\$Array[\$i] = StringTrimRight (ClipGet(), 2)
Send("{down}")
Next```

Now you have an array of your text, with entries in \$Array[1] to \$Array[100].

##### Share on other sites

again thanks for the help. i have been using the References for help. not so familuar with the "Not" or "For" loop statements. still on the noob level :] i'll see if i can get this working now, thanks

##### Share on other sites

If I were doing it, I would use an array and a for loop.

```Global \$Array[101]
For \$i = 1 to 100
Send("^{c}")
\$Array[\$i] = StringTrimRight (ClipGet(), 2)
Send("{down}")
Next```

Now you have an array of your text, with entries in \$Array[1] to \$Array[100].

just while the the topic is fresh, thanks greenmachine this worked fine

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...