Real Software Forums

RedHat Desktop; RB 2007 Rel 2 Pro; and Styled Text
Page 1 of 1

Author:  hnoyes [ Wed May 23, 2007 3:55 pm ]
Post subject:  RedHat Desktop; RB 2007 Rel 2 Pro; and Styled Text


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
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
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
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
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
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
//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
//default height = 9.0 inches (72 points per inch) = 1.0" off top & bottom
g=OpenPrinterDialog() //open without any properties
End If
If g<>Nil then //user didn't cancel the Print dialog
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
End If
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
line of code. stp should not still =nil after this line! Yet, it does.

Any help will be appreciated!

Author:  wademaxfield [ Thu May 24, 2007 4:51 pm ]
Post subject: 


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.

Author:  Corbin D [ Thu May 24, 2007 5:13 pm ]
Post subject: 

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 :(

Author:  hnoyes [ Thu May 24, 2007 5:25 pm ]
Post subject: 

Thanks, Wade, for the reply. I tried it and, indeed, it made stp not Nil. However, the line of code
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!

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group