Discussion:
Basic again
(too old to reply)
Arne Vajhøj
2024-03-11 01:04:15 UTC
Permalink
My lack of skills in VMS Basic are back to haunt me.

$ type z.pas
program z(input,output);

begin
writeln('XXX');
writeln('YYY' + chr(13) + chr(10));
writeln('ZZZ');
end.
$ pas z
$ link z
$ r z
XXX
YYY

ZZZ
$ type z.bas
program z

print "XXX"
print "YYY" + chr$(13) + chr$(10)
print "ZZZ"

end program
$ bas z
$ link z
$ run z
XXX
YYY
ZZZ

Why are there no empty line between YYY and ZZZ in the Basic
example??

(VMS Basic 1.8 on VMS Alpha)

Arne
Dave Froble
2024-03-11 01:53:46 UTC
Permalink
Post by Arne Vajhøj
My lack of skills in VMS Basic are back to haunt me.
$ type z.pas
program z(input,output);
begin
writeln('XXX');
writeln('YYY' + chr(13) + chr(10));
writeln('ZZZ');
end.
$ pas z
$ link z
$ r z
XXX
YYY
ZZZ
$ type z.bas
program z
print "XXX"
print "YYY" + chr$(13) + chr$(10)
print "ZZZ"
end program
$ bas z
$ link z
$ run z
XXX
YYY
ZZZ
Why are there no empty line between YYY and ZZZ in the Basic
example??
(VMS Basic 1.8 on VMS Alpha)
Arne
Interesting behavior ...

So, some delimiters to see what is happening. One could also write to a file,
then open it with EDT and see the actual characters.

print "(ZZZ)"; "("; CR; ")"; "("; LF; ")"
)(ZZ)(
)

So, what happens above, up to the CR the data is printed, then the CR does just
that, moves the cursor back to the left, then data up to the LF is printed, then
the LF happens, and the last character is displayed. Note, the LF will advance
the line, but does not return the cursor to the left.

Ok, this program writes to a file, then the data is displayed in EDT, then the
file is typed.

1 Open "Y.Y" For Output as File #1%

Print #1%, "<"; "ZZZ"; ">"; "<"; CR; ">"; "<"; LF; ">"

Close #1
End

<ZZZ><<CR>><<LF>>

Note that the CR is depicted as <CR> and the LF is depicted as <LF> in EDT.

$ type y.y
Post by Arne Vajhøj
<ZZ><
The first 6 characters are displayed <ZZZ><
Then the CR happens, cursor is then at column 1
Then the >< is displayed, cursor is now in column 3
Then the LF happens
Then the last character, >, is displayed

Funny things happen when CR and LF are embedded in text on a display.

:-)

In your example, the CR can return the cursor to column 1, but it appears the LF
doesn't give you the extra blank line. I can only guess that the print
statement might not add a second LF. A bit strange.
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: ***@tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
Arne Vajhøj
2024-03-11 02:34:48 UTC
Permalink
Post by Dave Froble
Post by Arne Vajhøj
My lack of skills in VMS Basic are back to haunt me.
$ type z.pas
program z(input,output);
begin
   writeln('XXX');
   writeln('YYY' + chr(13) + chr(10));
   writeln('ZZZ');
end.
$ pas z
$ link z
$ r z
XXX
YYY
ZZZ
$ type z.bas
program z
print "XXX"
print "YYY" + chr$(13) + chr$(10)
print "ZZZ"
end program
$ bas z
$ link z
$ run z
XXX
YYY
ZZZ
Why are there no empty line between YYY and ZZZ in the Basic
example??
(VMS Basic 1.8 on VMS Alpha)
Interesting behavior ...
Funny things happen when CR and LF are embedded in text on a display.
:-)
In your example, the CR can return the cursor to column 1, but it
appears the LF doesn't give you the extra blank line.  I can only guess
that the print statement might not add a second LF.  A bit strange.
The mystery evolves:

$ type z2.bas
program z2

print "XXX"
print "YYY" + chr$(13) + chr$(10) + chr$(10)
print "ZZZ"

end program
$ bas z2
$ link z2
$ run z2
XXX
YYY


ZZZ

1 LF => no blank line
2 LF => two blank lines

Arne
Simon Clubley
2024-03-11 13:13:31 UTC
Permalink
Post by Arne Vajhøj
$ type z2.bas
program z2
print "XXX"
print "YYY" + chr$(13) + chr$(10) + chr$(10)
print "ZZZ"
end program
$ bas z2
$ link z2
$ run z2
XXX
YYY
ZZZ
1 LF => no blank line
2 LF => two blank lines
Your basic assumptions may be wrong (or they be right). Run the following
command procedure and note where the cursor stops during the 5 second pause.

