Printing content of checkboxes that are checked

If you have specific questions regarding the Professional Edition of Quartam Reports, this is the place to get answers from your fellow users of Quartam Reports - Professional Edition for LiveCode.
Post Reply
charles61
Posts: 4
Joined: Thu Aug 12, 2010 9:32 pm

Printing content of checkboxes that are checked

Post by charles61 » Wed Aug 25, 2010 1:41 am

Jan,

I have a project that has 72 cards with checkboxes on about 65 of the cards. With my current setup of using printing cards, all of the checkboxes are printed regardless of whether the checkboxes are checked or not checked.

I remember some time last year you mentioned that it would be possible to use Quartam Reports Professional Edition to print only the checkboxes that are checked. Since some of the user's choices would result in anywhere from 7 to 13 cards being printed with checkboxes on them, this possibility of using Quartam Reports Professional seems to be a possible option to reduce printing the number of cards.

I know that you cannot actually print the checkboxes unless you used special graphics to represent the checkboxes. But I am more interested in just printing the content of the checkboxes that are checked - not the checkboxes. I have used Quartam Reports Professional on one of my projects before but never in the manner described above. So, how can I do this with Quartam Reports Professional?

JanSchenkel
Site Admin
Posts: 110
Joined: Sun Jul 18, 2010 5:21 pm
Location: Aalst, Belgium
Contact:

Re: Printing content of checkboxes that are checked

Post by JanSchenkel » Fri Aug 27, 2010 8:26 pm

Hi Charles,

I can think of several ways to print this using Quartam Reports - but it all depends on what exactly your goal is.

One possibility is to add a virtual property 'HilitedCheckboxLabels' to your stack script that collects a return or comma-separated list of the labels of the hilited checkboxes. Something along the lines of:

Code: Select all

getProp HilitedCheckboxLabels
  local tCount, tIndex, tButton, tLabels
  put the number of buttons of the target into tCount
  repeat with tIndex = 1 to tCount
    put the long id of button tIndex of the target into tButton
    if the style of tButton is "checkbox" and the hilite of tButton is true then
      put the label of tButton & return after tLabels
    end if
  end repeat
  -- make sure to strip off the trailing return
  return char 1 to -2 of tLabels
end HilitedCheckboxLabels
Then you would have a stretching data field in the detail band of your layout, with the following expression:

Code: Select all

the HilitedCheckboxLabels of this card
Finally your printing script would be something similar to this:

Code: Select all

on mouseUp
  local tLayoutPath, tStackName, tPreviewFlag, tCardsRange
  put "the path to my layout.qrl" into tLayoutPath
  put the short name of this stack into tStackName
  put true into tPreviewFlag
  put "all" into tCardsRange
  qrtReports_PrintReportForStack tLayoutPath, tStackName, tPreviewFlag, tCardsRange
end mouseUp
When you click the button, the report will print the labels of all the hilited checkboxes, one card at a time. You don't even need the Professional Edition for the above scenario. Note that this is just a first idea - if it doesn't do the trick for you, please provide more information so that I can try and suggest a better solution.

Cheers,

Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com

charles61
Posts: 4
Joined: Thu Aug 12, 2010 9:32 pm

Re: Printing content of checkboxes that are checked

Post by charles61 » Tue Sep 14, 2010 12:51 am

Hi Jan,

Thanks for responding to my request! I would like to use your virtual property idea but there is something that may keep this from working. Some of the checkbox labels were not long enough to hold the content that I needed. Consequently, some of the checkboxes have label fields that continues with the content below in the label field. Any other ideas?

By the way, I would have responded to your suggestions but I did not have any indication that you had responded to my request.

JanSchenkel
Site Admin
Posts: 110
Joined: Sun Jul 18, 2010 5:21 pm
Location: Aalst, Belgium
Contact:

Re: Printing content of checkboxes that are checked

Post by JanSchenkel » Tue Sep 14, 2010 6:12 am

Hi Charles,

You actually can give a checkbox a multi-line label. Just create a new stack, drop a checkbox on the card, select the checkbox and type the following into the message box:

Code: Select all

set the label of the selectedObject to "Line 1" & return & "Line 2"
Unfortunately, the checkbox itself is still painted in the vertical middle, so if you want your checkbox next to the first line of text, this is obviously not an option.

You could also have another virtual property to fetch the label from your checkbox:

Code: Select all

getProp EffectiveLabel
  local tLabel
  put the longLabel of the target into tLabel
  if tLabel is empty then
    put the label of the target into tLabel
  end if
  if tLabel is empty then
    put the short name of the target into tLabel
  end if
  return tLabel
end EffectiveLabel
and we slightly change the other virtual property:

Code: Select all

getProp HilitedCheckboxLabels
  local tCount, tIndex, tButton, tLabels
  put the number of buttons of the target into tCount
  repeat with tIndex = 1 to tCount
    put the long id of button tIndex of the target into tButton
    if the style of tButton is "checkbox" and the hilite of tButton is true then
      put the EffectiveLabel of tButton & return after tLabels
    end if
  end repeat
  -- make sure to strip off the trailing return
  return char 1 to -2 of tLabels
end HilitedCheckboxLabels
Then you have to set the longLabel custom property of the checkbox button to the complete label as you want it printed. The virtual property above will fallback to the label property for all other checkboxes; and even to the short name of the checkbox if you didn't explicitly assign a label to the control.

If neither of these approaches suit you, you'll need to find a way to 'link' these label fields to the checkbox. The first thing that comes to mind, is to adopt a naming scheme: if the checkbox name is "ABC" your extended label would be "ABC_XLabel" - for that solution, we can extend the EffectiveLabel virtual property to:

Code: Select all

getProp EffectiveLabel
  local tLabel, tFieldLongName
  -- first try the accompanying extended label field
  put the long name of the target into tFieldLongName
  put "field" into word 1 of tFieldLongName
  put "_XLabel" before char -1 of word 2 of tFieldLongName
  if there is a tFieldLongName then
    put the text of tFieldLongName into tLabel
  end if
  -- fallback to the custom property
  if tLabel is empty then
    put the longLabel of the target into tLabel
  end if
  -- fallback to the regular label property
  if tLabel is empty then
    put the label of the target into tLabel
  end if
  -- fallback to the short name property
  if tLabel is empty then
    put the short name of the target into tLabel
  end if
  return tLabel
end EffectiveLabel
This combines the best of all approaches and gives you plenty of flexibility to adopt the right solution.

As for the lack of warning, I thought this forum software acted the same as on the RunRev.com forums - though I think I saw an RSS module that I could install, if it would help?

HTH,

Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com

charles61
Posts: 4
Joined: Thu Aug 12, 2010 9:32 pm

Re: Printing content of checkboxes that are checked

Post by charles61 » Wed Oct 10, 2012 12:59 am

Jan,

I finally got to my project, which I had to "shelved" because of some other projects that I was working on. I tried solutions 2 and 3 with one checkbox on a single card. I could get it working. Is there anything you could provide a checkbox on a single card showing this script should work?

JanSchenkel
Site Admin
Posts: 110
Joined: Sun Jul 18, 2010 5:21 pm
Location: Aalst, Belgium
Contact:

Re: Printing content of checkboxes that are checked

Post by JanSchenkel » Tue Oct 16, 2012 9:14 am

Hi Charles,

I've attached a simple stack to demonstrate what I was describing earlier with regards to the 'virtual' custom properties.

HTH,

Jan Schenkel.
Attachments
HilitedCheckboxesDemo.livecode.zip
HilitedCheckbox labels demonstration stack (zipped)
(1.75 KiB) Downloaded 424 times
Quartam Developer Tools for LiveCode
http://www.quartam.com

Post Reply