Jump to content

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}")

Link to comment
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...

Link to comment
Share on other sites

How about

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

Link to comment
Share on other sites

How about

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...
Link to comment
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.

Link to comment
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       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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].

Link to comment
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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...