Jump to content

increment file within loop generating errors


Recommended Posts

Hi Folks,

Hope you can help.

I'm working on a script to take pictures, send them to the web, and generate a series of images to use as a time lapse movie. Everything works fine, till I include this code to create the "series" of images in a folder for the time lapse movie

The error I get is "While" statement has no matching "Wend" statement.

This loop works fine till I include the func. statement. I found this "Custom" function statement here in this forum, and want to give thanks to weaponx. Thanks in advance, I appreciate your help.

;begin taking pictures,take 1 pic each 10min for 10 hours = 60 pics

; camin is the directory where pics are captured

; cammovie is the folder for the time lapse movie

; camout is the folder i use for FTP to the web.

$i = 1

While $i <=60

; next line fires the shutter

Send ("{SPACE}")

Sleep (5000)

_IncrementalFileCopy("c:\vws\camin\*.jpg", "c:\vws\cammovie\image.jpg")

Func _IncrementalFileCopy($Source, $Destination)

$count = 0

Do

;Split destination into file / extension

$pathArray = StringSplit ( $Destination, ".")

;If more than one period in destination filename, return error

if $pathArray[0] > 2 then return 3

$newDestination = $pathArray[1] & $count & "." & $pathArray[2]

$count += 1

Until FileExists($newDestination) = 0

;Copy file without overwrite just to be safe

FileCopy ( $Source, $newDestination, 8)

Return @error

EndFunc

; move image for FTP

FileMove ("c:\vws\camin\*.jpg", "c:\vws\camout\image.jpg", 1)

Sleep (595000)

$i = $i + 1

WEnd

Link to comment
Share on other sites

You have your function inside of the while loop

$i = 1
While $i <=60
; next line fires the shutter
Send ("{SPACE}")
Sleep (5000)
_IncrementalFileCopy("c:\vws\camin\*.jpg", "c:\vws\cammovie\image.jpg")
FileMove ("c:\vws\camin\*.jpg", "c:\vws\camout\image.jpg", 1)
Sleep (595000)
$i = $i + 1
WEnd 

Func _IncrementalFileCopy($Source, $Destination)
$count = 0
Do
$pathArray = StringSplit ( $Destination, ".")
if $pathArray[0] > 2 Then Return 3
$newDestination = $pathArray[1] & $count & "." & $pathArray[2]
$count += 1
Until FileExists($newDestination) = 0
FileCopy ( $Source, $newDestination, 8)
Return @error
EndFunc
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...