
#INCLUDE 'sunshow.ch'
PROCEDURE pMain(cFileType)
aDirectory := {}
aDirectory := DIRECTORY("*." + cFileType)
cFileType = ALLTRIM(cFileType)
SetVMode(18)
FOR i = 1 TO LEN(aDirectory)
DO CASE
CASE cFileType = "SFP" .OR. cFileType = "USP" .OR. cFileType = "USL" .OR. cFileType = "SFL"
nFontHandle := LoadHPFont(aDirectory[i,1])
CASE cFileType = "FON" .OR. cFileType = "FNT"
nFontHandle := LoadMSFont(aDirectory[i,1])
CASE cFileType = "STX" .OR. cFileType = "PTX"
nFontHandle := LoadSTXFont(aDirectory[i,1])
END
cString := "TIFF is a rich image format which allows a flexibility " +;
"unheard of in other formats. Information in the form of " +;
"tags can be added or removed as needed."
WrapXY(0, 30, 610, nFontHandle, 15, 0, "R", cString)
INKEY(0)
ClearWin(0,16,0,0,29,79)
WrapXY(0, 30, 610, nFontHandle, 15, 0, "C", cString)
INKEY(0)
ClearWin(0,16,0,0,29,79)
WrapXY(0, 30, 610, nFontHandle, 15, 0, "L", cString)
UnLoadFont(nFontHandle)
INKEY(0)
ClearWin(0,16,0,0,29,79)
NEXT i
TextMode()
RETURN
PROCEDURE WrapXY(nStartX, nStartY, nEndX, nFontHandle, nFColor, nBColor, cJust, cString)
LOCAL nLineWidth, nChars, nStartLine := 1, nWidth
// Append a space to the string so it justifies correctly
IF ALLTRIM(cJust) == "R"
IF SUBSTR(cString,LEN(cString),1) <> ' '
cString := cString + ' '
ENDIF
END
// Calculate the 'column' width
nWidth := nEndX - nStartX
DO WHILE nStartline < LEN(cString)
nLineWidth := 0
nChars := 0
cHoldString := ""
// Add a character at a time to the cHold string until the width of the colomn
// is reached
DO WHILE nStartLine + nChars <= LEN(cString) .AND. GetTextWidth(nFontHandle,cHoldString) < nWidth
++nChars
cHoldString := SUBSTR(cString, nStartLine, nChars)
ENDDO
// Find last space in the string segment
IF nStartLine + nChars < LEN(cString)
IF RAT (' ',SUBSTR(cString,nStartLine,nChars)) > 0
DO WHILE SUBSTR(cString, nStartLine + nChars - 1, 1) = ' '
--nChars
END
END
IF RAT (' ',SUBSTR(cString,nStartLine,nChars)) > 0 .AND. ;
SUBSTR(cString, nStartLine + nChars - 1, 1) <> ' '
nChars := RAT(' ',SUBSTR(cString,nStartLine,nChars))
END
END
// Put text on screen
DO CASE
CASE ALLTRIM(cJust) == "R"
SunSayXY(nEndX - GetTextWidth(nFontHandle,SUBSTR(cString,nStartLine,nChars)),nStartY,nFontHandle,nFColor,nBColor,"", ;
SUBSTR(cString,nStartLine,nChars - 1))
CASE ALLTRIM(cJust) == "C"
SunSayXY((nStartX+(nWidth/2)) - (GetTextWidth(nFontHandle,SUBSTR(cString,nStartLine,nChars))/2),nStartY,nFontHandle,nFColor,nBColor,"", ;
SUBSTR(cString,nStartLine,nChars))
CASE ALLTRIM(cJust) == "L"
SunSayXY(nStartX,nStartY,nFontHandle,nFColor,nBColor,"", ;
SUBSTR(cString,nStartLine,nChars))
ENDCASE
SunSayXY(0,470,nFontHandle,12,1,"", aDirectory[i,1])
// Increment nStartY for next line of text
nStartY := nStartY + GetFontHeight(nFontHandle)
nStartLine += nChars
// Make sure we don't start a line with a wrapped space
WHILE SUBSTR(cString,nStartLine,1) == ' '
++ nStartLine
END
END
RETURN

Return to Technical Support, Notes, Tips, Tricks
and Programming Information

Return to SunShow Professional Page