Posting multiple prints on one line

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

Posting multiple prints on one line

Post by Burning Lamp »

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
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Posting multiple prints on one line

Post by fxm »

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: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Posting multiple prints on one line

Post by counting_pine »

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

Re: Posting multiple prints on one line

Post by badidea »

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

Re: Posting multiple prints on one line

Post by lizard »

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
Post Reply