$ type arne.com
$ write sys$output "Line 1"
$ wait 0:00:05
$ write sys$output "Line 2"
$ @arne
Line 1
Line 2

Now turn that into a Basic program. During the 5 second pause, does the
cursor stop at the beginning of the first line or does it stop on the
line _below_ the first line ?

If it's the latter, carry on as I have no useful suggestions.

If it's the former, rewrite your tests as LF + text + CR, instead of
text + CR + LF. That makes your testing compatible with the way VMS
outputs lines of text by default. What I don't know is if VMS Basic
uses that same model.

Simon.
--
Simon Clubley, ***@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
Chris Townley
2024-03-11 13:20:33 UTC
Permalink
Post by Simon Clubley
Post by Arne Vajhøj
$ type z2.bas
program z2
print "XXX"
print "YYY" + chr$(13) + chr$(10) + chr$(10)
print "ZZZ"
end program
$ bas z2
$ link z2
$ run z2
XXX
YYY
ZZZ
1 LF => no blank line
2 LF => two blank lines
Your basic assumptions may be wrong (or they be right). Run the following
command procedure and note where the cursor stops during the 5 second pause.
$ type arne.com
$ write sys$output "Line 1"
$ wait 0:00:05
$ write sys$output "Line 2"
Line 1
Line 2
Now turn that into a Basic program. During the 5 second pause, does the
cursor stop at the beginning of the first line or does it stop on the
line _below_ the first line ?
If it's the latter, carry on as I have no useful suggestions.
If it's the former, rewrite your tests as LF + text + CR, instead of
text + CR + LF. That makes your testing compatible with the way VMS
outputs lines of text by default. What I don't know is if VMS Basic
uses that same model.
Simon.
Surely BASIC has its own formatting. Why manually put in control
characters to confuse it?

print "XXX"
print "YYY"
print ""
print "ZZZ"

will simply give:

XXX
YYY

ZZZ

if that is what you want
--
Chris
Arne Vajhøj
2024-03-11 13:30:54 UTC
Permalink
Post by Chris Townley
Surely BASIC has its own formatting. Why manually put in control
characters to confuse it?
print "XXX"
print "YYY"
print ""
print "ZZZ"
XXX
YYY
ZZZ
if that is what you want
The real context is a CGI script under Apache doing a
redirect.

And it seems like for whatever reasons the writes
(SYS$PUT) does not write CRLF to that whatever type of
connection back to Apache. So for Pascal I put them in manually
and it worked great. But for basic I hit a roadblock.

Arne
Simon Clubley
2024-03-11 13:41:29 UTC
Permalink
Post by Arne Vajhøj
Post by Chris Townley
Surely BASIC has its own formatting. Why manually put in control
characters to confuse it?
print "XXX"
print "YYY"
print ""
print "ZZZ"
XXX
YYY
ZZZ
if that is what you want
The real context is a CGI script under Apache doing a
redirect.
You didn't mention that bit Arne. :-(

The implication from your posting was that this is an interactive
session problem. This matters because the terminal driver does a
lot of output processing on the data it is asked to display.

Now I know this, try putting your output + CR + LF into a string
and then output the string only in the print statement.

This may or may not make a difference depending on what the Basic
RTL does with the string.

Simon.
--
Simon Clubley, ***@remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
Arne Vajhøj
2024-03-11 13:49:54 UTC
Permalink
Post by Simon Clubley
Post by Arne Vajhøj
Post by Chris Townley
Surely BASIC has its own formatting. Why manually put in control
characters to confuse it?
print "XXX"
print "YYY"
print ""
print "ZZZ"
XXX
YYY
ZZZ
if that is what you want
The real context is a CGI script under Apache doing a
redirect.
You didn't mention that bit Arne. :-(
No because the problem could be recreated using a
simple standalone console program.

It is a bit easier for people that may want to test, than
to get Apache CGI up and running.
Post by Simon Clubley
The implication from your posting was that this is an interactive
session problem. This matters because the terminal driver does a
lot of output processing on the data it is asked to display.
Yes, but what about the difference with Pascal?

Pascal code-->Pascal RTL--|
|-->SYS$PUT->SYS$QIOW-->terminal driver
Basic code--->Basic RTL---|
Post by Simon Clubley
Now I know this, try putting your output + CR + LF into a string
and then output the string only in the print statement.
This may or may not make a difference depending on what the Basic
RTL does with the string.
No difference.

