Posting multiple prints on one line

New to FreeBASIC? Post your questions here.
Burning Lamp
Posts: 4
Joined: Feb 13, 2018 21:14

Posting multiple prints on one line

Postby Burning Lamp » Feb 16, 2018 21:10

Is there a way to print multiple things on one line?

Code: Select all

dim tribute(30) as string
dim i as integer

i = 0
do
    input tribute(i)
    i = i + 1
loop until i = 5

print "The tributes are as named below..."
i = 0
do
    print "Tribute"
    print i + 1
    print tribute(i)
    i = i + 1
loop until i = 5
sleep
fxm
Posts: 8537
Joined: Apr 22, 2009 12:46
Location: Paris (suburbs), FRANCE

Re: Posting multiple prints on one line

Postby fxm » Feb 16, 2018 21:21

For example:

Code: Select all

dim tribute(30) as string
dim i as integer

i = 0
do
    input tribute(i)
    i = i + 1
loop until i = 5

print "The tributes are as named below..."
i = 0
do
    print "Tribute"; i + 1, tribute(i)
    i = i + 1
loop until i = 5
sleep
counting_pine
Site Admin
Posts: 6027
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Posting multiple prints on one line

Postby counting_pine » Feb 16, 2018 22:19

You can also end a Print statement with a semicolon, which will stop it putting a line break after what you print.
badidea
Posts: 1057
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Posting multiple prints on one line

Postby badidea » Feb 16, 2018 22:44

Or use locate to set the cursor (print position).
lizard
Posts: 411
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Posting multiple prints on one line

Postby lizard » Feb 17, 2018 0:33

Burning Lamp wrote:Is there a way to print multiple things on one line?


Sometimes it is useful to create the string for output before and then display it at once:

Code: Select all

dim tribute(30) as string
dim Result as string
dim i as integer

i = 0
do
    input tribute(i)
    i = i + 1
loop until i = 5

print "The tributes are as named below..."
i = 0
do
    Result += "Tribute " & i + 1 & " " & Tribute(i) & " "
    i = i + 1
loop until i = 5
print Result
sleep

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 2 guests