Article ID: 190769
Article Last Modified on 7/13/2004
LOCAL lcString_to_Output, laOutput[1]
lcOutPut = ""
* Get the version information for VFP6.exe, returned to an array.
=AGETFILEVERSION(laOutput, HOME()+'vfp6.exe')
* Convert the contents of that array to a string with the function
* Array_to_String. Note that there must be a carriage return and line
* feed after each line.
lcString_to_Output = Array_to_String(@laOutput)
* Print the string
=Print_a_String(lcString_to_Output)
* Make sure this .prg file is not open.
CLOSE ALL
* Print this PRG file after converting it to a string with
* FILETOSTR().
=Print_a_String(FILETOSTR(SUBSTR(SYS(16),1, LEN(SYS(16))-3) + 'prg'))
RETURN
PROC Print_a_String
LPARAMETER tcStringToPrint
LOCAL laPrinters[1,1], lnArrayRow, lcPrinter
* Prompt the Select the printer.
lcPrinter = GETPRINTER()
* You could also use SET('printer', 2) to return Windows default
* printer, or SET('printer', 3) to return the VFP default printer.
IF LEN(lcPrinter) = 0
RETURN .F.
ENDIF
=APRINTERS(laPrinters)
lnArrayRow = ASUBSCRIPT(laPrinters, ASCAN(laPrinters, lcPrinter),1)
* IIF uses second column of laPrinters array in Windows 95, and
* the first in Windows NT.
* Last argument of .T. passed to STRTOFILE() means ADDITIVE output.
IF STRTOFILE(tcStringToPrint, ;
laPrinters[lnArrayRow,IIF('NT'$OS(), 1, 2)], ;
.T.) > 0
* Succeeded, since bytes were written.
RETURN .T.
ELSE
* Failed, since no bytes were written.
RETURN .F.
ENDIF
ENDPROC
PROC Array_to_String
LPARAMETERS tcarray
* Note: This would require modification for use with multicolumn
* arrays
LOCAL lni, lcOutPut
lcOutPut = ""
#DEFINE CR_LF CHR(13)+CHR(10)
* Iterate through array and append a carriage return/line feed
* to each line.
FOR lni = 1 TO ALEN(tcarray)
lcOutPut = lcOutPut + tcarray[lni] + CR_LF
ENDFOR
RETURN lcOutPut
ENDFOR
Additional query words: kbXBase kbVFp600
Keywords: kbhowto kbcode KB190769