Creating a Job List, Another one that use to work in System 9, Please

Creating a Job List
Another one that use to work in System 9
Would like to get a version that works in OSX

Basically the script starts with a dialog box that asks for Prefix
(the Job Number followed by “.P”)

Then ask for the Number of Pages
(Start Page) (End Page)

A check box for (Include FC, IFC, IBC, BC)

Buttons
(Cancel) (Build Log)

Result is a Plain text document with all pages in it ready to import into Quark

Example

ColorLog.txt

123123.P01
123123.P02
123123.P03
123123.P04
123123.P05
123123.P06
etc.

Here is the old script;

set d_log_items to [¬
	{class:«class ∆Pic», bounds:[0, 0, 283, 195], contents:128}, ¬
	{class:«class ∆ETx», bounds:[86, 18, 157, 33], «class pVAL»:"1171_p"}, ¬
	{class:«class ∆ETx», bounds:[31, 72, 68, 87], «class pVAL»:"1"}, ¬
	{class:«class ∆ETx», bounds:[165, 72, 202, 87], «class pVAL»:"100", name:"End Page", «class ∆Bn2»:[378, 28, 455, 46]}, ¬
	{class:«class ∆Chk», bounds:[53, 115, 73, 135], name:""}, ¬
	{class:«class ∆Btn», bounds:[154, 152, 269, 172], name:"Build Log"}, ¬
	{class:«class ∆Btn», bounds:[67, 152, 145, 172], name:"Cancel"} ¬
		]
set ditems to «event DiDiDlog» {size:[283, 195], contents:d_log_items, style:«constant â—ŠWndname:"ColorLogBuilder v1.0"}

if item 7 of ditems then return
set the_prefix to item 2 of ditems
set start_pg to item 3 of ditems as integer
set end_pg to item 4 of ditems as integer
set do_cvrs to item 5 of ditems

set the_log to ""


if do_cvrs then
	set the_log to the_log & (characters 1 thru -2 of the_prefix) & "OFC" & return
	set the_log to the_log & (characters 1 thru -2 of the_prefix) & "IFC" & return
	set the_log to the_log & (characters 1 thru -2 of the_prefix) & "IBC" & return
	set the_log to the_log & (characters 1 thru -2 of the_prefix) & "OBC" & return
end if

repeat with a from start_pg to end_pg
	if a < 10 and end_pg > 99 then -- 1171p001
		set the_log to the_log & the_prefix & "00" & a & return as string
	else
		if (a < 10 and a < 99) or (a > 9 and end_pg > 99 and a < 100) then -- 1171p01 or 1171p083
			set the_log to the_log & the_prefix & "0" & a & return as string
		else
			set the_log to the_log & the_prefix & a & return as string
		end if
	end if
end repeat

set refnum to open for access file ((path to desktop as string) & "ColorLog.txt" as string) with write permission
write the_log to refnum
close access refnum

Hi, NiteOwlMacGuy.

As far as I can make out, the above code requires a third-party OSAX called Dialog Director, which I don’t think has been ported to OS X. To get a similar dialog now, you’d need to ask those nice people over on the AppleScript Studio forum; but you could get the input in stages with vanilla AppleScript. The version below does just that. I’ve also taken the liberty of debugging and improving the rest of it, but, like the original, it doesn’t contain any checks to ensure that the user’s input conforms to the expected parameters. These can be added, if you need them. (The original also ended job numbers with “_p”, not “.P” as in the text of your post. I’ve changed it to “.P” here.)

set the_prefix to text returned of (display dialog "Job number?" default answer "1171.P")
set start_pg to text returned of (display dialog "Start page?" default answer "1")
set end_pg to text returned of (display dialog "End page?" default answer "100")
set do_cvrs to button returned of (display dialog "Include FC, IFC, IBC, BC?" buttons {"Cancel", "Yes", "No"})
display dialog "Job number: " & the_prefix & return & ¬
	"Start page: " & start_pg & return & ¬
	"End page: " & end_pg & return & ¬
	"Include FC, IFC, IBC, BC: " & do_cvrs

set start_pg to start_pg as integer
set end_pg to end_pg as integer
if (end_pg > 99) then
	set o to 2
else
	set o to 3
end if
set the_log to {}

if (do_cvrs is "Yes") then
	set prefix2 to text 1 thru -2 of the_prefix
	set the end of the_log to prefix2 & "OFC"
	set the end of the_log to prefix2 & "IFC"
	set the end of the_log to prefix2 & "IBC"
	set the end of the_log to prefix2 & "OBC"
end if

repeat with a from start_pg to end_pg
	set the end of the_log to the_prefix & (text o thru 4 of ((1000 + a) as string))
end repeat

set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set the_log to the_log as string
set AppleScript's text item delimiters to astid

set refnum to open for access file ((path to desktop as Unicode text) & "ColorLog.txt") with write permission
try
	set eof refnum to 0
	write the_log to refnum
end try
close access refnum

Thank you Nigel
:slight_smile:
This will work, but I’d like to simplify it a little.

1st I’d like to have the script automatically put the “.P” at the end of the Job #

2nd Delete the “Start Page” window, have all list start with Page One.

3rd Change the “End Page” to Number of Pages"

4th Delete “Include FC, IFC, IBC, BC” window

5th No Result Window at the end

This way there are only 2 Dialog Boxes to create the list.

:)~~~~~~~~~~~~~~~~~~~~~~~

Open Quark Document “MillenniumColorLog.template”

Paste List into Quark Document

I thought you might. Good idea. :slight_smile:

You haven’t said if you want these entries included in the file anyway, or whether you want them left out. I’ve left them in for now. You can easily zap the relevant lines of the script if necessary.

I’ve revamped and commented the script (see below) and have included an input check for the number of pages.

I’ll have to pass on that one. :wink:

-- Get the job number. Use it as a prefix for the list entries.
set the_prefix to (text returned of (display dialog "Job number?" default answer "1171")) & "."

-- Page range = 1 to the number of pages entered by the user.
set start_pg to 1
repeat -- until the user enters an integer number between 1 and 999.
	try
		set end_pg to (text returned of (display dialog "Number of pages? (1 - 999)" default answer "100")) as number
		if (end_pg < 1) or (end_pg > 999) or (end_pg's class is real) then error number -1700 -- Fake "failed coercion" error.
		exit repeat -- If no errors, move on.
	on error msg number -1700
		-- Bad input. Ask again.
	end try
end repeat

-- Initialise a list to hold the entries.
set the_log to {}

-- Do the FC, IFC, IBC, and BC entries. (Omit if not wanted.)
set the end of the_log to the_prefix & "OFC"
set the end of the_log to the_prefix & "IFC"
set the end of the_log to the_prefix & "IBC"
set the end of the_log to the_prefix & "OBC"

-- Do the entires for the page numbers.
set the_prefix to the_prefix & "P"
if (end_pg > 99) then
	set o to 2 -- Pad to 3 digits. (text 2 thru 4 of ((1000 + page number) as string).)
else
	set o to 3 -- Pad to 2 digits. (text 3 thru 4 of ((1000 + page number) as string).)
end if
repeat with a from start_pg to end_pg
	set the end of the_log to the_prefix & (text o thru 4 of ((1000 + a) as string))
end repeat

-- Convert the list of entries to a single, return-delimited text.
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set the_log to the_log as string
set AppleScript's text item delimiters to astid

-- Save the text to a file on the desktop.
set refnum to open for access file ((path to desktop as Unicode text) & "ColorLog.txt") with write permission
try
	set eof refnum to 0
	write the_log to refnum
end try
close access refnum