Where is printexpressionlist defined?

Forum for discussion about the documentation project.
dkr
Posts: 34
Joined: Nov 20, 2015 15:17
Location: Alabama, USA

Where is printexpressionlist defined?

Postby dkr » Apr 05, 2019 15:22

From the (Print/?) Using page:

Outputs formatted text to the screen or output device

Syntax

(Print | ?) [# filenum ,] [ printexpressionlist {,|;} ] Using formatstring ; [ expressionlist [ ; ] ]

Parameters
filenum
The file number of a file or device opened for Output or Append. (Alternatively LPrint may be used where appropriate, instead of Print #)
printexpressionlist
Optional preceding list of items to print, separated by commas (,) or semi-colons (;) (see Print for more details). <<-- WHERE??
formatstring
Format string to use.
expressionlist
List of items to format, separated by semi-colons (;).

Thanks,
Darren
deltarho[1859]
Posts: 1907
Joined: Jan 02, 2017 0:34
Location: UK

Re: Where is printexpressionlist defined?

Postby deltarho[1859] » Apr 05, 2019 15:52

(see Print for more details). <<-- WHERE??

Hover over Print, it is a link.
dkr
Posts: 34
Joined: Nov 20, 2015 15:17
Location: Alabama, USA

Re: Where is printexpressionlist defined?

Postby dkr » Apr 05, 2019 16:07

My link just goes to the (Print|?) page. However, there is no documentation for a printexpressionlist

Am I looking for something that is obvious to everyone else or does this printexpressionlist exist?

Thanks,
Darren
fxm
Posts: 9123
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where is printexpressionlist defined?

Postby fxm » Apr 05, 2019 16:49

This link (/wiki/KeyPgPrint) points to this information:
Consecutive values in the expression list are separated either by a comma (,) or semicolon (;). A comma indicates printing should take place at the next 14 column boundary, while a semicolon indicates values are printed with no space between them. This has a similar effect to concatenating expressions using + or &.

Print also supports the special expressions, Spc() and Tab(). These can be used to space out expressions, or to align the printing to a specific column.

A new-line character is printed after the values in the expression list unless the expression list is followed by a comma or semicolon. A Print without any expressions or separators following it will just print a new-line.
dkr
Posts: 34
Joined: Nov 20, 2015 15:17
Location: Alabama, USA

Re: Where is printexpressionlist defined?

Postby dkr » Apr 05, 2019 17:49

Ok, it appears that printexpressionlist is nearly the same as the expressionlist, but has no formatting controls

The below code shows a simple example

Code: Select all

dim as integer i,j,k
dim as string a,b,c
i = 1
j = 12
k = 23
a = "1st string"
b = "2nd string"
c = "&&&&&"
print i;j;12, using c; a;b;c;a;b
sleep

I suppose that helps if you only need to format the last variable(s)

Thanks,
Darren
counting_pine
Site Admin
Posts: 6170
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Where is printexpressionlist defined?

Postby counting_pine » Apr 05, 2019 18:56

Yeah, in most cases, I expect people will not want to mix formatted and unformatted output in a single Print expression, but the possibility is there if anyone wants to do that.
In practice, maybe it's not a feature worth having, since makes the documentation a little more complex, and possibly means more complexity for the compiler. But I guess the main reason it's there is probably because QBASIC supported it.
fxm
Posts: 9123
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where is printexpressionlist defined?

Postby fxm » Apr 06, 2019 7:38

In some cases, this can make it possible to compact two obligatorily separated instructions (because of the "comma" in the very simple example which follows) in only one:

Code: Select all

Dim As Double a = 31.7, b = -2.5

'Print Using "The different return values are:", & "a=###.##   b=##.#"; a; b   '' does not work

Print "The different return values are:",
Print Using "a=###.##   b=##.#"; a; b

Print "The different return values are:", Using "a=###.##   b=##.#"; a; b

Sleep
speedfixer
Posts: 375
Joined: Nov 28, 2012 1:27
Location: California

Re: Where is printexpressionlist defined?

Postby speedfixer » Apr 12, 2019 17:13

Perhaps a very **simple** extra example could be added to the docs to display this 'feature' of embedding using in the expressionlist.

Quick, easy, done.

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 2 guests