Print and File#
Print is used to output information to the screen or a file. The most important application is debugging, to verify that the program’s execution flow and computational logic are correct.
Syntax#
| |
| Syntax Element | Optional | Description |
|---|---|---|
OutputTarget | Optional | Specifies the output target. Defaults to PowerLanguage Editor Output Log |
Expression | Required | String, TrueFalse, or Numerical |
Output Target (OutputTarget)#
| Output Target | Description |
|---|---|
| (Not specified) | Output to PowerLanguage Editor Output Log (default) |
Printer | Specifies the default printer as the output target |
File("FilePath") | Specifies the file at FilePath as the output target. If the file does not exist, a new file will be created |
Numeric Output Format#
If Expression is numerical, you can use the Expression:C:D syntax to specify the output format:
| Syntax Element | Description |
|---|---|
C | The minimum number of output characters (integer + decimal point + decimal places). If the number of characters is less than C, leading spaces will be added in front of the value to fill up |
D | The number of decimal places. If the number of decimal places is greater than D, the value will be rounded to D places |
The default output format is a minimum of 7 characters and 2 decimal places.
Example#
Print 0.10 in the PowerLanguage Editor Output Log (3 leading spaces are added in front of 0.10).
| |
Print 1.556 in the PowerLanguage Editor Output Log (1 leading space is added in front of 1.556).
| |
Output CurrentDate and CurrentTime to the file C:\test.txt.
| |
Reference#
https://www.multicharts.com/trading-software/index.php?title=Print