rightAligned Text Fields In Windows
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
rightAligned Text Fields In Windows
I have another printing problem with windows under version 5.5.3
In a right aligned text field, if one line is short and another is longer, the right side of my field is not aligned when I print.
Yes, I set the formatforprinting to false before opening my stack to set everything up.
Yes, I closed the stack, set the formatforprinting to true and then reopened the stack before printing.
This is very frustrating. Can anyone help?
Thanks,
John Miller
In a right aligned text field, if one line is short and another is longer, the right side of my field is not aligned when I print.
Yes, I set the formatforprinting to false before opening my stack to set everything up.
Yes, I closed the stack, set the formatforprinting to true and then reopened the stack before printing.
This is very frustrating. Can anyone help?
Thanks,
John Miller
Re: rightAligned Text Fields In Windows
Dear John,
Closing the stack is not enough. You have to make sure that the stack is no longer in memory. Is the destroyStack property of the stack true? It has to be true to remove the stack from memory when the stack closes. Another way is to delete the stack after closing it:
The formatForPrinting entry in the LiveCode dictionary contains quite a few useful hints. Read it carefully.
Kind regards,
Mark
Closing the stack is not enough. You have to make sure that the stack is no longer in memory. Is the destroyStack property of the stack true? It has to be true to remove the stack from memory when the stack closes. Another way is to delete the stack after closing it:
Code: Select all
save stack "Foo"
close stack "Foo"
delete stack "Foo"
set the formatForPrinting of stack "C:/path/to/stack/foo.livecode" to true
go stack "C:/path/to/stack/foo.livecode" in new window
print card 1 of stack "Foo"
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
OK ! I have tried to isolate this problem, so I made a new stack with a substack for the printing. Here is my code for the PRINT button:
on mouseUp
set the destroystack of stack "Print Page" to true
set the formatforprinting of stack "Print Page" to false
open stack "Print Page"
put "$ 9.00" into cd fld "Info"
put CR & "$ 99.00" after cd fld "Info"
put CR & "$ 999.00" after cd fld "Info"
put CR & "$ 9,999.00" after cd fld "Info"
put CR & "$ 99,999.00" after cd fld "Info"
put CR & "$ 999,999.00" after cd fld "Info"
put CR & "$ 9,999,999.00" after cd fld "Info"
put CR & CR & "Total For This Project: $ 999,999,999.00" after cd fld "Info"
close stack "Print Page"
set the formatforprinting of stack "Print Page" to true
open stack "Print Page"
answer printer
if the result = "Cancel" then
close stack "Print Page"
exit mouseUp
end
open printing
print cd 1 of stack "Print Page"
close printing
close stack "Print Page"
end mouseUp
Initially, this is what I got for a printout:
[img]/Users/johnmiller1950/Desktop[/img]
on mouseUp
set the destroystack of stack "Print Page" to true
set the formatforprinting of stack "Print Page" to false
open stack "Print Page"
put "$ 9.00" into cd fld "Info"
put CR & "$ 99.00" after cd fld "Info"
put CR & "$ 999.00" after cd fld "Info"
put CR & "$ 9,999.00" after cd fld "Info"
put CR & "$ 99,999.00" after cd fld "Info"
put CR & "$ 999,999.00" after cd fld "Info"
put CR & "$ 9,999,999.00" after cd fld "Info"
put CR & CR & "Total For This Project: $ 999,999,999.00" after cd fld "Info"
close stack "Print Page"
set the formatforprinting of stack "Print Page" to true
open stack "Print Page"
answer printer
if the result = "Cancel" then
close stack "Print Page"
exit mouseUp
end
open printing
print cd 1 of stack "Print Page"
close printing
close stack "Print Page"
end mouseUp
Initially, this is what I got for a printout:
[img]/Users/johnmiller1950/Desktop[/img]
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Oops! I submitted this and meant to preview it.
How do I attach an image to my post?
How do I attach an image to my post?
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Here are the images that show the printing results from the code above. The first is when the margins are set to 8. The second is when I have increased the margins to 20.
Re: rightAligned Text Fields In Windows
Hi,
Have you read my reply?
Mark
Have you read my reply?
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Mark,
Yes, I read your earlier reply. I have read and reread the documentation. I had NOT implemented the destroystack setting, so I inserted it into my code with no effect. I also tried your code, but using the "delete the stack" command did just that. It completely deleted my stack. When I set the formatforprinting of the stack to true, I got an error message saying that I had no such stack.
Maybe I'm overlooking something really obvious, but I'm stumped.
Thanks for your help.
John
Yes, I read your earlier reply. I have read and reread the documentation. I had NOT implemented the destroystack setting, so I inserted it into my code with no effect. I also tried your code, but using the "delete the stack" command did just that. It completely deleted my stack. When I set the formatforprinting of the stack to true, I got an error message saying that I had no such stack.
Maybe I'm overlooking something really obvious, but I'm stumped.
Thanks for your help.
John
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Mark,
My print button is contained in a stack, and the card I am trying to print is in a substack. Does that make andifference here?
John
My print button is contained in a stack, and the card I am trying to print is in a substack. Does that make andifference here?
John
Re: rightAligned Text Fields In Windows
Hi John,
Yes, it does make a difference, because the button and the substack are part of the same mainstack, which apparently is never removed from memory. In order to remove the substack from memory, you have to delete it, which will actually delete the substack completely, which would be a big problem. You have to turn the substack into a mainstack and save it to disk to be able to actually delete it from memory. Obviously, you need to execute a save command before deleting the stack from memory.
Kind regards,
Mark
Yes, it does make a difference, because the button and the substack are part of the same mainstack, which apparently is never removed from memory. In order to remove the substack from memory, you have to delete it, which will actually delete the substack completely, which would be a big problem. You have to turn the substack into a mainstack and save it to disk to be able to actually delete it from memory. Obviously, you need to execute a save command before deleting the stack from memory.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Mark,
Thanks! I'll try this post haste, and let you know what happens.
John
Thanks! I'll try this post haste, and let you know what happens.
John
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Mark,
I deleted my substack and created a new mainstack for printing operations. I tried adjusting my code to yours, but I am still NOT getting a proper right align.
Here is my code:
on mouseUp
set the defaultfolder to specialfolderpath("Desktop")
set the formatforprinting of stack "Print Page.livecode" to false
open stack "Print Page.livecode"
if the controlKey is down then
put 2 into CN
save stack "Print Page"
close stack "Print Page"
delete stack "Print Page"
set the formatforprinting of stack "Print Page.livecode" to true
go stack "Print Page.livecode" in new window
else
put 1 into CN
go to cd 1
put empty into cd fld "Info"
set the textfont of cd fld "Info" to "Arial"
set the textsize of cd fld "Info" to 8
put "$ 9.00" into cd fld "Info"
put CR & "$ 99.00" after cd fld "Info"
put CR & "$ 999.00" after cd fld "Info"
put CR & "$ 9,999.00" after cd fld "Info"
put CR & "$ 99,999.00" after cd fld "Info"
put CR & "$ 999,999.00" after cd fld "Info"
put CR & "$ 9,999,999.00" after cd fld "Info"
put CR & CR & "Total For This Project: $ 999,999,999.00" after cd fld "Info"
put CR & the long time after cd fld "Info"
save stack "Print Page"
close stack "Print Page"
delete stack "Print Page"
set the formatforprinting of stack "Print Page.livecode" to true
go stack "Print Page.livecode" in new window
end if
answer printer
if the result = "Cancel" then
close stack "Print Page"
exit mouseUp
end if
open printing
print cd CN of stack "Print Page"
close printing
hide stack "Print Page"
close stack "Print Page"
end mouseUp
I deleted my substack and created a new mainstack for printing operations. I tried adjusting my code to yours, but I am still NOT getting a proper right align.
Here is my code:
on mouseUp
set the defaultfolder to specialfolderpath("Desktop")
set the formatforprinting of stack "Print Page.livecode" to false
open stack "Print Page.livecode"
if the controlKey is down then
put 2 into CN
save stack "Print Page"
close stack "Print Page"
delete stack "Print Page"
set the formatforprinting of stack "Print Page.livecode" to true
go stack "Print Page.livecode" in new window
else
put 1 into CN
go to cd 1
put empty into cd fld "Info"
set the textfont of cd fld "Info" to "Arial"
set the textsize of cd fld "Info" to 8
put "$ 9.00" into cd fld "Info"
put CR & "$ 99.00" after cd fld "Info"
put CR & "$ 999.00" after cd fld "Info"
put CR & "$ 9,999.00" after cd fld "Info"
put CR & "$ 99,999.00" after cd fld "Info"
put CR & "$ 999,999.00" after cd fld "Info"
put CR & "$ 9,999,999.00" after cd fld "Info"
put CR & CR & "Total For This Project: $ 999,999,999.00" after cd fld "Info"
put CR & the long time after cd fld "Info"
save stack "Print Page"
close stack "Print Page"
delete stack "Print Page"
set the formatforprinting of stack "Print Page.livecode" to true
go stack "Print Page.livecode" in new window
end if
answer printer
if the result = "Cancel" then
close stack "Print Page"
exit mouseUp
end if
open printing
print cd CN of stack "Print Page"
close printing
hide stack "Print Page"
close stack "Print Page"
end mouseUp
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
I have found a solution !!!
As far as I can tell, the whole formatforprinting thing in live code does NOT work as advertised. I have, however found a work-a-round.
I have two stacks. One contains the print button, the other contains the card to be printed. Here is my code that causes everything to line up nicely on the right edge.
It's not very elegant and seems to fly in the face of the way things are supposed to be coded, but it works.
As far as I can tell, the whole formatforprinting thing in live code does NOT work as advertised. I have, however found a work-a-round.
I have two stacks. One contains the print button, the other contains the card to be printed. Here is my code that causes everything to line up nicely on the right edge.
It's not very elegant and seems to fly in the face of the way things are supposed to be coded, but it works.
Code: Select all
on mouseUp
set the defaultfolder to specialfolderpath("Desktop")
set the formatForPrinting of stack "Print Page.livecode" to false
go stack "Print Page.livecode" in new window
set the locktext of cd fld "Info" to false
set the formatForPrinting of stack "Print Page.livecode" to true
set the locktext of cd fld "Info" to true
set the printerName to "CutePDF Writer"
print card 1 of stack "Print Page"
save stack "Print Page"
close stack "Print Page"
hide stack "Print Page"
delete stack "Print Page"
end mouseUp
Re: rightAligned Text Fields In Windows
Hi,
This is funny, because I don't think the formatforprinting has any effect in your example. Does it really make a difference?
Mark
This is funny, because I don't think the formatforprinting has any effect in your example. Does it really make a difference?
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 113
- Joined: Mon Apr 30, 2007 3:33 pm
- Location: Dalton, Ohio
Re: rightAligned Text Fields In Windows
Yes, the formatforprinting is important in this code. Turning the locktext off and on after setting the formatforprinting activates the setting. Turning the lock text off and on WITHOUT setting the formatforprinting does nothing.
Go figure !!
I don't know why or how, but this works; whereas just using the formatforprinting as described in the dictionary does not work for me.
Go figure !!
I don't know why or how, but this works; whereas just using the formatforprinting as described in the dictionary does not work for me.
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: rightAligned Text Fields In Windows
It isn't really necessary to change the formatForPrinting property if only your scripts are inserting the text. Just set it once during development and forget about it. You can put text into the fields from a script regardless of the setting. You also wouldn't need to mess with the locktext, I dont usually even bother locking the fields since no one will see them. I open the printing substack invisibly, populate the cards, print them, and close it.
I routinely use a substack for printing, so that should work fine, and it's always acted as the dictionary describes for me. The difference I think is that my printing stacks always have formatForPrint set to true, so when the stackfile loads the property is already active.
I routinely use a substack for printing, so that should work fine, and it's always acted as the dictionary describes for me. The difference I think is that my printing stacks always have formatForPrint set to true, so when the stackfile loads the property is already active.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com