can TC_Win_Print print the contents of a text editor window?

I have a program that places the results of a statistical analysis in a text editor that is ATTACHED to its own window. I would like to print the results using:

CALL TC_Win_PageSetup (ResultsWindow)
CALL TC_Win_Print (ResultsWindow)

as this should let the user set printer parameters (choice of printers; landscape vs portrait, etc.).

The calls work as expected -- they produce a printer setup box and then a dialogue box that reports that output has been sent to the printer. But all the printer produces is a blank page. There are no graphics to print, of course; but p. 365 implies that TC_Win_Print will print out text also.

I've looked through the Gold manual for version 6 and searched the Forum topics without finding anything useful. I've also looked at pwinlib.tru, which indeed prints the graphics in pwindemo.tru, but I don't have the knowledge to adapt this to my purposes. It uses

CALL Object(17,pwin_id,"","",v) to move to a new page, and
CALL Object(18,pwin_id,"","",v) to print, with the aid of a do-loop

but both 17 and 18 are undocumented at pp. 308-309 in the Manual.

I guess my alternative is to use

CALL TC_Txed_ReadTextFromArray (txid, lines$())
OPEN the default printer (can this be set by TC_Win_PageSetup?), and PRINT line$(). But I would like to give my users the options available from TC_Win_PageSetup.

If TC_Win_Print can't print the contents of a text editor, could I use the Object 17 and 18 calls to print lines$()? If so, how would that be done? -- pwindemo.tru only demonstrates graphics, not text.

Thanks!

Bill Roberts

Comments

PWINLIB

Hi Bill,

The call to TC_Win_Print actually uses the routines from pwinlib. Personally I wasn't aware that TC_win_print only prints graphics and not text, but this is relatively easy to overcome: instead of PRINT text$
use PLOT TXT, AT x,y: text$

Substitute PLOT TEXT AT in the pwdemo program and see how you get on. It works for me.

I will keep this idea in mind for the next release of the editor. In the version 6 editor, all the text is plotted not printed, so this should work with TC_win_print.

Regards
Big John

still lost...

Thanks for getting back to me so promptly. At your suggestion, I returned to pwinlib and modified the routines in pwindemo to use Plot Text, at. However, I still get only blank pages. Here is the code:

CALL Prt_PageSetup

LET title$ = "Scan_Results"
CALL Prt_Create(pwid,title$,result)

! get the text editor contents as a single string
CALL TC_Txed_GetText (txResults, R$)
DO
CALL Prt_NextBand(pwid,result)
IF result = 0 then EXIT DO
PLOT TEXT, AT .2,.2: R$
! I think pwinlib sets up a logical window with 0,1 coordinates; but integer values for x and y (corresponding to the text editor window) also fail
LOOP

CALL Prt_Close(pwid)

I have also pulled the editor contents as an array, and tried to use Prt_NextBand inside a for-next structure.

Since I have Gold 6, I tried TC_win_print rather than the pwinlib routines -- this prints a block of solid black where the text is.

Clearly I'm doing something wrong, but I don't see it.

Best regards,

Bill Roberts

TC_win_print

Hi Bill,

You need LIBRARY statements for pwlib.trc AND TrueCTRL.trc AND you need to use CALL TC_init to initialize TrueCTRl before you can use any TC_ calls.

Regards
Big John

success!

Hi, Big John,

Sorry to be confusing -- I only sent the lines from the section that tries to print the contents of the text editor. The whole program is over 1600 lines long, and the statements you mention are all placed earlier.

But success at last! The following code fragment successfully prints out documents of many pages.

DIM res$(20)
CALL TC_Txed_WriteTextToArray (txResults, res$)

CALL Prt_PageSetup

LET title$ = "Scan_Results"
CALL Prt_Create(pwid,title$,result)

LET fontname$ = "fixed" ! needed to align columns of numbers in my output
LET fontsize = 10
CALL Prt_SetFont(pwid,fontname$,fontsize,fontstyle$)

SET TEXT JUSTIFY "left", "base"
LET topmargin = .965 ! text will be printed from .95 to .05
LET linedown = 0
FOR x = 1 to ubound(res$)
LET vert = topmargin - ((x - linedown)*.015) ! .015 results in single-spacing
IF vert <= .05 then
CALL Prt_NewPage(pwid,result)
LET linedown = x - 1 ! start at the top of the page again
LET vert = .95
END IF
CALL Prt_NextBand(pwid,result)
PLOT TEXT, AT .1, vert: res$(x)
NEXT x

CALL Prt_Close(pwid)

Perhaps this could be incorporated into pwinlibdemo.tru -- it would have saved me many hours of floundering in the dark.

Thanks for your help, and your patience in correcting some rather bone-headed errors I've made along the way.

Bill

pwinlib

Hi Bill,

I will take this on board when I tackle the problem of making a commercial version of pwinlib. At present this library is just a development task and needs much polishing. For example, the routines treat text and graphics differently - as you have discovered. PLOT TEXT works extremely well even at incredibly small font sizes - less than 1mm high upper case letters. It is amazing how much print can be put onto a postage stamp.

Regards
Big John

Can user cancel print request?

Hi, Big John,

Am I right, that even though the printer dialog box created by pwinlib contains a Cancel button, there is no way to tell if the user selects it (that is, changes his mind and tries to cancel the print request)?

Trying to Cancel crashes pwinlibdemo with an unspecified interpreter system error, and of course it also crashes the program that I've been working on (above). I've tried to capture the error with a WHEN ERROR IN...USE... structure, without success. Any suggestions?

thanks,

Bill

pwinlib

Hi Bill,

You are correct. This is one of the areas that need "polishing".
I will see what I can do about passing the CANCEL button status back to the user in some way. I will keep you posted.

REgards
Big John