It is currently Thu Mar 30, 2017 11:33 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: PRINT with comma at end
Unread postPosted: Sun Sep 04, 2016 5:41 am 
Offline

Joined: Mon Oct 22, 2012 7:32 am
Posts: 130
[Admin Note: Moved these posts out of the "[GENERAL] TooBASIC (BASIC! 2)" topic of the TooBASIC >> Questions and Comments subforum, because their intent is to report a bug in standard BASIC!]

BTW.. The above program runs in BASIC! but not correctly. [Admin Note: refers to this post]
print i;":";a[i];double(a[i]), prints a comma (,) at the end instead of a tab.
I had to use print i;":";a[i];double(a[i]);chr$(9); to force a tab at the end..

Just thought you'd like to know..


Last edited by jMarc on Sat Sep 10, 2016 9:21 am, edited 1 time in total.
First post of a block moved from another subforum.


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Sun Sep 04, 2016 7:46 am 
Offline
User avatar

Joined: Thu Jan 08, 2015 11:28 am
Posts: 1087
Location: .NET
but 'print "string",' should put a comma at the end, no? that's what BASIC! does, so that's what tooBASIC now does. comma at the end is not documented, only semicolon is.

_________________
https://github.com/evolbug
http://toobasic.jimdo.com


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Sun Sep 04, 2016 10:58 am 
Offline
User avatar

Joined: Sun Nov 23, 2014 8:15 am
Posts: 2184
Location: romania
I don't agree with kokenje (not sure if is a bug). Comma should print ', '(comma-space, not TAB), to keep my BEXgen compiler compatible with BASIC!, i made it work the same way. (let's keep back compatibility)
Kokenje's observation would mention: the next print after comma should stay in the same line, but BASIC does a new line, so I did.


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Sun Sep 04, 2016 2:23 pm 
Offline

Joined: Mon Oct 22, 2012 7:32 am
Posts: 130
Hmmmm! IMO I think BASIC! has the bug.
Control characters in the print statement should be treated as control characters.
In the case of BASIC! if I want a comma at the end of a print statement I will enter it as ","
I tried the following code in 2 other basic languages plus BASIC!
Code:
for i = 1 to 2
print i,"a",
print "b"
next

Output for other basic languages
Code:
1.0   a   b
2.0   a   b

Output for BASIC!
Code:
1.0   a,
b
2.0   a,
b

If I wanted a comma after the "a" I would have entered the comma in ","

The code using ; as a control character, The ; means 'don't move the cursor'
Code:
for i = 1 to 2
print i;"a";
print "b"
next

Output in the other basic languages including BASIC! gave the following:
Code:
1.0ab
2.0ab

So why does BASIC! print the comma at the end of the first example and not print the ; at then end of the second example.
Both the , and ; are control characters and should be treated the same..


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Sun Sep 04, 2016 2:44 pm 
Offline
User avatar

Joined: Thu Jan 08, 2015 11:28 am
Posts: 1087
Location: .NET
kokenge, why does your comma print TAB? it should print comma and a space ", ", what's up with that? what version of BASIC! are you using?

_________________
https://github.com/evolbug
http://toobasic.jimdo.com


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Mon Sep 05, 2016 12:18 am 
Offline
User avatar

Joined: Sun Nov 23, 2014 8:15 am
Posts: 2184
Location: romania
evolbug wrote:
kokenge, why does your comma print TAB? it should print comma and a space ", ", what's up with that? what version of BASIC! are you using?

the same thing to me: ', ', not tab.


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Tue Sep 06, 2016 6:26 am 
Offline

Joined: Mon Oct 22, 2012 7:32 am
Posts: 130
Ok.. If I do this it works.
Code:
for i = 1 to 5
print i
next


If I do this the the previous version of tooBasic gave an error. Now I get the number followed with a comma (,).
It should print the 5 numbers followed with a <tab>.
Code:
for i = 1 to 5
print i,
next


If I do this it works correctly by placing all the 5 numbers next to each other
Code:
for i = 1 to 5
print i;
next


Thanks for the help..


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Tue Sep 06, 2016 6:28 am 
Offline
User avatar

Joined: Thu Jan 08, 2015 11:28 am
Posts: 1087
Location: .NET
kokenge, no it should NOT print the numbers followed by a TAB, BASIC! does not do that. BASIC! prints ", " (comma followed by whitespace).

_________________
https://github.com/evolbug
http://toobasic.jimdo.com


Top
 Profile  
 
 Post subject: Re: [GENERAL] TooBASIC (BASIC! 2)
Unread postPosted: Sat Sep 10, 2016 9:39 am 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2785
Location: Colorado, U.S.
kokenge wrote:
Hmmmm! IMO I think BASIC! has the bug.
Control characters in the print statement should be treated as control characters.
Yes, the comma is a control character, and the manual describes what it does:
De Re BASIC! wrote:
If the comma (,) separator follows an expression then a comma and a space will be printed after the value of the expression.
That's how BASIC! defines the comma operator in a PRINT statement. It is not a bug.

It may be different from other versions of BASIC. Let me repeat the question evolbug and gika asked, and add one of my own:
  • What versions of BASIC do what you expect?
  • What exactly do you expect?

You talk about it as if everyone knows what you think the comma should do, but clearly we do not. Please explain?
From your example, it looks like you think a terminal comma should suppress the line feed and add a tab. Is that correct?

kokenge wrote:
So why does BASIC! print the comma at the end of the first example and not print the ; at then end of the second example.
Both the , and ; are control characters and should be treated the same..
They are treated exactly as they are defined:
  • Comma after an expression inserts a comma and a space in the printed output. That's all.
  • Semicolon suppresses the line feed. It also holds the line to print, building an output string until you print a line with no semicolon.

Obviously I can't change the definition of BASIC! now -- it would break many existing programs. But if we need to add a new feature to BASIC!, please tell us what you want it to do.

- Marc


Top
 Profile  
 
 Post subject: Re: PRINT with comma at end
Unread postPosted: Sat Sep 10, 2016 12:46 pm 
Offline
User avatar

Joined: Sun Nov 23, 2014 8:15 am
Posts: 2184
Location: romania
let it as it is


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred