Getting a pop up window to appear in my script

Hello,

I have a script that uses a prompt to tell the user what to do, but I have to put a warning in there and its long and I don’t want it to get lost in the top of the Finder window. Is there a way to add a pop-up window to an applescript, so that it forces the user to read it before continuing with the script?

thanks
babs

Never mind!!!
I found it!!
Display Dialog :slight_smile:

Here’s a snippet that will display long text in multiple “pages”…


global myName
global theLyricsPages
property maxlines : 30 --MODIFY FOR PAGE SIZE

on makePages(someText)
	--get lines
	set OldDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to return
	set linelist to the text items of someText --i.e the lines of text seperated by return
	set AppleScript's text item delimiters to OldDelimiters
	--make pages max size maxlines
	set n to count of linelist
	set pageList to {}
	if n > maxlines then
		--more total lines than maxlines
		set m to (((n - 1) div maxlines) + 1)
		set t to 1
		repeat with j from 1 to (m - 1)
			set pageListj to items t thru (t + maxlines - 1) of linelist
			copy pageListj to end of pageList
			set t to (t + maxlines)
		end repeat
		--(remainder...)
		set pageListRemainder to items t thru n of linelist
		copy pageListRemainder to end of pageList
	else
		--less total lines than maxlines
		copy linelist to end of pageList
	end if
	set myPages to {}
	repeat with i from 1 to (count of pageList)
		set temp to ""
		repeat with j from 1 to (count of item i of pageList)
			set temp to temp & item j of item i of pageList & return
		end repeat
		copy temp to end of myPages
	end repeat
	return myPages
end makePages

on displayLyrics(somepageNumber, someTitle, someTextPages)
	set button_returned to ""
	set PageCount to (count of someTextPages)
	if PageCount is 1 then
		--1 page only
		display dialog (item somepageNumber of someTextPages) buttons {"Done"} default button 1 with title someTitle
	else
		if somepageNumber is 1 then
			--first page
			display dialog (item somepageNumber of someTextPages) buttons {"Next"} default button 1 with title someTitle
			set button_returned to button returned of the result
		else
			if somepageNumber is not PageCount then
				display dialog (item somepageNumber of someTextPages) buttons {"Back", "Next"} default button 2 with title someTitle
				set button_returned to button returned of the result
			else
				--last page
				display dialog (item somepageNumber of someTextPages) buttons {"Back", "Done"} default button 2 with title someTitle
				set button_returned to button returned of the result
			end if
		end if
		--actions...
		if button_returned is "Next" then
			my displayLyrics((somepageNumber + 1), someTitle, someTextPages)
		else
			if button_returned is "Back" then
				my displayLyrics((somepageNumber - 1), someTitle, someTextPages)
			end if
		end if
	end if
end displayLyrics



--EXAMPLE
set myName to "Save Me"
set myLyrics to "You look like
a perfect fit
For a girl in need      
of a tourniquet

But can you  save me
Come on and save me
If you could save me
From the ranks of the freaks
Who suspect they could never love anyone

'Cause I can tell 
You know what it's like 
The long farewell
Of the hunger strike

But can you save me
Come on and save me
If you could save me
From the ranks of the freaks
Who suspect they could never love anyone

You struck me down LIKE RADIUM
Like Peter Pan or Superman

You will come to save me
C'mon and save me
If you could save me
From the ranks of the freaks
Who suspect they could never love anyone
'Cept the freaks
Who suspect they could never love anyone
But the freaks
Who suspect they could never love anyone

C'mon and save me
Why don't you save me
If you could save me
From the ranks of the freaks 
Who suspect they could never love anyone

Except the freaks
Who suspect they could never love anyone
Except the freaks who could never love anyone "


my displayLyrics(1, myName, makePages(myLyrics))




Whoops! The example doesn’t quite work if you “Open this Scriptlet in your Editor” because the line feeds are getting lost in the web-page html…(???)

So cut & paste your own Aimee Mann lyrics to get the idea
(pages are maxlines lines long, with Next & Back buttons)

Hello,
That is great!! Works fine!!!
AND I LOVE AIMEE MANN :wink:
You could not have picked a better artist to test with!
thanks!!
babs

You can get round this by changing the delimiter from return to linefeed at the top of makePages(). Or better still, dispense with delimiters altogether and simply get the paragraphs. Or even better still, don’t get the paragraphs but get the texts for display directly!


on makePages(someText)
	set myPages to {}
	set lineCount to (count someText's paragraphs)
	repeat with i from 1 to lineCount by maxlines
		set j to i + maxlines - 1
		if (j > lineCount) then set j to lineCount
		set end of myPages to text from paragraph i to paragraph j of someText
	end repeat
	
	return myPages
end makePages

Yes, much better!!