Switching scripts from Quark6 to InDesign

Hi all,

Since every update of Quark 6 seems to be a step backwards I am thinking of switching to Indesign. However, I have got quite a lot of scripts which make life easy. Below is one of them.

This script selects a text file with a monthly or weekly scheme with names (e.g. ClubA, BarB, PlaceC etc). It then adds the corresponding masterpages in Quark. Works fine.

set theSchema to (choose file with prompt "Select the textfile with this weeks scheme:") as string
set masterPages to read file theSchema using delimiter {return}

tell application "QuarkXPress Passport"
	tell document 1
		repeat with i in masterPages
			make page at end with properties {master spread:i}
		end repeat
	end tell
end tell

Then Indesign.

set theSchema to (choose file with prompt "Select the textfile with this weeks scheme:") as string
set masterPages to read file theSchema using delimiter {return}

tell application "InDesign CS"
	tell active document
		repeat with i in masterPages
			set myNewPage to make page with properties {master spread:i}
		end repeat
	end tell
end tell

This part is not working:

set myNewPage to make page with properties {master spread:i}

This is also not working:

set myNewPage to make page with properties {base name:i}

Problem seems to be that the script needs the prefix of the masterpage.
Does anyone know how to get this work?

Kjeld

I don’t have an answer to your specific question, however, I am using InDesign 2.0.2 and on the CD is a PDF titled “InDesign Scripting Guide.pdf.” It’s got a lot of info. If ID CS doesn’t have it, let me know and I can email you the version that I have (keeping in mind that there are some scripting changes from 2.0 to CS, or so I’ve heard).

Hope this helps,
Brad Bumgarner, CTA

I have got this Scripting guide, but it does not mention this…

Try this (it works in ID 2.0.2):

set theSchema to (choose file with prompt "Select the textfile with this weeks scheme:") as string
set masterPages to paragraphs of (read file theSchema) --Should be something like {"A-Master", "B-Master", "C-Master"}

tell application "InDesign CS"
    set this_document to active document
    tell this_document
        repeat with i in masterPages
            make new page at end with properties {applied master:(master spread (contents of i) of this_document)}
        end repeat
    end tell
end tell

Jon

Thanks. I wil try it this evening. But maybe I have to be more clear about the list, because I doubt if your script will do the right thing.

The editor sents me a list with pages and the corresponding name of the club.
23 PlaceC
24 ClubA
25 advertisement
26 BarB
etc.
In the list which I use for the script, the page numbers are not important, so I trim them.
So the list which the script will use looks like this:
{“PlaceC”, “ClubA”, “Advertisement”, “BarB”}
No prefixes of the masterpages. In Quark6 this is no problem, but InDesign seems to need a prefix.

Kjeld

Well, of course this all presumes that you have an InDesign template that has the master pages created and named according to the text file. You can have it so that every master page is prefixed by the same letter so when you read the file as paragraphs, you’ll get a list that looks like this: {“23 PlaceC”, “24 ClubA”, “25 advertisement”, “26 BarB”}. In your routine to trim the pages, also append the same prefix. For example: {“A-PlaceC”, “A-ClubA”, “A-advertisement”, “A-BarB”}. Then this list, when combined with the code I provided above should work for you.

Barring this, you can also try this:

--let's say you've read the file and your list looks like this:
set masterPages to {"PlaceC", "ClubA", "advertisement", "BarB"}

--let's also say the master pages in your ID dcoument look like this:
--{"A-Master", "B-BarB", "C-ClubA", "D-PlaceC", "F-advertisement"}

tell application "InDesign CS"
    set this_document to active document
    tell this_document
        set master_names to name of master spreads
        repeat with i in masterPages
            repeat with j from 1 to (count master_names)
                set this_master to (item j of master_names)
                if this_master ends with (contents of i) then
                    make new page at end with properties {applied master:(master spread this_master of this_document)}
                    exit repeat
                end if
            end repeat
        end repeat
    end tell
end tell
Jon

That’s right. They contain specific information like adressess and logos.

And thanks. The last script works. It’s even not necessary to replace the page numbers by the same prefix since your script takes the last part of the name of the masterpage.
However there is a complication when the editor makes a mistake and types “ClupB” instead of “ClubB”. In the quark version of this script (see above), Quark adds a page, even if the names of the list do not correspond with those of the masterpages. In Indesign no page is added, so one is missing and all the rest of the pages don’t have the correct page number (or left or right page; hope you understand). This implicates probably another if/then statement, or I will have to use the pagenumbers of the list as well. Makes it all more complicated.

I don’t know how it is with other scripting actions, but scripting Quark seems to be less complicated then InDesign. Especially when I take a look at your script (let’s say it’s not leading straight to Rome). Since I am thinking of changing my workflow from Quark to InDesign, I also started with converting some scripts.

Are there some more people who can tell me the +++ and — of scripting Quark or Indesign? I would like to hear some more experiences.

Kjeld

I’ve used QXP since 1992 and scripted it since 1994. I have moved my workflow to InDesign and not looked back. In regards to not adding the prefix, well, that was the whole point of the alternate routine. As to adding the page regardless of whether or not the master page exists, just add a simple flag:

--let's say you've read the file and your list looks like this:
set masterPages to {"PlaceC", "ClubA", "advertisement", "BarB"}

--let's also say the master pages in your ID dcoument look like this:
--{"A-Master", "B-BarB", "C-ClubA", "D-PlaceC", "F-advertisement"}

tell application "InDesign CS"
    set this_document to active document
    tell this_document
        set master_names to name of master spreads
        repeat with i in masterPages
            set page_added to false
            repeat with j from 1 to (count master_names)
                set this_master to (item j of master_names)
                if this_master ends with (contents of i) then
                    make new page at end with properties {applied master:(master spread this_master of this_document)}
                    set page_added to true
                    exit repeat
                end if
            end repeat
            if page_added = false then make new page at end
        end repeat
    end tell
end tell

Jon

InDesign scripting is more complicated, largely because InDesign is more complicated – there’s just so much more to the app.

It also takes a slightly different approach – the scripting model mirrors the UI more, with more commands – and it can take a little while for a Quark scripter to get the hang of it. After you’ve been scripting Quark for years, you don’t find things like image 1 and story 1 as odd as newcomers do.

There are a couple of big differences. The biggest is that almost everything is scriptable in InDesign. So when you sit down to consider a project, you don’t have to go through the whole Quark exercise of half-writing the thing to see if it’s at all feasible. It’s also remarkably bug-free.

Then the list rolls on: a built-in suite for building your script’s UI, much more powerful labelling with a built-in palette, much more robust object references (ID-based rather than index based), the ability to open documents with no window for more speed, the ability to give scripts keyoard shortcuts, and on and on.

On the downside, there are some limits to move/duplicate.

But the ubiquity is the real big plus for me.


Shane Stanley

Thanks for your answer Shane. Maybe it is a good idea to just switch and don’t look back, like Jonn did. And maybe I have some advantage because I am scripting only since half a year or so.
But on the other hand, I am working as a designer on my own. And allthough I like to write scripts, the core business to earn some money is designing. Scripting is for when there’s nothing else to do. On this way I have made some pretty good time saving scripts.
But we’ll see. Shirley Hopkins wrote a good book about scripting XPress and InDesign (already for CS as well?) and here is a pretty good forum :).
Still any other comments/experiences are welcome.

Thanks,
Kjeld