$ type zm.bas
program zm

declare string s

print "XXX"
s = "YYY" + chr$(13) + chr$(10)
print s
print "ZZZ"

end program
$ bas zm
$ link zm
$ run zm
XXX
YYY
ZZZ

Arne
Lawrence D'Oliveiro
2024-03-12 23:09:59 UTC
Permalink
The real context is a CGI script under Apache doing a redirect.
Really, using CGI? Particularly on an OS where process creation is
expensive?
Arne Vajhøj
2024-03-13 02:19:42 UTC
Permalink
Post by Lawrence D'Oliveiro
The real context is a CGI script under Apache doing a redirect.
Really, using CGI? Particularly on an OS where process creation is
expensive?
All stories has a beginning.

The story about web applications start with CGI.

Arne
Lawrence D'Oliveiro
2024-03-13 02:27:12 UTC
Permalink
Post by Arne Vajhøj
The story about web applications start with CGI.
That was last century.
bill
2024-03-11 13:34:12 UTC
Permalink
Post by Chris Townley
Post by Simon Clubley
Post by Arne Vajhøj
$ type z2.bas
program z2
print "XXX"
print "YYY" + chr$(13) + chr$(10) + chr$(10)
print "ZZZ"
end program
$ bas z2
$ link z2
$ run z2
XXX
YYY
ZZZ
1 LF => no blank line
2 LF => two blank lines
Your basic assumptions may be wrong (or they be right). Run the following
command procedure and note where the cursor stops during the 5 second pause.
$ type arne.com
$ write sys$output "Line 1"
$ wait 0:00:05
$ write sys$output "Line 2"
Line 1
Line 2
Now turn that into a Basic program. During the 5 second pause, does the
cursor stop at the beginning of the first line or does it stop on the
line _below_ the first line ?
If it's the latter, carry on as I have no useful suggestions.
If it's the former, rewrite your tests as LF + text + CR, instead of
text + CR + LF. That makes your testing compatible with the way VMS
outputs lines of text by default. What I don't know is if VMS Basic
uses that same model.
Simon.
Surely BASIC has its own formatting. Why manually put in control
characters to confuse it?
print "XXX"
print "YYY"
print ""
print "ZZZ"
XXX
YYY
ZZZ
if that is what you want
I think what he wants is an explanation of why the behavior is
different than on any other machine. :-)

Yes, I tried it with other versions of basic and Pascal and got
the behavior Arne was looking for. Sadly, at t he moment I don't
have a VMS system running to play with it there.

bill
Single Stage to Orbit
2024-03-11 14:35:42 UTC
Permalink
Post by bill
I think what he wants is an explanation of why the behavior is
different than on any other machine.  :-)
Yes, I tried it with other versions of basic and Pascal and got
the behavior Arne was looking for.  Sadly, at t he moment I don't
have a VMS system running to play with it there.
CGI is Unix and really wants LF+CR but VMS strips away one of these
characters so it never looks like a LF+CR sequence at the other end.

All that's needed is for him to output as raw rather than "cooked".
--
Tactical Nuclear Kittens
Arne Vajhøj
2024-03-11 19:22:27 UTC
Permalink
Post by Single Stage to Orbit
Post by bill
I think what he wants is an explanation of why the behavior is
different than on any other machine.  :-)
I wanted to know why it was different from Pascal and
different from "common expectation".
Post by Single Stage to Orbit
Post by bill
Yes, I tried it with other versions of basic and Pascal and got
the behavior Arne was looking for.  Sadly, at t he moment I don't
have a VMS system running to play with it there.
CGI is Unix and really wants LF+CR but VMS strips away one of these
characters so it never looks like a LF+CR sequence at the other end.
All that's needed is for him to output as raw rather than "cooked".
I had one problem with CGI and Apache.

I solved that problem by sending extra CRLF with Pascal.

And then I got a new problem because that solution did not work
with Basic.

And the Basic problem can be demonstrated with plan terminal
output.

If I could solve the original CGI Apache problem in a way that
did not require extra CRLF then that would make it work for
both Pascal and Basic.

But I would still be curious to know why Basic is eating that CRLF.

For the CGI problem I used Simons suggestion and moved on.

Instead of:

print "..." + chr$(13) + chr$(10)
print ""

then:

print "..." + chr$(13)
print chr$(10) + ""

