Add a PICT using Dialog Directo

Hello All,

How can I add a PICT using Dialog Director?

I understand that a pict resource needs to be created, the problem that I am having is incorporating the PICT into my script. Please look at my sample posted below.
The DD manual has the following sample

Set pic1 to {class:pict, bounds:[10,90,10+198,90+47],contents:131}

What are the +'s used for?

Thank you,
Damon

set Language to DoMenu(["English", "French", "German", "Spanish"]) -- "Italian", "Japanese" to be added
if Language is "English" then
set lang to "En" else if Language is "French" then
set lang to "FR" else if Language is "Italian" then
set lang to "IT" else if Language is "German" then
set lang to "GR" else if Language is "Spanish" then
set lang to "SP" else if Language is "Japanese" then
set lang to "JP" end if
on DoMenu(theLanguage)
set [_next, _cancel, _choice] to dd auto dialog {size:[390, 240], contents:[¬
{class:push button, bounds:[320, 210, 380, 230], name:"Next"}, ¬
{class:push button, bounds:[240, 210, 300, 230], name:"Cancel"}, ¬
{class:radio group, bounds:[10, 45, 130, 61], button offset:[120, 50], max down:3, contents:theLanguage}, ¬
{class:pict, bounds:[10, 10, 250, 26], contents:101} ¬
], timeout after:200000} with grayscale
if _next then
return theLanguage's item _choice
else if _cancel then
error number -128
end if
end DoMenu

1. Sorry if it sounds silly but “+” means “plus” or “add”! If your left side is at 100 it is sometimes convenient to set the right side to 100 + 50 instead of 150. (e.g. you can immediately see the ‘size’ by looking at the script without doing any mental arithmetic.)

2. You don’t put the pict into your script - you put it into the app you are creating (with ResEdit). Just match its id to that you use in “{class: pict}”. Don’t get a fright when you run it in the Editor - you won’t see the pict unless you run it as an independent app. Also realise that the size of your pict is irrelevant - its size will be adjusted by dd to the bounds you have set.

PS I don’t know if you are aware of this. You don’t have to go to great trouble to prepare a ‘pict’ unless you want to. If you have any picture copied into the clipboard when you are in ResEdit’s main window just ‘paste’ - and the picture will appear as a new ‘pict’ resource. Can’t get simpler than that, can it?

You can dynamically change the size of a Dialog Director dialog with a line such as …

dd set bounds of items 1 thru 2 of dialog1 to [[230, 324, 304, 344], [322, 324, 412, 344]]

Hope this helps …

I’m not sure that that does help, George. I’m sure you’ve done that with items of other classes but have you done it with an item of class ‘pict’?

Thank you - it’s always rewarding to hear something like that. I am, though, puzzled about something.

I recognised your piece of code and remembered that not long ago I had made a couple of suggestions:

1. That all the if-this-is-that-then-do-this-else-if-that-is-this etc can be replaced with one line of 3 or 4 words.

2. That the reference to the Cancel button can be removed, together with the use of error -128.

There is most definitely no requirement that anyone implement something just because Andreas suggests it, but you will understand that I am curious as to why you have kept your original coding.

Hello Andreas,

Your solution was very helpful and extremely easy.

Thank you very much for everyone’s help. I have finished the script that I was working on. It looks pretty good for my first attempt. I probably should have started with something a little easier, but everything turned out ok.

Thank you.

Oops,

You’re right. I skimmed the message too quickly, I suppose. While you can’t set the bounds dynamically, you can change the contents of an item of class pict …

dd set contents of item 6 of dialog1 to 6001

Sorry for error.

Hello Andreas,

I left the original code because it was easier for me to work with; my limited knowledge of Apple Script was the problem.

I did not want to deviate from the original until I was able to understand AS a little bit better. Once I am an AS pro like you, I will be able to optimize my script. I really do appreciate all of your effort in helping me. Can you suggest a book that might be of interest to me?

Thank you.

The general consensus seems to be that one of the most reccomendable books is “Danny Goodman’s AppleScript Handbook (Second Edition)” - out of print ages ago - find online second hand.

The matter of simplifying that series of "if"s, though, is not so much a question of AS knowledge as the application of some logical thinking to dd:

return (item d's item 3) of theOptions 
d's item 3

gives a number - the number (or index) of the chosen radio button - which is the item number (or index) for the list theOptions. (It would be simpler if you could directly “dd get” the contents/name of the radio button, but you can’t.) Pretty simple really! Actually your “if then else” is a fair bit more complicated - if your brain can sort that out then you can do anything you set your mind to!!

And, BTW, I come here mainly to learn just because I’m NOT a pro - look at the questions I keep posting! If at the same time I can repay by helping a bit then that’s a lovely bonus.

It just occurred to me that if you found my earlier alteration to your code a bit confusing I should perhaps explain a little bit more. First of all I would suggest using the standard format of “set d to dd auto dialog {”. The code you use smacks of the sort of thing Chris Hyde uses in his examples - not really for beginners.

The full line needed to avoid all the 'if’s would be:

if d's item 1 then return theOptions's item (d's item 3) 

The first bit, “if d’s item 1”, is just shorthand for “if item 1 of d is true”. The dd dialog button clicked by the user returns “true” (equivalent to “button returned” of ‘disply dialog’) - so here we are testing for your item 1, the “Next” button.

Forgive me if all that was already obvious.

Thank you again for your continued help. I hope to rewrite my code in the near future. If you are curious of my final product I can send it to you. I know it is not a big deal but being my first script I am pretty happy.

Thank you.

Thank you for saying thanks. Keep up the good work!