目录
索引 🔎︎

# Print 语句

将指定字符串或数字表达式输出到对话框或文件。

### 语法:

    Print [#filenum,] expression1[{;|,} [Spc(number As Integer);] [Tab(pos As Integer);] [expression2[...]]

### 参数:

filenum: Any numeric expression that contains the file number that was set by the Open statement for the respective file.

expression: Any numeric or string expression to be printed. Multiple expressions can be separated by a semicolon. If separated by a comma, the expressions are indented to the next tab stop. The tab stops cannot be adjusted.

number: Number of spaces to be inserted by the Spc function.

pos: Spaces are inserted until the specified position.

如果最后一个要打印的表达式后面出现分号或逗号，LibreOffice Basic 将把该文字存储在一个内部缓冲区中并继续执行程序，但不执行打印。当遇到结尾处不含分号或逗号的另一个打印语句时，将一并打印所有需要打印的文字。

打印的正数表达式前面带有一个空格，而打印出的负数表达式前面带有一个减号。对于超出了浮点数取值范围的数字表达式，则以指数表示法打印。

如果要打印的数字表达式超出了一定的长度，将会自动换行。

您可以在自变量之间插入「Tab」函数 (用分号括起)，使输出缩进到指定的位置；或者使用「Spc」函数插入指定的空格数。

### 示例:

    Sub ExamplePrint
        Print "ABC"
        Print "ABC","123"
        i = FreeFile()
        Open "C:\Temp.txt" For Output As i
        Print #i, "ABC"
        Close #i
    End Sub

    Sub ExamplePrint
        Print "ABC"
        Print "ABC","123"
        i = FreeFile()
        Open "~/temp.txt" For Output As i
        Print #i, "ABC"
        Close #i
    End Sub