Arne
Arne Vajhøj
2024-03-11 13:44:15 UTC
Permalink
Post by Simon Clubley
Post by Arne Vajhøj
$ type z2.bas
program z2
print "XXX"
print "YYY" + chr$(13) + chr$(10) + chr$(10)
print "ZZZ"
end program
$ bas z2
$ link z2
$ run z2
XXX
YYY
ZZZ
1 LF => no blank line
2 LF => two blank lines
Your basic assumptions may be wrong (or they be right). Run the following
command procedure and note where the cursor stops during the 5 second pause.
$ type arne.com
$ write sys$output "Line 1"
$ wait 0:00:05
$ write sys$output "Line 2"
Line 1
Line 2
Now turn that into a Basic program. During the 5 second pause, does the
cursor stop at the beginning of the first line or does it stop on the
line _below_ the first line ?
If it's the latter, carry on as I have no useful suggestions.
If it's the former, rewrite your tests as LF + text + CR, instead of
text + CR + LF. That makes your testing compatible with the way VMS
outputs lines of text by default. What I don't know is if VMS Basic
uses that same model.
$ type zhack.bas
program z

print "XXX"
print "YYY" + chr$(13)
print chr$(10) + "ZZZ"

end program
$ bas zhack
$ link zhack
$ run zhack
XXX
YYY

ZZZ

And maybe I can use that as workaround.

But I would still like to know why a trailing CR LF get
stripped away.

I really don't like the idea of RTL stripping any
of "my data" away.

Arne
Dave Froble
2024-03-11 20:57:41 UTC
Permalink
Post by Arne Vajhøj
Post by Simon Clubley
Post by Arne Vajhøj
$ type z2.bas
program z2
print "XXX"
print "YYY" + chr$(13) + chr$(10) + chr$(10)
print "ZZZ"
end program
$ bas z2
$ link z2
$ run z2
XXX
YYY
ZZZ
1 LF => no blank line
2 LF => two blank lines
Your basic assumptions may be wrong (or they be right). Run the following
command procedure and note where the cursor stops during the 5 second pause.
$ type arne.com
$ write sys$output "Line 1"
$ wait 0:00:05
$ write sys$output "Line 2"
Line 1
Line 2
Now turn that into a Basic program. During the 5 second pause, does the
cursor stop at the beginning of the first line or does it stop on the
line _below_ the first line ?
If it's the latter, carry on as I have no useful suggestions.
If it's the former, rewrite your tests as LF + text + CR, instead of
text + CR + LF. That makes your testing compatible with the way VMS
outputs lines of text by default. What I don't know is if VMS Basic
uses that same model.
$ type zhack.bas
program z
print "XXX"
print "YYY" + chr$(13)
print chr$(10) + "ZZZ"
end program
$ bas zhack
$ link zhack
$ run zhack
XXX
YYY
ZZZ
And maybe I can use that as workaround.
But I would still like to know why a trailing CR LF get
stripped away.
I really don't like the idea of RTL stripping any
of "my data" away.
Arne
I'm pretty sure it is the PRINT statement. I'm guessing it thinks it know
better than you.

:-)

I write that because if you omit both the PRINT and the terminal driver, by
printing to a file, you will see the file has exactly what you intended.
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: ***@tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
Lawrence D'Oliveiro
2024-03-11 05:28:22 UTC
Permalink
Why are there no empty line between YYY and ZZZ in the Basic example??
Because two different language implementation teams came to two different
decisions about how to map character streams onto VMS’ insistence that
files be made out of records.
Arne Vajhøj
2024-03-11 13:21:34 UTC
Permalink
Post by Lawrence D'Oliveiro
Why are there no empty line between YYY and ZZZ in the Basic example??
Because two different language implementation teams came to two different
decisions about how to map character streams onto VMS’ insistence that
files be made out of records.
I see VMS Basic IO as record oriented and not stream oriented.

And I was not expecting any "mapping". I was expecting
PRINT to format an internal buffer with the data provided
and call SYS$PUT without any attempts to modify the data
provided.

The reality is observable different.

Arne
Dan Cross
2024-03-11 13:22:41 UTC
Permalink
Post by Arne Vajhøj
Post by Lawrence D'Oliveiro
Why are there no empty line between YYY and ZZZ in the Basic example??
Because two different language implementation teams came to two different
decisions about how to map character streams onto VMS’ insistence that
files be made out of records.
I see VMS Basic IO as record oriented and not stream oriented.
And I was not expecting any "mapping". I was expecting
PRINT to format an internal buffer with the data provided
and call SYS$PUT without any attempts to modify the data
provided.
The reality is observable different.
Please don't feed the troll.

