Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Jul 12, 2020 7:57 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: RedHat Desktop; RB 2007 Rel 2 Pro; and Styled Text
PostPosted: Wed May 23, 2007 3:55 pm 
Offline

Joined: Mon May 21, 2007 4:57 pm
Posts: 2
Hello!

New to Linux, REALbasic, and OOP -- yeah, on a really steep learning curve!

Trying to work through the RB Tutorial (a novel approach for an EE with 26 years' experience). I cannot get my program to handle saving or opening styled text files properly -- the styling goes away through a save/open cycle. I also cannot get styled text to print.

Note: I have not compiled the code. I've only run it under the IDE.

The save code I have is:
Dim f As FolderItem
If Document=nil or DisplaySaveDialog=True Then
#If TargetWin32 //Conditional compile for Windows machines
f=GetSaveFolderItem(rtf,FileName) //Use rtf file type
#Else //On LINUX or MAC
f=GetSaveFolderItem(txt,FileName) //Use text file type
#EndIf
If f<>nil Then //If user did not cancel out of the save...
Title=f.Name //window title set to document name
Document=f //window property "Document" gets FolderItem
End If
End If
If Document<>nil Then //if the file is being saved to itself (not a new file name)
Document.SaveStyledEditField TextField
TextHasChanged=False
End If


This code appears to work properly. There are no errors, exceptions, etc. When I read the file back, all the characters are there -- just none of the styling!

The open file code I have is:
Dim f As FolderItem
Dim w As TextWindow
#If TargetWin32 //Conditional compile for Windows machines
f=GetOpenFolderItem(txt;rtf) //Use txt or rtf file type
#Else //On LINUX or MAC
f=GetOpenFolderItem(txt) //Use text file type
#EndIf
If f<>nil Then //If user clicked on open
w=new TextWindow //Create new instance of TextWindow
f.OpenStyledEditField w.TextField
w.Document=f //Assign f to document property of TextWindow
w.Title=f.Name //Assign name of f to title property of w
TextHasChanged=False
End If


This code also seems to work. There are no errors, etc. But, there is no styling, either!

The print code I have is:
Dim stp as styledTextPrinter
Dim g As Graphics
Dim ps As New PrinterSetup
Dim pageWidth, pageHeight as Integer
ps=New PrinterSetup
//This vanila print works!
g=OpenPrinterDialog() //open without any properties
g.DrawString "Hello World!",50,50
g.NextPage
If PageSetup<>"" then //If PageSetup already contains properties,
ps.SetupString=PageSetup //use them!
//Create a "printable area" which is less than the actual page size...
//This changes from printer to printer!!!
//36 points = 0.5"
pageWidth=ps.Width-36 //Allow 1/4 inch margin on each side of page;
pageHeight=ps.Height-36 //Allow 1/4 inch margin top & bottom of page
g=OpenPrinterDialog(ps) //open Print dialog with current Page Setup Properties
Else
//Default to "Letter" size paper = 8.5" X 11.0"
//Create a "printable area" which is less than the actual page size...
//This "printable area" changes from printer to printer!!!
//8.5 - 7.5 = 1.0" (0.5" margins on sides)
//11.0 - 10.0 = 1.0" (0.5" margins top & bottom)
//default width = 7.5 inches (72 points per inch) = 0.5" off each side
pageWidth=72*7.5
//default height = 9.0 inches (72 points per inch) = 1.0" off top & bottom
pageHeight=72*10.0
g=OpenPrinterDialog() //open without any properties
End If
If g<>Nil then //user didn't cancel the Print dialog
stp=TextField.StyledTextPrinter(g,pageWidth)
Do Until stp.EOF
//36 points = 0.5" (top & left margins = 0.5"); start printing @ margin corner
stp.drawBlock 36,36,pageHeight
//Anything remaining to print? (Isn't this test already being performed in the Loop?)
If not stp.eof then
g.NextPage
End If
Loop
End If


This gives an run error: "Exception of class NilObjectException Was Not Handled". Using the debugger and setting breakpoints and step through this code, I noticed that stp=nil all the way through, until the error happens on the stp.drawblock command.

I have seen some of the posts regarding drawblock and Linux. However, I believe my problem is with the
stp=TextField.StyledTextPrinter(g,pageWidth)
line of code. stp should not still =nil after this line! Yet, it does.


Any help will be appreciated!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 24, 2007 4:51 pm 
Offline

Joined: Wed Feb 21, 2007 6:28 pm
Posts: 277
Hi,

You need this:

Dim stp as styledTextPrinter
stp = New styledTextPrinter


that keeps stp from being nil. The Dim statement only make a place for it to live. The "new" creates the stp and puts it in that place.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 24, 2007 5:13 pm 
Offline

Joined: Sun Nov 13, 2005 5:48 pm
Posts: 1073
Location: Gone man...gone.
It's also possible you're running into this bug.

They have marked it as verified, but I don't think it's been fixed yet :(

_________________
God bless and thanks to my friends and fellow RB'ers for the good times!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 24, 2007 5:25 pm 
Offline

Joined: Mon May 21, 2007 4:57 pm
Posts: 2
Thanks, Wade, for the reply. I tried it and, indeed, it made stp not Nil. However, the line of code
stp=TextField.StyledTextPrinter(g,pageWidth)
set it back to Nil! Any other ideas?

Corbin referred me to a bug report (thanks!) that seems to be exactly the problem. In fact, I also received an email from Jason Parsley of REALsoftware confirming the bug and the fact that, at present, there is no workaround.

Oh well....

BTW Jason answered my query in about 12 hours. Thanks to Jason & REALsoftware for the responsiveness!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group