Sign in to follow this  
Followers 0
SimpleC

Array with decimal help!

20 posts in this topic

I honestly have no idea why this isn't working. It should be simple!

This is just a brief example of what I'm trying to do.

#include <array.au3>

dim $test[5]
$test[0]  = 55
$test[1] = 59.25
$test[3] = 65
$test[4] = 65.45

mouseclick("left", 410, 203, 1)
sleep(100)

for $i = 0 to 3
    send($test[$i])
    sleep(50)
    send("{enter}")
    sleep(50)
next

The problem is the the loop doesn't get past the decimal. Any help would be awesome. All its trying to do is write that array to an open notepad

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, SimpleC. To begin with, can you explain why you declare your array with 5 elements, and then skip [2]? Is this just a type, or is this how it is in your actual script? Beyond adding the missing element, it all worked just fine for me.

Edit: Notice too that you have 5 elements in your array, but only loop through 4 of them, so you'll only get 4 outputs.

This works fine and prints out [0], [1], [2], and [3]

#include <array.au3>
dim $test[5]
   $test[0] = 55
   $test[1] = 59.25
   $test[2] = 60.31
   $test[3] = 65
   $test[4] = 65.45
 
mouseclick("left", 410, 203, 1)
   sleep(100)
 
for $i = 0 to 3
   send($test[$i])
      sleep(50)
   send("{enter}")
      sleep(50)
next
Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

local $testmax= 5, $test[$testmax]

You have 4 elements, but you skip index [2] when you define them.

If the don't skip 2 you might have 5 elements

I would loop through the array like this to simplify things for myself.

for $i= 0 to $testmax-1;

Your example prints decimals just fine.

Edited by Xandy

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

As JLogan3o13 said you made some strange things, commented below.

#include <array.au3>

dim $test[5]
$test[0]  = 55
$test[1] = 59.25
                    ;<<--- Skipped ??
$test[3] = 65
$test[4] = 65.45

mouseclick("left", 410, 203, 1)
sleep(100)

for $i = 0 to 3        ;<<--- maybe to 4?
    send($test[$i])
    sleep(50)
    send("{enter}")
    sleep(50)
next

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Just a typo here on the forums. It's right in the script.

There's no error message either.

You say it works for you? Hmm. Maybe I should go try it on another computer.

Here's the actual code

dim $test[5]
$test[0] = 59
$test[1] = 59.55
$test[2] = 59
$test[3] = 59
click(410, 203)
for $i = 0 to 4
  send($test[$i])
  sleep(100)
  send("{enter}")
Next

if I take out the 59.55 and just put 59 without the decimal it works fine.

Edited by SimpleC

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You say it works for you? Hmm. Maybe I should go try it on another computer.

Na, when was your last reformat?

​It's probably the code dude, do an exact copy, somebody will solve this for you.

edit: I mis-read you. I thought you said maybe you should buy another computer. Oops, yeah try it on another machine.

Edited by Xandy

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Just a typo here on the forums. It's right in the script.

There's no error message either.

You say it works for you? Hmm. Maybe I should go try it on another computer.

Here's the actual code

dim $test[5]
$test[0] = 59
$test[1] = 59.55
$test[2] = 59
$test[3] = 59
click(410, 203)
for $i = 0 to 4
send($test[$i])
sleep(100)
send("{enter}")
Next

if I take out the 59.55 and just put 59 without the decimal it works fine.

That cannot be the "actual code" as click is not a function. When I change it back to Mouseclick, it prints out the 4 numbers, with decimals, just fine. However, as you are declaring 5 elements, and looping 5 times, but only have 0-3 defined, there will be a couple of blank lines.

Edit: I am going to hazard a wild and crazy guess that you're not actually trying to print this stuff into Notepad. Why not fill us in on the name of the application you're trying to work with? There are probably ways of accomplishing what you want that are 10x easier than using MouseClick and Send.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I've been using autoit for years. I've coded literally thousands of lines of code in it. I use it everyday at work. It has to be something other then the script.

Ok.. just tested it on another computer and it works fine. So yeah, I'm not sure why it wouldn't be working on this machine.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

That cannot be the "actual code" as click is not a function. When I change it back to Mouseclick, it prints out the 4 numbers, with decimals, just fine. However, as you are declaring 5 elements, and looping 5 times, but only have 0-3 defined, there will be a couple of blank lines.

Most of my scripts have a custom function to shorten mouseclick ;)

func click($x, $y, $clicks = 1)

mouseclick("left", $x, $y, $clicks)

endfunc

Also this is just a test to figure out why my actual code isn't working. A quick throw together array to see where the problem is.

Thanks for the help though guys. I might try a complete uninstall and reinstall and see what happens. If I can't get it I'll just switch to one of my other computers.

Edited by SimpleC

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

That may be, but when you use MouseClick in the first post, and then your custom click function in another, without letting us in on the secret, you make it difficult to assist you ;)

Edit: Not to mention skipping or omitting elements in your array, and changing the number of elements you loop through ;)

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Can you please explain what you try to achieve? Do you try to solve a real problem or do you just "play" with AutoIt?

If we know what you try to do we might provide a much simpler solution.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It's fairly simple. The loop ends when it gets to the decimal. If the decimal isn't there the loop runs fine. If I replace 59.55 with 59, it completes the loop. As soon as I put in 59.55 the script ends.

Share this post


Link to post
Share on other sites

What I mean is: Which application do you try to automate?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

All this is doing is writing that array to an open notepad. Which that exact code works on a different computer just not this one. It's weird.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

This might be caused by different screen resolutions so notepad might be on different screen coordinates or many other reasons.

But again: Is this a real task you need to solve or do you just play (means: is it worth the effort)?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Nope, this is actually something for work. I'll keep at it and report back when I figure out what's actually going on.

Solved!

I'm a noob

Haha... Ok. I had my terminate hotkey set to period.

HotKeySet(".", "terminate")

func terminate()

exit 0

EndFunc

So yeah... thanks for the help though everyone.

Edited by SimpleC

Share this post


Link to post
Share on other sites

I suggest to use something like this to send data to notepad:

Global $test[5] = [59, 59.55, 59, 59]
WinActivate("Unbenannt - Editor") ; <== Replace with the window title of your notepad
for $i = 0 to 4
  send($test[$i])
  send("{enter}")
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Solved!

I'm a noob

Haha... Ok. I had my terminate hotkey set to period.

Please, if you post a problem the next time add the complete script!

Without a complete script it is impossible to help you. And - more important - wastes our and your time!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Nothing like expecting people to guess at wtf you're doing...


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Please, if you post a problem the next time add the complete script!

Without a complete script it is impossible to help you. And - more important - wastes our and your time!

Will do. Thanks again though!

Share this post


Link to post
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
Sign in to follow this  
Followers 0