- Dan C.
Dave Froble
2024-03-11 20:59:32 UTC
Permalink
Post by Dan Cross
Post by Arne Vajhøj
Post by Lawrence D'Oliveiro
Why are there no empty line between YYY and ZZZ in the Basic example??
Because two different language implementation teams came to two different
decisions about how to map character streams onto VMS’ insistence that
files be made out of records.
I see VMS Basic IO as record oriented and not stream oriented.
And I was not expecting any "mapping". I was expecting
PRINT to format an internal buffer with the data provided
and call SYS$PUT without any attempts to modify the data
provided.
The reality is observable different.
Please don't feed the troll.
- Dan C.
:-)

Well, this time, I think the troll is correct ...
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: ***@tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
Dan Cross
2024-03-13 12:35:00 UTC
Permalink
Post by Dave Froble
Post by Dan Cross
Post by Arne Vajhøj
Post by Lawrence D'Oliveiro
Why are there no empty line between YYY and ZZZ in the Basic example??
Because two different language implementation teams came to two different
decisions about how to map character streams onto VMS’ insistence that
files be made out of records.
I see VMS Basic IO as record oriented and not stream oriented.
And I was not expecting any "mapping". I was expecting
PRINT to format an internal buffer with the data provided
and call SYS$PUT without any attempts to modify the data
provided.
The reality is observable different.
Please don't feed the troll.
- Dan C.
:-)
Well, this time, I think the troll is correct ...
Perhaps he is. Broken clocks, twice a day, etc.
Regardless, best not to feed him. People like that
thrive on engagement.

- Dan C.

Lawrence D'Oliveiro
2024-03-11 20:40:33 UTC
Permalink
Post by Arne Vajhøj
The reality is observable different.
That’s what I mean.
Craig A. Berry
2024-03-11 18:04:14 UTC
Permalink
Post by Arne Vajhøj
My lack of skills in VMS Basic are back to haunt me.
$ type z.pas
program z(input,output);
begin
   writeln('XXX');
   writeln('YYY' + chr(13) + chr(10));
   writeln('ZZZ');
end.
$ pas z
$ link z
$ r z
XXX
YYY
ZZZ
$ type z.bas
program z
print "XXX"
print "YYY" + chr$(13) + chr$(10)
print "ZZZ"
end program
$ bas z
$ link z
$ run z
XXX
YYY
ZZZ
Why are there no empty line between YYY and ZZZ in the Basic
example??
(VMS Basic 1.8 on VMS Alpha)
I don't know the answer to your question, but the docs mention a lot of
special behavior in special circumstances, e.g., "When printing to a
terminal-format file, VSI BASIC does not write out the record until a
PRINT statement without trailing punctuation executes." Maybe the CRLF
are considered trailing punctuation? Or maybe one of the other special
rules is in effect. PRINT docs start at p. 201 here:

<https://docs.vmssoftware.com/docs/vsi-basic-for-openvms-reference-manual.pdf>
Arne Vajhøj
2024-03-11 19:15:05 UTC
Permalink
Post by Craig A. Berry
Post by Arne Vajhøj
My lack of skills in VMS Basic are back to haunt me.
$ type z.bas
program z
print "XXX"
print "YYY" + chr$(13) + chr$(10)
print "ZZZ"
end program
$ bas z
$ link z
$ run z
XXX
YYY
ZZZ
Why are there no empty line between YYY and ZZZ in the Basic
example??
(VMS Basic 1.8 on VMS Alpha)
I don't know the answer to your question, but the docs mention a lot of
special behavior in special circumstances, e.g., "When printing to a
terminal-format file, VSI BASIC does not write out the record until a
PRINT statement without trailing punctuation executes."  Maybe the CRLF
are considered trailing punctuation? Or maybe one of the other special
<https://docs.vmssoftware.com/docs/vsi-basic-for-openvms-reference-manual.pdf>
I have read it, but I got the impression that it was intended
for this:

$ type pw.bas
program pw

print "A",
print "B",
print "C"

end program
$ bas pw
$ link pw
$ run pw
A B C
$ type pw.pas
program pw(input,output);

begin
write('A');
write('B');
writeln('C');
end.
$ pas pw
$ link pw
$ run pw
ABC
$ type pw.for
program pw
write(*,'(1x,A,$)') 'A'
write(*,'(1h+,A,$)') 'B'
write(*,'(1h+,A)') 'C'
end
$ for pw
$ link pw
$ run pw
ABC

Arne
Loading...