Leaving the tell clause for a line

hello :slight_smile:

i have a couple of indesign scripts and would like to write a gui for them.
my idea was that i should have a controller.scpt to control the gui, and to load and run all the, so to say, sub-scripts when needed. i’d also like to have a progress indicator, and this is where my problem begins.

below is the basic idea of the whole:
controller.scpt

on clicked theObject
	if name of theObject is "doItAllButton" then
		runMe(window "mainWIn") of (load script of file (((path to me) as string) & "Contents:Resources:Scripts:doItAll.scpt"))
	end if
end clicked

doItAll.scpt

on runMe(controller)
	tell application "Adobe InDesign CS2"
		tell controller to set maximum value of progress indicator "progInd" to count of every story of active document
		repeat with i from 1 to count of every story of active document
			--do the whole stuff here
			tell controller to set content of progress indicator "progInd" to i
		end repeat
	end tell
end runMe

the problem i seem quite unable to solve on my own is this:

  1. the “tell controller…” can’t be nested inside “tell application “Adobe InDesign CS2”…” - i don’t actually know why, but it just doesn’t work that way
    but on the other hand
  2. the “tell controller…” can’t be outside of it because it needs to be run every time a story is finished - otherwise it would just have two states: 0% and 100% finished which somewhat undermines the very idea of it.

is there some kind of way to leave the “tell application…” clause just for the “tell controller…” line? or should i be trying to access the controller some other way?

could you help me please?

Model: mac mini g4
AppleScript: 1.9.3
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)

Hi,

assign the value of InDesign to a variable, this should work

on runMe(controller)
	tell application "Adobe InDesign CS2" to set countStory to count of every story of active document
	tell controller to set maximum value of progress indicator "progInd" to countStory
	repeat with i from 1 to countStory
	  	--do the whole stuff here
		tell controller to set content of progress indicator "progInd" to i
	end repeat
 end runMe

oh dear, but of course! thanks a lot for the help!
it was just quite a lot more complicated in the original version, and i seem to have got lost in it myself. i understand i should try harder to strip it down to as little as possible for myself before actually posting, instead of taking your time.
thanks a lot, again! :slight_smile:

Moved to AS Studio. [Also replaced the spaces in your code with tabs.]

As a general reply to the topic, you can use tell me if you have to.

oh, sorry. thanks!

do you mean like this “tell me to tell controller to…” inside the “tell application…”? it doesn’t seem to work, i’m afraid…
and why do you say “if you have to”? is there something wrong about “tell me”? or should i have just organized the whole thing differently?

Nothing wrong with it; You should just see if there’s a better way of organizing things (like StefanK did above).