Sign in to follow this  
Followers 0
l3ill

For Next repeater

9 posts in this topic

Hi Guys,

Need a little help with this. I am trying to repeat this process until the last number in my excel sheet.

  • Open PDF
  • Fill out the 4 forms on one page
  • print it
  • close it
Then do it all again until all numbers have been used

Most of it works except the repeat all part.

See notes in code for more info...

sanirecord.pdf if you need it...

Thanks

;step 1 - open sanirecord.pdf
$sanirecord = (@DesktopDir & "\SaniMotion\sanirecord.pdf")
ShellExecute('AcroRd32.exe', $sanirecord)
WinWaitActive("sanirecord.pdf")

;step 2 - fills out the 4 records on sanirecord.pdf
$oExcel=_ExcelBookAttach("22022010001.xlsx", "FileName")
    Sleep(300)
    Send("+{TAB}")
    Sleep(300)
For $iCount = 1 To 4 ;position counter
    Send($iCount)
    Sleep(300)
    Send("{TAB}")
    Sleep(300)
 $sCellValue = _ExcelReadCell($oExcel, $iCount, 1);reads from selected Excel file 1 pos @ a time
 If $sCellValue = "" Then ExitLoop
    Send ($sCellValue)
    Sleep(300)
    Send("{TAB}")
    Sleep(300)
    Send ("Oasis")
    Send("{TAB}")
    Sleep(300)
 $sCellValue2 = _ExcelReadCell($oExcel, $iCount, 2)
    Send ($sCellValue2)
    Sleep(300)
    Send("{TAB}")
    Sleep(300)
    Send ("Grunstadt")
    Sleep(300)
    Send("{TAB}")
    Sleep(300)
    Send(_NowDate())
    Send("{TAB}")
Next
;step 3 - prints and closes sanirecord.pdf
    WinActivate("sanirecord.pdf")
            Send("^p")
            Sleep(1000)
            Send("{ENTER}")
            Sleep(1000)
            Send("^q")
 ;should go back and do it all again until (($sCellValue = "")) - no more numbers in excel sheet 
 ;then move to step 3 and print and quit regardless if all 4 records are complete or not

Share this post


Link to post
Share on other sites



do it all again until (($sCellValue = ""))

You might've answered your own question..

Do...Until


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I'm not sure I understand what you want exactly.

I am trying to repeat this process until the last number in my excel sheet.

Where do you get that "last number in my excel sheet"?

And do you wan to perform steps 1..4 until your exit condition is met?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for your interest...

@snowmaker

the problem with Do Until is that it repeats 1-4 over and over again when I need it to continue with 5-8 and the 9-12 and so on.

@jchd

the excel sheet has, lets say, a list of 13 serial numbers each 10 integers long in a row. I need to send them one at a time to the pdf form, which holds 4 different serial numbers among other things and then needs to printed and closed and then on to the next 4 numbers from the excel sheet and so on. finally, in our instance the 13th number will be alone on the form that usually holds 4 but still should go then to the print and close step. hope this clears things up...

Edited by billo

Share this post


Link to post
Share on other sites

Will it do what you need if you put the For..Next loop in a Do..Until?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

_Way_ clearer once explained as you did.

Pseudocode:

;; 1) Read the Excel list and grab the whole list of serial numbers into an array and say you call it $SerNum.

;; 2) Say you have read in
Local $nbSerNum = UBound($serNum)
;; You will have to fill in Mod($nbSerNum + 3, 4) PDF form holding up to 4 serial numbers.

Local $j
For $i = 0 To $nbSerNum - 1
    ; this is a counter modulo 4
    $j = Mod($i, 4)
    
    If $j = 0 Then
        ;; Setup a new empty PDF form
    Endif
    
    ;; fill in the $i-th serial number in the form
    ;; it will be in $j-th position in the form (0 to 3) or more simply in the next available position
    
    WriteSerNumToPDF($Sernum[$i], $j)
    
    ; we have to print if a form is full or if the last serial number has been processed
    If ($i > 0 And $j = 0) Or $i = $nbSerNum - 1 Then
        ;; print the PDF form
        If $i = $nbSerNum - 1 Then ExitLoop     ; you're done
    Endif
Next

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

It is kind of difficult to explain. I have been working with these dealies for weeks now so I probably assumed some stuff and left some stuff out.

At any rate thanks so much for your help, There is some new ground here for me so I will be playing around with this and get back with any progress and further questions.

Once again, thanks for your time JC!

Share this post


Link to post
Share on other sites

Arrays are new ground for me and I'm stuck on this one problem:

How to declare/call the variable that actually gives me the serial number ('s)

I've got the array working and I can see (consolewrite) that the counters and ubound are doing their job.

But I cant see a serial number...

I've been playing with _FileWriteFromArray($nbSerNum, $serNum, 3) (and other variations of same) but have the feeling I'm on the wrong trolley.

any hints?

Share this post


Link to post
Share on other sites

Use _ArrayDisplay($array) to ... display the content of an array. Mostly useful for debugging.

You declare arrays this way:

Local $myArray[50]

and $myArray can hold 50 variants (values of any type), which you access with $myArray[0] (first one has index 0), $myArray[1] (second one) up to $myArray[49] (last one in his example).

Often, the array will be create by a function like _FileReadFromArray(), _StringSplit(), ... In this case, you only have to declare the variable (Local or Global $myVar) and pass it to the function. It will make it an array of the required dimension (size) to hold the results.

Read the Array topic in the help file: Language Reference - Variables


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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