PRINT statement
Purpose: Prints to stdout, usually the screen or printer.
A question mark, ?, can be used instead of
the PRINT statement.
Syntax 1: PRINT Comma,Separated,Expressions [;] Syntax 2: ? Comma,Separated,Expressions [;] Parameters:
|
Example 1:
PRINT "Hello "; PRINT "World "; PRINT "from BCX"
will print
Hello World from BCX
Example 2:
DIM a FOR a = 1 TO 10 PRINT a NEXT a PRINT "hello "; PRINT "world"; FOR a = 1 TO 10 PRINT a; NEXT a
Remarks: PRINT works only in console mode programs.
The WRITE statement also can be used for displaying comma delimited and quoted strings to the screen.
Please note that BCX uses the FPRINT function for printing to a file instead of the PRINT# syntax commonly used in other BASIC dialects.
PRINT to printer
To send data to a printer, BCX opens a connection to the printer using a handle to PRN, the standard printer communications device. The data then is output to the printer using a PRINT statement.
Here is a simple example of an alternative to LPRINT for sending data to the default printer.
DIMiOPEN"PRN"FOROUTPUTASfp1FORi=1TO60"This is line number", iNEXTCHR$(12)'CHR$(12) is Form Feed CharacterCLOSEfp1
Printing at column 80 row 25
For the answer to that eternal question, "How is it possible to PRINT to the screen at column 80 row 25 without causing the screen to scroll?" see the example below.
GLOBAL i, j, A$ A$ = " : The FastPrint routine is very -QUICK- at displaying text on the screen" CLS FOR i = 1 TO 24 j = j + 1 : IF j = 6 THEN j = 1 FastPrint(4, i, j, 0 , JOIN$(2,STR$(i),A$)) NEXT FastPrint(80, 25, 3, 0 , "X") KEYPRESS : CLS : END SUB FastPrint(Row, Col, Fg, Bg, Text$) LOCAL hOut AS HWND LOCAL Coord AS COORD LOCAL junk Coord.X = Row-1 Coord.Y = Col-1 hOut = GetStdHandle(STD_OUTPUT_HANDLE) WriteConsoleOutputCharacter(hOut, Text$, LEN(Text$), Coord, &junk) FillConsoleOutputAttribute (hOut, Fg+Bg*16, LEN(Text$), Coord, &junk) END SUB
BCX Console Sample Programs using PRINT function.
S22.bas PRINT "The Value Of A! = ",
A!
S24.bas PRINT "PI =" & STR$(4*ATN(1))
S26.bas PRINT a$
S33.bas PRINT "A = ", a, " and B=", b
S37.bas PRINT "The Factorial Of 34 Is
";Factorial!(34)
S50.bas PRINT "C Macros in BCX. 100 cubed
=",cube(100)
S54.bas PRINT "The length of Buffer$ =" ,
A , " bytes."
S56.bas PRINT C!, " *", A!/C!, " =", A!
S63.bas PRINT Reverse$("Hello There")
S70.bas PRINT
S72.bas PRINT ExeName$()
S74.bas PRINT COMMAND$, "
", FileDateTime$(COMMAND$)
S78.bas PRINT t$, ", ", d$, "(", s$, ")"
S80.bas PRINT h.a
S89.bas PRINT B$[C]
S91.bas PRINT "This program was launched from
",argv$[0]
S95.bas PRINT RND
S99.bas PRINT MyType[2,3,4].a
S101.bas PRINT "Windows",
OsVersion(),
" detected"
S119.bas PRINT CHR$(Sid);
S124.bas PRINT $pB ' Displays
"ello!"
S133.bas PRINT "PI = "; ATN(1)*4.0