>From: Mikearrony@... >Date: Sat, 13 Nov 1999 19:18:44 EST >To: futurebasic@... >Subject: styled Edit field to disk and printer > > I have 2 things that I need to do and hope you can help. I am working >in FB2. >1) I need to write a styled edit field to disk, both with styling and as a >plain text document. It needs to be read by simple text or some such Word P. > The program that is producing it will not be reading it back for any >reason. To do this you take the handle to the EF and split it into TEXT and styl information. You write the TEXT to the data fork with a WRITE FILE command and then add the style information to a styl resource #128 using a PG function, FN pGreplaceXRes. If you just want the text, don't save the style information. To make it a SimpleText document, use DEF OPEN "TEXTttxt" before you open the file that you are writing to. This file will be opened by SimpleText when double-clicked. 'This function will save an edit field to a file as a SimpleText file 'If there is any style information, it will be saved as well 'Uses PG FN pGreplaceXRes to replace/add the styl resource '========================================= LOCAL FN saveText (efNum%, fileName$, fileVolNum%) 'send an EF number and a file name and volume reference number to save EF to. DIM zTxtH&, osErr, bytes&, stSz& DIM newFolder, h&, fileResNum% GET FIELD zTxtH&, efNum% LONG IF zTxtH& DEF OPEN "TEXTttxt" OPEN "O", #1, fileName$, 1, fileVolNum% osErr = FN HLOCK(zTxtH&) bytes& = {[zTxtH&]} LONG IF bytes& WRITE FILE #1, [zTxtH&]+2, bytes& END IF osErr = FN HUNLOCK(zTxtH&) CLOSE #1 '==================================== 'remove this to just save the text without the styl information bytes& = bytes& + 2 stSz& = FN GETHANDLESIZE (zTxtH&) - {[zTxtH&]} - 2 LONG IF stSz& newFolder = FOLDER ("", fileVolNum%) CALL CREATERESFILE (fileName$) h& = FN NEWHANDLE (stSz&) BLOCKMOVE [zTxtH&] +bytes&, [h&], stSz& fileResNum% = USR OPENRFPERM(fileName$, fileVolNum%, _fsrdWrPerm) FN pGreplaceXRes(h&, _"styl", 128,"", fileResNum%) CALL CLOSERESFILE (fileResNum%) END IF '========================================== KILL FIELD zTxtH& CALL USERESFILE (gResRef) 'for PG project END IF END FN >2) I need to send this field to the printer as is and it will involve more >than 1 page. This is a little more complicated. I have some routines that will display a dialog box while printing, get the number of copies and the size of the paper (from the PRHANDLE), check for command-period interupts and print multi-page edit fields including a page number or message on each page. They are modified from PG FNs or others available around. I will be glad to send them to you if you like and you can modify them to suit your needs. >If you have a simple routein that I can use or direct me to where to find >the information, I'd greatly appreciate you assistance. Thanks! > >Mike > Mark