Contents

# Print# Statement

Outputs the specified strings or numeric expressions to the screen or to a sequential file.

Use Put# statement to write data to a binary or a random file. Use Write# statement to write data to a sequential text file with delimiting characters.

### Syntax:

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

### Parameters:

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 會將該文字儲存在內部緩衝區中，並繼續執行程式，但不執行列印。當遇到結尾處不帶分號或逗號的另一個列印陳述式時，所有需要列印的文字會被一同列印。

列印出的正數表示式有一個前導空格，而負數表示式有一個前導減號。對於超出了浮點值範圍的數值型表示式，則以指數表示法列印。

如果要列印的表示式超出了一定的長度，其顯示將自動斷行。

You can insert the Tab function, enclosed by semicolons, between arguments to indent the output to a specific position, or you can use the Spc function to insert a specified number of spaces.

### Example:

    Sub ExamplePrint
        Print "ABC"
        Print "ABC","123"
        i = FreeFile()
        Open "C:\Users\ThisUser\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

相關主題

Close Statement

Put# Statement

Open Statement

Write# Statement

Please support us!