Page 1 of 1

XSample_186()

Posted: Fri May 12, 2017 2:52 am
by Eugene Lutsenko
After editing the row to save it to a file on disk?

Code: Select all

STATIC FUNCTION XSample_186()

/* This example uses DC_FormatMemoToWidth() to perfectly
   fit memo text into an object based on its font */

LOCAL cText, GetList[0], GetOptions, nWidth, cFont, cOutString, oMemo, oButton

nWidth := 640
cFont := Pad('12.Courier',40)

TEXT INTO cText WRAP

Now is the time for all good men to come to the aid of their country.

The quick red fox jumped over the lazy dog's back.

When in the course of human events it becomes necessary to Narfel the Garthog, then let the Narfelling begin.

ENDTEXT

cOutString := cText

@ 1,0 DCSAY 'Width (in pixels)' GET nWidth PICTURE '999'
@ 2,0 DCSAY ' Font' GET cFont POPUP {|c|DC_PopFont(c)}

@ 3,0 DCMULTILINE cOutString  SIZE 70,14 ;
      FONT Alltrim(cFont) OBJECT oMemo

@18,0 DCPUSHBUTTON CAPTION 'Format Text' SIZE 12,1.2 ;
      OBJECT oButton ;
      ACTION {||cOutString := DC_FormatMemoToWidth(cText,nWidth,cFont), ;
                DC_GetRefresh(GetList), ;
                oMemo:setFontCompoundName(Alltrim(cFont))}

DCGETOPTIONS SAYWIDTH 150 SAYRIGHTBOTTOM

DCREAD GUI FIT TITLE 'String Format Test' ;
   OPTIONS GetOptions ;
   EVAL {||PostAppEvent(xbeP_Activate,,,oButton)}

RETURN nil

*** END OF EXAMPLE ***

Re: XSample_186()

Posted: Fri May 12, 2017 7:42 am
by rdonnay
MemoWrit('MyMemo.Txt',cOutString)

Re: XSample_186()

Posted: Fri May 12, 2017 8:26 am
by Eugene Lutsenko
rdonnay wrote:MemoWrit('MyMemo.Txt',cOutString)
Thank You, Roger! Happened. And I wrote: MemoWrit('MyMemo.Txt',cText). It would Seem a small distinction, but important:)