Page 1 of 1
Check Box
Posted: Mon Feb 01, 2010 4:03 pm
by bsouthuk
Hi - wonder is someone can help.
I have a stack containing 15 cards and a user is able to click on a button to print all of these cards. However, on certain occassions a user may not want to print all of them and am thinking of putting 15 'check buttons' on the first card which the user can click if they do not require certain cards not to be printed.
At the moment the code I am using in the 'print' button is:
Code: Select all
set the formatForPrinting of stack "qg" to true
set the printRotated to false
open printing with dialog
set the printScale to 1
set the printMargins to 0, 0, 0, 0 --1/2 inch margins
set the printGutters to 0, 0 --1/4 inch gutters
repeat with i = 1 to number of cards
print card i
end repeat
Can anyone suggest suitable coding so that 'check boxes' relating to the individual cards that have been ticked are not to be printed?
Cheers
Daniel
Re: Check Box
Posted: Mon Feb 01, 2010 4:45 pm
by Klaus
Hi Daniel,
bsouthuk wrote:... if they do not require certain cards not to be printed....
??? Does that mean they can check the cards they want to get printed?
Anyway, I would group all these buttons and use a function to get a list of all checked buttons:
Code: Select all
function whatCards2Print
repeat with i = 1 to to the num of btns of grp "Check4Print" of cd 1
if the hilite of btn i of grp "Check4Print" of cd 1 = treu then
put i & "," after new_list
end if
end repeat
## Get rid of trailing COMMA
delete char -1 of new_list
end whatCards2Print
Then you can use this in your print handler:
Code: Select all
...
put whatCards2Print() into card2print
repeat for each item i in cards2print
print card i
end repeat
...
You get the picture
Best
Klaus
Re: Check Box
Posted: Mon Feb 01, 2010 5:05 pm
by bsouthuk
Hi Klaus
Thanks very much for this.
I'm a bit of a beginner with the print function.
What I have done is:
put 15 check buttons on card 1 of the stack and named them "page 1", "page 2" etc
Put the code you have given in the Print button
I have added the 'open printing with dialog' code but nothing is printing when I select my printer. I know i've probably missed something very simple out but as I say i'm a total beginner when it somes to the print function.
Can you see what I have missed?
Cheers
Daniel
Re: Check Box
Posted: Mon Feb 01, 2010 5:18 pm
by wsamples
Daniel, if you copy + pasted his snippet, you may have to correct the spelling of "true" in
"if the hilite of btn i of grp "Check4Print" of cd 1 = treu then"
I have some habitual typing dyslexia myself where I get all the letters but in the wrong order "filed" = "field" etc... *sigh*
Re: Check Box
Posted: Mon Feb 01, 2010 5:39 pm
by bsouthuk
That wasn't the problem as did notice that myself.
For some reason though nothing is printing even though I ticked some of the check buttons. Am I right by putting your first snippet in the print button script just before your second snippet?
Cheers
Dan
Re: Check Box
Posted: Mon Feb 01, 2010 5:40 pm
by bsouthuk
Am I to put any script in the 'check buttons'?
Re: Check Box
Posted: Mon Feb 01, 2010 5:51 pm
by Klaus
Hi Daniel,
sorry, for "treu", I am lefthanded and the left hand is sometimes a millisecond faster than my right hand when typing with 10 fingers

Glad you found it, other people tend to NOT think about snippets when copying nor take a look nor try to find errors like this,
they just come up with "That not works, boohoo...", hate it
Anyway, where you put the function does not matter (card or stack script) as long as your printing handler will find it!
And no scripting required in the checkboxes.
You have to add "close printing" right after the repeat loop, or the printout will not start!
See the docs (Rev dictionary) for more info, which is ALWAYS a good idea, hint, hint!
Best
Klaus
Re: Check Box
Posted: Mon Feb 01, 2010 6:05 pm
by bsouthuk
ha thanks Klaus it really is much appreciated.
Though I am still having proglems even after typing in the close printing script.
What do you mean when you say '## Get rid of trailing COMMA'. Has this anything to do with the problems I am having?
Cheers again
Dan
Re: Check Box
Posted: Mon Feb 01, 2010 6:13 pm
by Klaus
bsouthuk wrote:...What do you mean when you say '## Get rid of trailing COMMA'. Has this anything to do with the problems I am having?
That is just the explnation of the following line in the scrupt!
After the repeat loop the last cahracter (char -1) of "new_list" is a COMMA!
And no, this has nothing to do with your problem, as you might have guessed.
Sorry no idea why it does not print.
Could you please post your complete latest script, please?
Best
Klaus
Re: Check Box
Posted: Mon Feb 01, 2010 6:18 pm
by bsouthuk
I have 15 Check buttons on card 1 of my 15 card stack and have grouped them and named the group "Check4Print"
The script I have in the card script is:
Code: Select all
function whatCards2Print
repeat with i = 1 to the num of btns of grp "Check4Print" of cd 1
if the hilite of btn i of grp "Check4Print" of cd 1 = true then
put i & "," after new_list
end if
end repeat
## Get rid of trailing COMMA
delete char -1 of new_list
end whatCards2Print
See I told you I was a complete when it came to this function!
Cheers Klaus
Daniel
And the script I have in my print button is:
Code: Select all
on mouseUp
open printing with dialog
put whatCards2Print() into whatCards2Print
repeat for each item i in whatCards2Print
print card i
end repeat
close printing
end mouseUp
Re: Check Box
Posted: Mon Feb 01, 2010 6:26 pm
by Klaus
Ooooops, how embarrassing, I forgot the MOST important part of ANY function:
Code: Select all
function whatCards2Print
repeat with i = 1 to the num of btns of grp "Check4Print" of cd 1
if the hilite of btn i of grp "Check4Print" of cd 1 = true then
put i & "," after new_list
end if
end repeat
## Get rid of trailing COMMA
delete char -1 of new_list
####### !!!!!! ARRRRGH :D
RETURN new_list
end whatCards2Print
So the function returned NOTHING and therefore the printing loop did not start at all
Best
Klaus
Re: Check Box
Posted: Mon Feb 01, 2010 6:43 pm
by bsouthuk
Thats sorted it! Thank you very very very much.
Cheers
Daniel
Re: Check Box
Posted: Mon Feb 01, 2010 6:44 pm
by Klaus
GREAT!
Best
Klaus