Sign in to follow this  
Followers 0
treefingers

"While" question

3 posts in this topic

Hello Autoit community!

I am, well, not a programmer. I need your help! Some background information: I'm trying to write a script that automates taking invoice numbers from a text file, and inputs every 50 lines of them in our point of sale software, pausing to print every 50 lines. So, basically I need to have a Send("!r") after 50 lines of reading text from a text file. How do I do that?

This is the code I have so far (which the majority of came from www.rick-davis.com), and it does exactly what I need it to do, except it reads and enters all 600+ lines. I just need it to "run" every 50..

CODE
$fileVariableName = FileOpen("invoices.txt", 0)

If $fileVariableName = -1 Then

MsgBox(0,"Failure","Failed to open file")

Exit

EndIf

While 1

$lineVariableName = FileReadLine($fileVariableName)

If @error = -1 Then ExitLoop

WinActivate("Completed Order Re-Print")

Send($lineVariableName)

Sleep(500)

Send("{ENTER}")

Sleep(500)

Send("!a")

Sleep(1000)

WEnd

FileClose($fileVariableName)

Don't mind all the sleeps, our point of sale software is very slow! That is the main reason I can only print 50 orders at a time as well..

Thanks for your help!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this maybe?

$fileVariableName = FileOpen("invoices.txt", 0)
If $fileVariableName = -1 Then
 MsgBox(0,"Failure","Failed to open file")
 Exit
EndIf

While 1
 For $x = 1 to 50
  $lineVariableName = FileReadLine($fileVariableName)
  If @error = -1 Then ExitLoop 2
  WinActivate("Completed Order Re-Print")
  Send($lineVariableName)
  Sleep(500)
  Send("{ENTER}")
  Sleep(500)
  Send("!a")
  Sleep(1000)
 Next
 Send("!r")
WEnd
FileClose($fileVariableName)
Edited by TomZ

Share this post


Link to post
Share on other sites

Thanks! That was fast!

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