Repository navigation
Print Using
Home › Console Functions › (Print | ?) Using
Writes values formatted by a template such as "##.##" or "&".
(Print | ?) [# filenum ,] [ printexpressionlist {,|;} ] Using formatstring ; [ expressionlist [ ; ] ]filenumprintexpressionlistformatstringexpressionlist
Print to screen various expressions using a format determined by the formatstring parameter. Internally, Print Using uses a buffer size of 2048 bytes: while it is highly unlikely that this buffer would be filled, it should be noted that output would be truncated should this limit be reached.
If no expression list is given, the format string will be printed up to the first special marker. Note that the semi-colon after formatstring is still necessary, even if no expression list is given.
The format string dictates how the expressions are to be formatted when output to the screen, indicated by the use of special marker characters. There are markers for formatting both string and numeric output:
| Marker | Formatting |
|---|---|
| ! | prints the first character of a string |
| \ \ | prints two or more characters of a string - as many as are occupied by the backslashes ('\') and any enclosed space characters (' ') |
| & | prints the entire string |
If an exact amount of characters is specified (with "!" or "\ \"), the string will be truncated or padded with spaces on the right as needed to output that many characters.
| Marker | Formatting |
|---|---|
| # | placeholder for either an integer digit, or a decimal digit if a decimal point precedes it |
| , | placed after integer digit indicates groups of 3 digits should be separated by commas in fixed-point notation |
| . | placed near # indicates place for the decimal point |
| ^^^ | uses exponential notation (E+/-#) when placed after the digit characters |
| ^^^^ | uses exponential notation (E+/-##) when placed after the digit characters |
| ^^^^^ | uses exponential notation (E+/-###) when placed after the digit characters |
| + | placed before/after the format string, controls whether the sign of a number is prepended/appended, and causes an explicit '+' sign to be printed for positive numbers |
| - | placed after the format string, causes the sign of the number to be appended rather than prepended, appending a space/negative sign for positive/negative numbers |
| $$ | placed at the start of integer digits, causes a dollar sign to be prepended to the number (after the sign if one is prepended) |
| ** | placed at the start of integer digits, causes any padding on the left to be changed from spaces to asterisks |
| **$ | placed at the start of integer digits, pads on the left with asterisks, and prepends a dollar sign after the asterisks |
| & | prints a number intelligently, using the exact number of digits required (new to version 0.21.0b) |
All of the special marker characters can be escaped by preceding them with the underscore character "_", allowing them to be printed directly. For example, "_!" is printed as "!", and "__" is printed as "_".
If a numerical value cannot fit in the number of digits indicated by the format string, the formatting is adapted to fit the number, possibly switching to scientific notation, and the number is printed preceded by the percent "%" character. E.g., the number 1234 with a formatstring of "##.##" would be printed as "%1234.00".
All other characters within the format string are printed as they appear.
A new-line character is printed after the values in the expression list unless the expression list is followed by a semicolon (;).
- QB didn't allow
"&"to be used for printing numbers.
Print Using "The value is #.## seconds"; 1.019
Print Using "The ASCII code for the pound sign (_#) is ###"; Asc("#")
Print Using "The last day in the year is & \ \"; 31; "December"
Print
For exponent As Integer = 1 To 5
Print Using "10 ^ # = ######"; exponent; 10 ^ exponent
Next exponentwill produce the output:
The value is 1.02 seconds
The ASCII code for the pound sign (#) is 35
The last day in the year is 31 Dec
10 ^ 1 = 10
10 ^ 2 = 100
10 ^ 3 = 1000
10 ^ 4 = 10000
10 ^ 5 = 100000Category: Console Functions
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing