Adding new page regardless.

Newbie again!

Just wondering why the “if” doesn’t seem to work. Whichever button is pressed - a new page is added and the choose prompt shows. What am I doing wrong.


tell application "Adobe InDesign CS3"
	
	set fileCounter to false
	set pageCounter to 1
	set myDocument to make document
	tell myDocument
		set myDocPrefs to document preferences
		tell myDocPrefs
			set pages per document to pageCounter
		end tell
	end tell
	
	repeat while fileCounter is false
		
		set myFile to (choose file with prompt "File to import:") as text
		
		tell margin preferences of page pageCounter of myDocument
			set myX to left
			set myY to right
		end tell
		
		tell page pageCounter of myDocument
			set myStory to place myFile place point {myX, myY} autoflowing no without showing options
		end tell
		
		display dialog "Add a file:" buttons {"NO", "YES"} default button 1
		set moveForward to the result
		
		if moveForward = "NO" then
			set fileCounter to true
		else
			set pageCounter to pageCounter + 1
			set myDocPrefs to document preferences
			tell myDocument
				set myDocPrefs to document preferences
				tell myDocPrefs
					set pages per document to pageCounter
				end tell
			end tell
			set fileCounter to false
		end if
		
	end repeat
	
end tell

Thanks all

Working more on it - I got it - I even streamlined it a bit more.

Scottie

Hi,

display dialog returns a record, in your case {button returned:value]


.
set moveForward to button returned of (display dialog "Add a file:" buttons {"NO", "YES"} default button 1)
       if moveForward = "NO" then
.

Thanks - that line is even more streamlined.

The Swiss Rock

Scottie